Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/miro/dominant_colors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def open_source_image
return File.open(@src_image_path) unless remote_source_image?

original_extension = @image_type || URI.parse(@src_image_path).path.split('.').last

original_extension = URI.parse(@src_image_path).path.split('/').last if original_extension.length>3
#Added above line since URL images without extensions would not work
tempfile = Tempfile.open(["source", ".#{original_extension}"])
remote_file_data = open(@src_image_path).read

Expand Down
7 changes: 7 additions & 0 deletions spec/cabelhigh_spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'miro'

RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
config.filter_run :focus
end
17 changes: 17 additions & 0 deletions spec/miro/Working_URL_Image.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'cabelhigh_spec_helper'

describe Miro::DominantColors do
context "Old Miro wouldn't work with non-local files" do
let(:online_image) {Miro::DominantColors.new('https://i.scdn.co/image/4c985df11e68ebe6453feea645cd5fa259e43333')}
let(:expected_hexes) { ["#010101", "#e3e4e4", "#021f18", "#0e190e", "#59615d", "#067f5d", '#295521', '#0b4e24']}
it "still successfully creates a new Miro object from an online image" do
online_image.src_image_path.should eq("https://i.scdn.co/image/4c985df11e68ebe6453feea645cd5fa259e43333")
end

it "can get hex colors from an online image" do
online_image.to_hex.should eq(expected_hexes)
end
end


end
2 changes: 1 addition & 1 deletion spec/miro/dominant_colors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
end
end

describe "#histogram" do
describe "#histogram" do
it "should return a hash" do
subject.histogram.should be_an_instance_of(Array)
end
Expand Down