nokaya 0.0.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: 798577b2a41f1875075fb4ae509ea5f4999df74e
4
+ data.tar.gz: 7ca1302cf20d022a9e22fdc4ea8736ae7c46776e
5
+ SHA512:
6
+ metadata.gz: 9345f2189cb292fe591b68894afe8b706852ed528844ae4f8395d16be6bf21a1c58143602a8c6ffed494a0e2dbcef37b69236f855c0bf3affa4241cdd2d37b5d
7
+ data.tar.gz: 02ddb1849c8e1206eb59fd659c64a84c344f277084429b7a8f8b72bbd8d37414cd27665b1b7ffb4d22f51887b26df8ab41032f45c460701110e78a127cc7fb76
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ .tags
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nokaya.gemspec
4
+ gemspec
@@ -0,0 +1,11 @@
1
+ guard 'rspec' do
2
+ # watch /lib/ files
3
+ watch(%r{^lib/(.+).rb$}) do |m|
4
+ "spec/#{m[1]}_spec.rb"
5
+ end
6
+
7
+ # watch /spec/ files
8
+ watch(%r{^spec/(.+).rb$}) do |m|
9
+ "spec/#{m[1]}.rb"
10
+ end
11
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Eric Dejonckheere
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Nokaya
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'nokaya'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install nokaya
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/nokaya/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
@@ -0,0 +1,10 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'bundler/gem_tasks'
3
+
4
+ # Default directory to look in is `/specs`
5
+ # Run with `rake spec`
6
+ RSpec::Core::RakeTask.new(:spec) do |task|
7
+ task.rspec_opts = ['--color', '--format', 'nested']
8
+ end
9
+
10
+ task :default => :spec
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ # Nokaya
4
+ # Author: Eric Dejonckheere (http://app.net/ericd)
5
+
6
+ $PROGRAM_NAME = 'nokaya'
7
+ require_relative '../lib/nokaya'
8
+
9
+ Nokaya::App.start ARGV
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+ require 'ostruct'
3
+ require 'thor'
4
+ require 'terminal-table/import'
5
+ require 'open-uri'
6
+ require 'nokogiri'
7
+ require_relative 'nokaya/version'
8
+ require_relative 'nokaya/app'
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+ module Nokaya
3
+ class App < Thor
4
+ package_name "Nokaya"
5
+ require_relative 'getter'
6
+
7
+ desc "instagram", "Get the main photo from an Instagram page (nokaya -i url)"
8
+ map "-i" => :instagram
9
+ option :name, aliases: "-n", type: :string, desc: "Specify a file name without extension (nokaya -i url -n some_name)"
10
+ def instagram *args
11
+ nokaya = Getter.new options, :instagram, args
12
+ page = nokaya.parse_page
13
+ img_link = nokaya.get_link page
14
+ path = nokaya.photo_name
15
+ puts "Downloading #{img_link}, please wait...\n"
16
+ nokaya.save_image path, img_link
17
+ puts "\nImage saved in #{path}\n\n"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+ module Nokaya
3
+ class Getter
4
+ def initialize *args
5
+ @args = OpenStruct.new options: args[0], type: args[1], url: args[2][0]
6
+ end
7
+ def args
8
+ @args.inspect
9
+ end
10
+ def options
11
+ @args.options
12
+ end
13
+ def type
14
+ @args.type
15
+ end
16
+ def url
17
+ @args.url
18
+ end
19
+ def get_image img_link
20
+ open(img_link).read
21
+ end
22
+ def get_link page
23
+ page.xpath("//meta[@property='og:image']/@content").first
24
+ end
25
+ def photo_name
26
+ unless @args.options[:name]
27
+ Dir.home + "/Downloads/#{@args.type.to_s}-#{Time.now.to_i}.jpg"
28
+ else
29
+ Dir.home + "/Downloads/#{@args.type.to_s}-#{@args.options[:name]}.jpg"
30
+ end
31
+ end
32
+ def parse_page
33
+ Nokogiri::HTML get_page_content
34
+ end
35
+ def save_image path, img_link
36
+ f = File.new(path, "wb")
37
+ f.puts(get_image img_link)
38
+ f.close
39
+ end
40
+ private
41
+ def get_page_content
42
+ open @args.url
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,3 @@
1
+ module Nokaya
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'nokaya/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nokaya"
8
+ spec.version = Nokaya::VERSION
9
+ spec.authors = ["Eric Dejonckheere"]
10
+ spec.email = ["eric@aya.io"]
11
+ spec.summary = %q{Download photos from several online services.}
12
+ spec.description = %q{CLI to download photos from several online services including Instagram. Mac OS X only for the time being.}
13
+ spec.homepage = "http://github.com/ericdke/nokaya"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "thor", "~> 0.18"
22
+ spec.add_dependency "rest-client", "~> 1.6"
23
+ spec.add_dependency "terminal-table", "~> 1.4"
24
+ spec.add_dependency "nokogiri"
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.6"
27
+ spec.add_development_dependency "rake"
28
+ spec.add_development_dependency "rspec"
29
+ spec.add_development_dependency "rspec-nc"
30
+ spec.add_development_dependency "guard"
31
+ spec.add_development_dependency "guard-rspec"
32
+ spec.add_development_dependency "pry"
33
+ spec.add_development_dependency "pry-remote"
34
+ spec.add_development_dependency "pry-nav"
35
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Nokaya::Getter do
4
+ describe "#args" do
5
+ it 'shows the args' do
6
+ obj = Nokaya::Getter.new({}, :instagram, ['http://instagram.com/p/nlUKF9TYEs/'])
7
+ expect(obj.args).to eq '#<OpenStruct options={}, type=:instagram, url="http://instagram.com/p/nlUKF9TYEs/">'
8
+ end
9
+ end
10
+ # describe "#get_page" do
11
+ # it 'gets the page' do
12
+ # obj = Nokaya::Getter.new({}, :instagram, ['http://instagram.com/p/nlUKF9TYEs/'])
13
+ # expect(obj.get_page).to eq ''
14
+ # end
15
+ # end
16
+ end
@@ -0,0 +1,2 @@
1
+ require 'pry'
2
+ require 'Nokaya'
metadata ADDED
@@ -0,0 +1,245 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nokaya
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Eric Dejonckheere
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.18'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.18'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: terminal-table
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.4'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
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: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.6'
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: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-nc
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: guard
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
+ - !ruby/object:Gem::Dependency
140
+ name: guard-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: pry
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: pry-remote
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: pry-nav
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ description: CLI to download photos from several online services including Instagram.
196
+ Mac OS X only for the time being.
197
+ email:
198
+ - eric@aya.io
199
+ executables:
200
+ - nokaya
201
+ extensions: []
202
+ extra_rdoc_files: []
203
+ files:
204
+ - ".gitignore"
205
+ - Gemfile
206
+ - Guardfile
207
+ - LICENSE.txt
208
+ - README.md
209
+ - Rakefile
210
+ - bin/nokaya
211
+ - lib/nokaya.rb
212
+ - lib/nokaya/app.rb
213
+ - lib/nokaya/getter.rb
214
+ - lib/nokaya/version.rb
215
+ - nokaya.gemspec
216
+ - spec/nokaya_spec.rb
217
+ - spec/spec_helper.rb
218
+ homepage: http://github.com/ericdke/nokaya
219
+ licenses:
220
+ - MIT
221
+ metadata: {}
222
+ post_install_message:
223
+ rdoc_options: []
224
+ require_paths:
225
+ - lib
226
+ required_ruby_version: !ruby/object:Gem::Requirement
227
+ requirements:
228
+ - - ">="
229
+ - !ruby/object:Gem::Version
230
+ version: '0'
231
+ required_rubygems_version: !ruby/object:Gem::Requirement
232
+ requirements:
233
+ - - ">="
234
+ - !ruby/object:Gem::Version
235
+ version: '0'
236
+ requirements: []
237
+ rubyforge_project:
238
+ rubygems_version: 2.2.2
239
+ signing_key:
240
+ specification_version: 4
241
+ summary: Download photos from several online services.
242
+ test_files:
243
+ - spec/nokaya_spec.rb
244
+ - spec/spec_helper.rb
245
+ has_rdoc: