photomosaic 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,58 @@
1
+ require "spec_helper"
2
+
3
+ module Photomosaic
4
+ describe Options do
5
+ let(:api_key) { "api_key" }
6
+ let(:base_image_path) { "base_image_path" }
7
+ let(:colors) { 16 }
8
+ let(:height) { 10 }
9
+ let(:level) { 4 }
10
+ let(:width) { 20 }
11
+ let(:results) { 100 }
12
+ let(:keyword) { "keyword" }
13
+ let(:output_path) { "output_path" }
14
+
15
+ before do
16
+ allow(ENV).to receive(:[]).with("PHOTOMOSAIC_API_KEY").and_return(api_key)
17
+ end
18
+
19
+ describe "#parse" do
20
+ context "when the required parameters are specified" do
21
+ let(:argv) do
22
+ "-b #{base_image_path} -o #{output_path} -k #{keyword} -c #{colors} -h #{height} -w #{width} -r #{results} -l #{level}".split(" ")
23
+ end
24
+
25
+ it "should return Options instance" do
26
+ expect(described_class.parse(argv)).to be_a described_class
27
+ end
28
+
29
+ it "should parse option string" do
30
+ options = described_class.parse(argv)
31
+ expect(options.api_key).to eq api_key
32
+ expect(options.base_image).to eq File.expand_path(base_image_path)
33
+ expect(options.color_model).to eq :rgb
34
+ expect(options.colors).to eq colors
35
+ expect(options.height).to eq height
36
+ expect(options.keyword).to eq keyword
37
+ expect(options.level).to eq level
38
+ expect(options.output_path).to eq File.expand_path(output_path)
39
+ expect(options.results).to eq results
40
+ expect(options.search_engine).to eq Photomosaic::SearchEngine::Bing
41
+ expect(options.width).to eq width
42
+ end
43
+ end
44
+
45
+ context "when the required parameters are not specified" do
46
+ let(:argv) do
47
+ "-b #{base_image_path}"
48
+ end
49
+
50
+ it "should raise OptionParser::MissingArgument" do
51
+ expect do
52
+ described_class.parse(argv)
53
+ end.to raise_error(OptionParser::MissingArgument, /output_path/)
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,57 @@
1
+ require "spec_helper"
2
+ require "json"
3
+ require "webmock/rspec"
4
+
5
+ module Photomosaic
6
+ module SearchEngine
7
+ describe Bing do
8
+ let(:api_key) do
9
+ "api_key"
10
+ end
11
+
12
+ let(:search_keyword) do
13
+ "keyword"
14
+ end
15
+
16
+ let(:results) do
17
+ 30
18
+ end
19
+
20
+ let(:client) do
21
+ described_class.new(api_key, results)
22
+ end
23
+
24
+ describe "#get_image_list" do
25
+ before do
26
+ stub_request(
27
+ :get,
28
+ "https://:#{api_key}@api.datamarket.azure.com/Bing/Search/v1/Composite?$format=json&$skip=0&$top=#{results}&Query='#{search_keyword}'&Sources='Image'"
29
+ )
30
+ .to_return(
31
+ status: 200,
32
+ body: JSON.generate(
33
+ d: {
34
+ results: [
35
+ {
36
+ Image: [
37
+ { MediaUrl: "http://example.com/image01.jpg" },
38
+ { MediaUrl: "http://example.com/image02.jpg" }
39
+ ]
40
+ }
41
+ ]
42
+ }
43
+ )
44
+ )
45
+ end
46
+
47
+ it "should return image list" do
48
+ expect(client.get_image_list(search_keyword))
49
+ .to match_array [
50
+ "http://example.com/image01.jpg",
51
+ "http://example.com/image02.jpg"
52
+ ]
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Photomosaic do
4
+ it 'has a version number' do
5
+ expect(Photomosaic::VERSION).not_to be nil
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
5
+ require 'photomosaic'
6
+
7
+ def fixture_path(name)
8
+ File.expand_path(File.join("..", "fixtures", name), __FILE__)
9
+ end
10
+
11
+ def tmp_dir
12
+ File.expand_path("../tmp", File.dirname(__FILE__))
13
+ end
14
+
15
+ def tmp_path(name)
16
+ File.join(tmp_dir, name)
17
+ end
metadata ADDED
@@ -0,0 +1,226 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: photomosaic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Daisuke Fujita
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: searchbing
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rmagick
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: terminal-notifier-guard
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: webmock
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Photomosaic Generator
140
+ email:
141
+ - dtanshi45@gmail.com
142
+ executables:
143
+ - photomosaic
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - ".gitignore"
148
+ - ".rspec"
149
+ - ".travis.yml"
150
+ - Gemfile
151
+ - Guardfile
152
+ - LICENSE.txt
153
+ - README.md
154
+ - Rakefile
155
+ - bin/photomosaic
156
+ - diagrams/sequence.png
157
+ - diagrams/sequence.uml
158
+ - diagrams/structure.png
159
+ - diagrams/structure.uml
160
+ - lib/photomosaic.rb
161
+ - lib/photomosaic/client.rb
162
+ - lib/photomosaic/color/hsv.rb
163
+ - lib/photomosaic/color/rgb.rb
164
+ - lib/photomosaic/image.rb
165
+ - lib/photomosaic/image_downloader.rb
166
+ - lib/photomosaic/options.rb
167
+ - lib/photomosaic/search_engine/bing.rb
168
+ - lib/photomosaic/version.rb
169
+ - photomosaic.gemspec
170
+ - spec/fixtures/lena.png
171
+ - spec/fixtures/lena_0.png
172
+ - spec/fixtures/lena_1.png
173
+ - spec/fixtures/lena_2.png
174
+ - spec/fixtures/lena_3.png
175
+ - spec/fixtures/lena_4.png
176
+ - spec/fixtures/lena_5.png
177
+ - spec/photomosaic/client_spec.rb
178
+ - spec/photomosaic/color/hsv_spec.rb
179
+ - spec/photomosaic/color/rgb_spec.rb
180
+ - spec/photomosaic/image_downloader_spec.rb
181
+ - spec/photomosaic/image_spec.rb
182
+ - spec/photomosaic/options_spec.rb
183
+ - spec/photomosaic/search_engine/bing_spec.rb
184
+ - spec/photomosaic_spec.rb
185
+ - spec/spec_helper.rb
186
+ homepage: https://github.com/dtan4/photomosaic
187
+ licenses:
188
+ - MIT
189
+ metadata: {}
190
+ post_install_message:
191
+ rdoc_options: []
192
+ require_paths:
193
+ - lib
194
+ required_ruby_version: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - ">="
197
+ - !ruby/object:Gem::Version
198
+ version: '0'
199
+ required_rubygems_version: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: '0'
204
+ requirements: []
205
+ rubyforge_project:
206
+ rubygems_version: 2.4.5
207
+ signing_key:
208
+ specification_version: 4
209
+ summary: Photomosaic Generator
210
+ test_files:
211
+ - spec/fixtures/lena.png
212
+ - spec/fixtures/lena_0.png
213
+ - spec/fixtures/lena_1.png
214
+ - spec/fixtures/lena_2.png
215
+ - spec/fixtures/lena_3.png
216
+ - spec/fixtures/lena_4.png
217
+ - spec/fixtures/lena_5.png
218
+ - spec/photomosaic/client_spec.rb
219
+ - spec/photomosaic/color/hsv_spec.rb
220
+ - spec/photomosaic/color/rgb_spec.rb
221
+ - spec/photomosaic/image_downloader_spec.rb
222
+ - spec/photomosaic/image_spec.rb
223
+ - spec/photomosaic/options_spec.rb
224
+ - spec/photomosaic/search_engine/bing_spec.rb
225
+ - spec/photomosaic_spec.rb
226
+ - spec/spec_helper.rb