miro 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8da79a7879154e553ec78af76e25f2a9d8a6b232
4
+ data.tar.gz: d180f86a6a43976d2d0ef84455aca46b109e36af
5
+ SHA512:
6
+ metadata.gz: 85e2a88179149a9afd9e4f62ad5a997115d705c72dd8d649a98b1cf157ee1e12fc756cf006a9f688f6e3a39c3aab8a6c4c03b8679fa2ba5765bb43c4330f0ee5
7
+ data.tar.gz: b870d98b936ebc868b49d5771ae7e6a402c640becc21bbd5c84c3abc81e5da488dc37298277c900fe2de9bef94b1c1fd52badf2fa0cfbfd8d8b81fa6000fffd6
@@ -9,8 +9,9 @@ require "miro/dominant_colors"
9
9
  module Miro
10
10
  class << self
11
11
  def options
12
+ convert = `which convert`.strip
12
13
  @options ||= {
13
- :image_magick_path => "/usr/bin/convert",
14
+ :image_magick_path => convert.length > 0 ? convert : '/usr/bin/convert',
14
15
  :resolution => "150x150",
15
16
  :color_count => 8,
16
17
  :quantize => 'RGB'
@@ -2,8 +2,9 @@ module Miro
2
2
  class DominantColors
3
3
  attr_accessor :src_image_path
4
4
 
5
- def initialize(src_image_path)
5
+ def initialize(src_image_path, image_type = nil)
6
6
  @src_image_path = src_image_path
7
+ @image_type = image_type
7
8
  end
8
9
 
9
10
  def to_hex
@@ -54,12 +55,12 @@ module Miro
54
55
 
55
56
  def open_source_image
56
57
  if remote_source_image?
57
- original_extension = URI.parse(@src_image_path).path.split('.').last
58
+ original_extension = @image_type || URI.parse(@src_image_path).path.split('.').last
58
59
 
59
60
  tempfile = Tempfile.open(["source", ".#{original_extension}"])
60
61
  remote_file_data = open(@src_image_path).read
61
62
 
62
- tempfile.write(RUBY_VERSION =~ /1.9/ ? remote_file_data.force_encoding("UTF-8") : remote_file_data)
63
+ tempfile.write(should_force_encoding? ? remote_file_data.force_encoding("UTF-8") : remote_file_data)
63
64
  tempfile.close
64
65
  return tempfile
65
66
  else
@@ -67,6 +68,10 @@ module Miro
67
68
  end
68
69
  end
69
70
 
71
+ def should_force_encoding?
72
+ Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('1.9')
73
+ end
74
+
70
75
  def open_downsampled_image
71
76
  tempfile = Tempfile.open(["downsampled", '.png'])
72
77
  tempfile.binmode
@@ -1,3 +1,3 @@
1
1
  module Miro
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Miro do
4
4
  describe '.options' do
5
5
  it "has default options" do
6
- Miro.options[:image_magick_path].should eq('/usr/bin/convert')
6
+ Miro.options[:image_magick_path].should eq(`which convert`.strip)
7
7
  Miro.options[:color_count].should eq(8)
8
8
  Miro.options[:resolution].should eq('150x150')
9
9
  end
metadata CHANGED
@@ -1,78 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
5
- prerelease:
4
+ version: 0.2.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jon Buda
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-04 00:00:00.000000000 Z
11
+ date: 2013-07-18 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: cocaine
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: oily_png
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: fakeweb
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  description: Extract the dominant colors from an image.
@@ -97,31 +88,29 @@ files:
97
88
  - spec/spec_helper.rb
98
89
  homepage: https://github.com/jonbuda/miro
99
90
  licenses: []
91
+ metadata: {}
100
92
  post_install_message:
101
93
  rdoc_options: []
102
94
  require_paths:
103
95
  - lib
104
96
  required_ruby_version: !ruby/object:Gem::Requirement
105
- none: false
106
97
  requirements:
107
- - - ! '>='
98
+ - - '>='
108
99
  - !ruby/object:Gem::Version
109
100
  version: '0'
110
101
  required_rubygems_version: !ruby/object:Gem::Requirement
111
- none: false
112
102
  requirements:
113
- - - ! '>='
103
+ - - '>='
114
104
  - !ruby/object:Gem::Version
115
105
  version: '0'
116
106
  requirements:
117
107
  - ImageMagick
118
108
  rubyforge_project:
119
- rubygems_version: 1.8.23
109
+ rubygems_version: 2.0.3
120
110
  signing_key:
121
- specification_version: 3
111
+ specification_version: 4
122
112
  summary: Extract the dominant colors from an image.
123
113
  test_files:
124
114
  - spec/miro/dominant_colors_spec.rb
125
115
  - spec/miro_spec.rb
126
116
  - spec/spec_helper.rb
127
- has_rdoc: