FlickrCollage 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c468c389c4aba1c9ca34ab6d88bbc16080847a12
4
+ data.tar.gz: 6710825d6fc0b96809a4f8cce7f4340e0f810a0b
5
+ SHA512:
6
+ metadata.gz: 14892552bd37b5bbab8e2e4e6b2adf9e8a359de7a4aef76083265df907cda11eefd16103138567f5144955fd102b5bbe53fbf41b4046a6930fc8f56767aca6e9
7
+ data.tar.gz: 255fe3b92e497c6850fe09317d45fe2bfcd70478698fc7a448b752f74e4b3077dd23b4a4c37deaf0a858f038c0ab157b5e6a6dc9b83ba714bf0dc6f40ab8a0ff
@@ -0,0 +1,5 @@
1
+ .DS_Store
2
+ .yardoc
3
+ results.html
4
+ pkg
5
+ html
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "FlickrCollage/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "FlickrCollage"
8
+ spec.license = "MIT"
9
+ spec.version = FlickrCollage::VERSION
10
+ spec.authors = ["Chromium"]
11
+ spec.email = ["crcs2o4@gmail.com"]
12
+
13
+ spec.summary = "Create collage from 10 top-rated Flickr images for your keywords"
14
+ spec.description = "This gem creates collage from 10 top-rated Flickr images for your keywords.
15
+ It's a part of coding challenge and it's fun."
16
+ spec.homepage = "https://github.com/CrCs2O4/FlickrCollage.git"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.13"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rdoc", "~> 4.2.2", ">= 4.2.2"
28
+ spec.add_development_dependency "aruba", "~> 0.14.2"
29
+ spec.add_dependency "methadone", "~> 1.9.2", ">= 1.9.2"
30
+ spec.add_development_dependency "test-unit", "~> 3.2.1", ">= 3.2.1"
31
+ spec.add_dependency "flickraw", "~> 0.9.9"
32
+ spec.add_dependency "mini_magick", "~> 4.5.1", ">= 4.5.1"
33
+ end
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in FlickrCollage.gemspec
4
+ gemspec
@@ -0,0 +1,68 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ FlickrCollage (0.1.0)
5
+ flickraw
6
+ methadone (~> 1.9.2)
7
+ mini_magick
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ aruba (0.14.2)
13
+ childprocess (~> 0.5.6)
14
+ contracts (~> 0.9)
15
+ cucumber (>= 1.3.19)
16
+ ffi (~> 1.9.10)
17
+ rspec-expectations (>= 2.99)
18
+ thor (~> 0.19)
19
+ builder (3.2.2)
20
+ childprocess (0.5.9)
21
+ ffi (~> 1.0, >= 1.0.11)
22
+ contracts (0.14.0)
23
+ cucumber (2.4.0)
24
+ builder (>= 2.1.2)
25
+ cucumber-core (~> 1.5.0)
26
+ cucumber-wire (~> 0.0.1)
27
+ diff-lcs (>= 1.1.3)
28
+ gherkin (~> 4.0)
29
+ multi_json (>= 1.7.5, < 2.0)
30
+ multi_test (>= 0.1.2)
31
+ cucumber-core (1.5.0)
32
+ gherkin (~> 4.0)
33
+ cucumber-wire (0.0.1)
34
+ diff-lcs (1.2.5)
35
+ ffi (1.9.14)
36
+ flickraw (0.9.9)
37
+ gherkin (4.0.0)
38
+ json (1.8.3)
39
+ methadone (1.9.2)
40
+ bundler
41
+ mini_magick (4.5.1)
42
+ multi_json (1.12.1)
43
+ multi_test (0.1.2)
44
+ power_assert (0.3.1)
45
+ rake (10.5.0)
46
+ rdoc (4.2.2)
47
+ json (~> 1.4)
48
+ rspec-expectations (3.5.0)
49
+ diff-lcs (>= 1.2.0, < 2.0)
50
+ rspec-support (~> 3.5.0)
51
+ rspec-support (3.5.0)
52
+ test-unit (3.2.1)
53
+ power_assert
54
+ thor (0.19.1)
55
+
56
+ PLATFORMS
57
+ ruby
58
+
59
+ DEPENDENCIES
60
+ FlickrCollage!
61
+ aruba
62
+ bundler (~> 1.13)
63
+ rake (~> 10.0)
64
+ rdoc
65
+ test-unit
66
+
67
+ BUNDLED WITH
68
+ 1.13.2
@@ -0,0 +1,8 @@
1
+ Name: FlickrCollage
2
+ Copyright (c) 2016 Chromium
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,102 @@
1
+ # FlickrCollage
2
+
3
+ This gem creates collage from 10 top-rated Flickr images for your keywords.
4
+ It's a part of coding challenge and it's fun.
5
+
6
+ ![](doc/flickrCollage.jpg)
7
+
8
+ ## Installation
9
+
10
+ There are two ways of installing gem:
11
+
12
+ - Just for collage creating
13
+
14
+ ```bash
15
+ $ gem install https://github.com/CrCs2O4/FlickrCollage.git
16
+
17
+ # see help
18
+ $ flickrCollage -h
19
+
20
+ ```
21
+
22
+ - Clone and install dependencies
23
+
24
+ ```bash
25
+ $ git clone https://github.com/CrCs2O4/FlickrCollage.git
26
+ $ cd FlickrCollage
27
+ $ bundle exec bin/setup
28
+
29
+ # build and install gem
30
+ $ gem build ./FlickrCollage.gemspec
31
+ $ gem install ./FlickrCollage-0.1.0.gem
32
+
33
+ # see help
34
+ $ bundle exec bin/FlickrCollage -h
35
+
36
+ # run tests
37
+ $ bundle exec rake
38
+
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ ```bash
44
+ $ flickrCollage city cityscape skyline architecture building skyscraper dawn twilight business finance
45
+
46
+ # use some random keywords from dictionary
47
+ $ flickrCollage city cityscape skyline
48
+
49
+ # set collage filename
50
+ $ flickrCollage city cityscape skyline -f my_awesome_collage
51
+
52
+ # set working path
53
+ $ flickrCollage city cityscape skyline -p ~/Pictures/
54
+
55
+ # view debug info
56
+ $ flickrCollage city cityscape skyline --log-level=debug
57
+
58
+ $ flickrCollage -h
59
+
60
+ Usage: FlickrCollage [options] [keywords]
61
+
62
+ Create collage from 10 top-rated Flickr images for your keywords
63
+
64
+ v0.1.0
65
+
66
+ Options:
67
+ -h, --help Show command line help
68
+ --api_key api_key Flickr api-key
69
+ --shared_secret shared_secretFlickr shared-secret
70
+ -w, --width width Set image width for crop
71
+ -e, --height height Set image height for crop
72
+ -p, --path path Path for collage
73
+ -f, --file file Filename for collage
74
+ -s, --save Don't delete downloaded images
75
+ --version Show help/version info
76
+ --log-level LEVEL Set the logging level
77
+ (debug|info|warn|error|fatal)
78
+ (Default: info)
79
+
80
+ Arguments:
81
+
82
+ keywords
83
+ Your keywords for Flickr images (optional)
84
+
85
+ ```
86
+
87
+ ## Development
88
+
89
+ After checking out the repo, run `bundle exec bin/setup` to install dependencies. You can also run `bundle exec bin/console` for an interactive prompt that will allow you to experiment.
90
+
91
+ To run app just type `bundle exec bin/FlickrCollage`
92
+
93
+ To run test `bundle exec rake`
94
+
95
+ To view docs `yard doc`
96
+
97
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
98
+
99
+ ## Contributing
100
+
101
+ Bug reports and pull requests are welcome on GitHub at https://github.com/CrCs2O4/FlickrCollage
102
+
@@ -0,0 +1,56 @@
1
+ def dump_load_path
2
+ puts $LOAD_PATH.join("\n")
3
+ found = nil
4
+ $LOAD_PATH.each do |path|
5
+ next unless File.exist?(File.join(path, "rspec"))
6
+ puts "Found rspec in #{path}"
7
+ if File.exist?(File.join(path, "rspec", "core"))
8
+ puts "Found core"
9
+ if File.exist?(File.join(path, "rspec", "core", "rake_task"))
10
+ puts "Found rake_task"
11
+ found = path
12
+ else
13
+ puts "!! no rake_task"
14
+ end
15
+ else
16
+ puts "!!! no core"
17
+ end
18
+ end
19
+ if found.nil?
20
+ puts "Didn't find rspec/core/rake_task anywhere"
21
+ else
22
+ puts "Found in #{path}"
23
+ end
24
+ end
25
+ require "bundler"
26
+ require "rake/clean"
27
+
28
+ require "rake/testtask"
29
+
30
+ require "cucumber"
31
+ require "cucumber/rake/task"
32
+ gem "rdoc" # we need the installed RDoc gem, not the system one
33
+ require "rdoc/task"
34
+
35
+ include Rake::DSL
36
+
37
+ Bundler::GemHelper.install_tasks
38
+
39
+ Rake::TestTask.new do |t|
40
+ t.pattern = "test/tc_*.rb"
41
+ end
42
+
43
+ CUKE_RESULTS = "results.html".freeze
44
+ CLEAN << CUKE_RESULTS
45
+ Cucumber::Rake::Task.new(:features) do |t|
46
+ t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x "
47
+ t.fork = false
48
+ end
49
+
50
+ Rake::RDocTask.new do |rd|
51
+ rd.main = "README.rdoc"
52
+
53
+ rd.rdoc_files.include("README.rdoc", "lib/**/*.rb", "bin/**/*")
54
+ end
55
+
56
+ task default: [:test, :features]
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "optparse"
4
+ require "methadone"
5
+ require "FlickrCollage.rb"
6
+
7
+ class App
8
+ include Methadone::Main
9
+ include Methadone::CLILogging
10
+ include FlickrCollage
11
+
12
+ main do |*args|
13
+ dict = Dictionary.new
14
+ flickr = Flickr.new(api_key: options[:api_key],
15
+ shared_secret: options[:shared_secret],
16
+ img_path: options[:path])
17
+ img_width = options.key?("width") ? options[:width].to_i : nil
18
+ img_height = options.key?("height") ? options[:height].to_i : nil
19
+ image = Image.new(img_path: options[:path],
20
+ collage_file: options[:file],
21
+ img_width: img_width,
22
+ img_height: img_height,
23
+ clear_tmp: !options[:save])
24
+ photos = []
25
+ step = 0
26
+
27
+ while photos.size < FlickrCollage::IMG_COUNT
28
+ keyword = step < args.size ? args[step] : dict.get_word
29
+
30
+ photo = flickr.scrape(keyword: keyword)
31
+ if Image.valid?(photo)
32
+ info "Keyword: #{step + 1} #{keyword}: #{photo}"
33
+ photos << photo
34
+ else
35
+ info "Keyword: #{step + 1} #{keyword}: no images found"
36
+ end
37
+ step += 1
38
+ end
39
+
40
+ info "Create collage #{image.collage_file}.jpg" if image.collage(files: photos)
41
+ info "Finished: #{FlickrCollage::IMG_COUNT} images in #{step} steps"
42
+ end
43
+
44
+ description "Create collage from 10 top-rated Flickr images for your keywords"
45
+
46
+ on("--api_key api_key", "Flickr api-key")
47
+ on("--shared_secret shared_secret", "Flickr shared-secret")
48
+ on("-w width", "--width width", "Set image width for crop")
49
+ on("-e height", "--height height", "Set image height for crop")
50
+ on("-p path", "--path path", "Path for collage")
51
+ on("-f file", "--file file", "Filename for collage")
52
+ on("-s", "--save", "Don't delete downloaded images")
53
+
54
+ arg :keywords, :optional, "Your keywords for Flickr images"
55
+
56
+ version FlickrCollage::VERSION
57
+
58
+ use_log_level_option toggle_debug_on_signal: "USR1"
59
+
60
+ go!
61
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "FlickrCollage"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,187 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: FlickrCollage
8
+
9
+ &mdash; Documentation by YARD 0.9.5
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "FlickrCollage";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index (F)</a> &raquo;
40
+
41
+
42
+ <span class="title">FlickrCollage</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <iframe id="search_frame" src="class_list.html"></iframe>
63
+
64
+ <div id="content"><h1>Module: FlickrCollage
65
+
66
+
67
+
68
+ </h1>
69
+ <div class="box_info">
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ <dl>
82
+ <dt>Defined in:</dt>
83
+ <dd>lib/FlickrCollage.rb<span class="defines">,<br />
84
+ lib/FlickrCollage/version.rb</span>
85
+ </dd>
86
+ </dl>
87
+
88
+ </div>
89
+
90
+ <h2>Overview</h2><div class="docstring">
91
+ <div class="discussion">
92
+
93
+ <p>Creating collage from top-rated Flickr images for your keywords</p>
94
+
95
+
96
+ </div>
97
+ </div>
98
+ <div class="tags">
99
+
100
+ <p class="tag_title">Author:</p>
101
+ <ul class="author">
102
+
103
+ <li>
104
+
105
+
106
+
107
+
108
+
109
+ <div class='inline'>
110
+ <p>Chromium</p>
111
+ </div>
112
+
113
+ </li>
114
+
115
+ </ul>
116
+
117
+ </div><h2>Defined Under Namespace</h2>
118
+ <p class="children">
119
+
120
+
121
+
122
+
123
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="FlickrCollage/Dictionary.html" title="FlickrCollage::Dictionary (class)">Dictionary</a></span>, <span class='object_link'><a href="FlickrCollage/Flickr.html" title="FlickrCollage::Flickr (class)">Flickr</a></span>, <span class='object_link'><a href="FlickrCollage/Image.html" title="FlickrCollage::Image (class)">Image</a></span>
124
+
125
+
126
+ </p>
127
+
128
+ <h2>Constant Summary</h2>
129
+ <dl class="constants">
130
+
131
+ <dt id="IMG_COUNT-constant" class="">IMG_COUNT =
132
+ <div class="docstring">
133
+ <div class="discussion">
134
+
135
+ <p>Class for Dictionary. Provides random words</p>
136
+
137
+
138
+ </div>
139
+ </div>
140
+ <div class="tags">
141
+
142
+
143
+ </div>
144
+ </dt>
145
+ <dd><pre class="code"><span class='int'>10</span></pre></dd>
146
+
147
+ <dt id="IMG_PATH-constant" class="">IMG_PATH =
148
+
149
+ </dt>
150
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>./</span><span class='tstring_end'>&quot;</span></span></pre></dd>
151
+
152
+ <dt id="COLLAGE_FILE-constant" class="">COLLAGE_FILE =
153
+
154
+ </dt>
155
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>flickrCollage</span><span class='tstring_end'>&quot;</span></span></pre></dd>
156
+
157
+ <dt id="RAISE_ERROR-constant" class="">RAISE_ERROR =
158
+
159
+ </dt>
160
+ <dd><pre class="code"><span class='kw'>true</span></pre></dd>
161
+
162
+ <dt id="VERSION-constant" class="">VERSION =
163
+
164
+ </dt>
165
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0.1.0</span><span class='tstring_end'>&quot;</span></span></pre></dd>
166
+
167
+ </dl>
168
+
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+ </div>
178
+
179
+ <div id="footer">
180
+ Generated on Mon Oct 24 09:56:49 2016 by
181
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
182
+ 0.9.5 (ruby-2.3.1).
183
+ </div>
184
+
185
+ </div>
186
+ </body>
187
+ </html>