fletcher 0.5.2 → 0.6.0
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.
- data/Gemfile +1 -0
- data/Gemfile.lock +4 -0
- data/README.md +36 -0
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/bin/fletcher +69 -0
- data/config/locales/fletcher.en.yml +27 -0
- data/fletcher.gemspec +9 -2
- data/spec/bin/fletcher_spec.rb +41 -0
- metadata +24 -4
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -4,12 +4,15 @@ GEM
|
|
4
4
|
activesupport (3.2.2)
|
5
5
|
i18n (~> 0.6)
|
6
6
|
multi_json (~> 1.0)
|
7
|
+
commander (4.1.2)
|
8
|
+
highline (~> 1.6.11)
|
7
9
|
diff-lcs (1.1.3)
|
8
10
|
factory_girl (2.6.4)
|
9
11
|
activesupport (>= 2.3.9)
|
10
12
|
fakeweb (1.3.0)
|
11
13
|
git (1.2.5)
|
12
14
|
hashie (1.2.0)
|
15
|
+
highline (1.6.15)
|
13
16
|
i18n (0.6.0)
|
14
17
|
jeweler (1.6.4)
|
15
18
|
bundler (~> 1.0)
|
@@ -39,6 +42,7 @@ PLATFORMS
|
|
39
42
|
|
40
43
|
DEPENDENCIES
|
41
44
|
bundler
|
45
|
+
commander
|
42
46
|
factory_girl
|
43
47
|
fakeweb
|
44
48
|
hashie
|
data/README.md
CHANGED
@@ -55,6 +55,42 @@ product.doc.class.name # => Nokogiri::HTML::Document
|
|
55
55
|
Fletcher.models # => [:amazon, :ebay, :etsy, :thinkgeek, ...]
|
56
56
|
```
|
57
57
|
|
58
|
+
### CLI
|
59
|
+
|
60
|
+
Get Product Details (defaults to yaml output):
|
61
|
+
|
62
|
+
```sh
|
63
|
+
$ fletcher fetch "http://www.amazon.com/Avenir-Deluxe-Unicycle-20-Inch-Wheel/dp/B00165Q9F8"
|
64
|
+
|
65
|
+
---
|
66
|
+
name: Avenir Deluxe Unicycle (20-Inch Wheel)
|
67
|
+
description: 'Amazon.com: Avenir Deluxe Unicycle (20-Inch Wheel): Sports & Outdoors'
|
68
|
+
price: $99.99
|
69
|
+
image:
|
70
|
+
src: http://ecx.images-amazon.com/images/I/41b3TNb3uCL._SL500_AA280_.jpg
|
71
|
+
url: http://www.amazon.com/Avenir-Deluxe-Unicycle-20-Inch-Wheel/dp/B00165Q9F8
|
72
|
+
```
|
73
|
+
|
74
|
+
Get a single attribute of a product:
|
75
|
+
|
76
|
+
```sh
|
77
|
+
$ fletcher fetch --only name "http://www.amazon.com/Avenir-Deluxe-Unicycle-20-Inch-Wheel/dp/B00165Q9F8"
|
78
|
+
Avenir Deluxe Unicycle (20-Inch Wheel)
|
79
|
+
```
|
80
|
+
|
81
|
+
Get list of supported websites:
|
82
|
+
|
83
|
+
```sh
|
84
|
+
$ fletcher websites
|
85
|
+
Amazon
|
86
|
+
ThinkGeek
|
87
|
+
...
|
88
|
+
```
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
58
94
|
## Attributes
|
59
95
|
|
60
96
|
The following attributes/method are available for a product:
|
data/Rakefile
CHANGED
@@ -21,6 +21,7 @@ Jeweler::Tasks.new do |gem|
|
|
21
21
|
gem.description = %Q{Easily fetch product/model information from third party websites such as Amazon, eBay, etc.}
|
22
22
|
gem.email = "dave@hulihanapplications.com"
|
23
23
|
gem.authors = ["Dave Hulihan", "Hulihan Applications"]
|
24
|
+
gem.executables = ["fletcher"]
|
24
25
|
# dependencies defined in Gemfile
|
25
26
|
end
|
26
27
|
Jeweler::RubygemsDotOrgTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/bin/fletcher
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'commander/import'
|
5
|
+
require 'yaml'
|
6
|
+
require File.expand_path("../../lib/fletcher", __FILE__)
|
7
|
+
#require 'commander-foo'
|
8
|
+
|
9
|
+
program :version, Fletcher.version #Commander-foo::VERSION
|
10
|
+
program :description, 'A cross-website product information fetcher'
|
11
|
+
program :help, 'Author', 'Dave Hulihan <dhulihan@gmail.com>'
|
12
|
+
#default_command :fetch
|
13
|
+
|
14
|
+
command :fetch do |c|
|
15
|
+
c.syntax = 'fletcher fetch [URL]'
|
16
|
+
c.summary = 'Fetch product information'
|
17
|
+
c.description = ''
|
18
|
+
c.example 'Fetch an amazon product', 'fletcher "http://www.example.com/product-id"'
|
19
|
+
#c.option '--format [yaml|json]', String, 'The format of the product details'
|
20
|
+
#c.option '--timeout SECONDS', Integer, 'Timeout in seconds'
|
21
|
+
c.option '--only [name|description|price|image]', String, 'Fetch a single attribute from the product.'
|
22
|
+
c.action do |args, options|
|
23
|
+
# Do something or c.when_called Commander-foo::Commands::Hello
|
24
|
+
options.default :format => :yaml
|
25
|
+
|
26
|
+
url = args.first
|
27
|
+
if url
|
28
|
+
product = Fletcher.fetch url
|
29
|
+
|
30
|
+
# Prep output
|
31
|
+
output_hash = Hash.new
|
32
|
+
output_hash["name"] = product.name
|
33
|
+
output_hash["description"] = product.description if product.description
|
34
|
+
output_hash["price"] = product.price.format if product.price
|
35
|
+
if product.image
|
36
|
+
output_hash["image"] = {
|
37
|
+
"src" => product.image.src
|
38
|
+
}
|
39
|
+
end
|
40
|
+
output_hash["url"] = product.url
|
41
|
+
|
42
|
+
# Get single attribute
|
43
|
+
if options.only
|
44
|
+
case options.only
|
45
|
+
when "image"
|
46
|
+
value = output_hash["image"]["src"]
|
47
|
+
else
|
48
|
+
value = output_hash[options.only]
|
49
|
+
end
|
50
|
+
value ? say(value.to_s) : say("Unknown attribute: #{options.only}")
|
51
|
+
else
|
52
|
+
say output_hash.to_yaml
|
53
|
+
end
|
54
|
+
else
|
55
|
+
puts c.syntax
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
command :websites do |c|
|
61
|
+
c.syntax = 'fletcher websites'
|
62
|
+
c.summary = 'Get a list of supported websites'
|
63
|
+
c.action do |args, options|
|
64
|
+
say "Supported Websites:"
|
65
|
+
for model in Fletcher.models.sort
|
66
|
+
say "\t#{model.to_s.capitalize}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
en:
|
2
|
+
fletcher:
|
3
|
+
models:
|
4
|
+
amazon:
|
5
|
+
name: Amazon
|
6
|
+
url: http://www.amazon.com
|
7
|
+
ebay:
|
8
|
+
name: eBay
|
9
|
+
url: http://www.ebay.com
|
10
|
+
etsy:
|
11
|
+
name: Etsy
|
12
|
+
url: http://www.etsy.com
|
13
|
+
gamecouk:
|
14
|
+
name: Game.co.uk
|
15
|
+
url: http://www.game.co.uk
|
16
|
+
googleshopping:
|
17
|
+
name: Google Shopping
|
18
|
+
url: http://www.google.com/shopping
|
19
|
+
playcom:
|
20
|
+
name: Play.com
|
21
|
+
url: http://www.play.com
|
22
|
+
steam:
|
23
|
+
name: Steam
|
24
|
+
url: http://store.steampowered.com
|
25
|
+
thinkgeek:
|
26
|
+
name: ThinkGeek
|
27
|
+
url: http://www.thinkgeek.com
|
data/fletcher.gemspec
CHANGED
@@ -5,13 +5,14 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "fletcher"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.6.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Dave Hulihan", "Hulihan Applications"]
|
12
|
-
s.date = "2012-10-
|
12
|
+
s.date = "2012-10-26"
|
13
13
|
s.description = "Easily fetch product/model information from third party websites such as Amazon, eBay, etc."
|
14
14
|
s.email = "dave@hulihanapplications.com"
|
15
|
+
s.executables = ["fletcher"]
|
15
16
|
s.extra_rdoc_files = [
|
16
17
|
"LICENSE.txt",
|
17
18
|
"README.md"
|
@@ -25,6 +26,8 @@ Gem::Specification.new do |s|
|
|
25
26
|
"README.md",
|
26
27
|
"Rakefile",
|
27
28
|
"VERSION",
|
29
|
+
"bin/fletcher",
|
30
|
+
"config/locales/fletcher.en.yml",
|
28
31
|
"fletcher.gemspec",
|
29
32
|
"lib/fletcher.rb",
|
30
33
|
"lib/fletcher/data.rb",
|
@@ -39,6 +42,7 @@ Gem::Specification.new do |s|
|
|
39
42
|
"lib/fletcher/models/thinkgeek.rb",
|
40
43
|
"lib/fletcher/nokogiri.rb",
|
41
44
|
"lib/fletcher/string.rb",
|
45
|
+
"spec/bin/fletcher_spec.rb",
|
42
46
|
"spec/factories/models.rb",
|
43
47
|
"spec/lib/fletcher/data_spec.rb",
|
44
48
|
"spec/lib/fletcher/models/amazon_spec.rb",
|
@@ -73,6 +77,7 @@ Gem::Specification.new do |s|
|
|
73
77
|
s.add_runtime_dependency(%q<hashie>, [">= 0"])
|
74
78
|
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
75
79
|
s.add_runtime_dependency(%q<money>, [">= 0"])
|
80
|
+
s.add_runtime_dependency(%q<commander>, [">= 0"])
|
76
81
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
77
82
|
s.add_development_dependency(%q<bundler>, [">= 0"])
|
78
83
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
@@ -86,6 +91,7 @@ Gem::Specification.new do |s|
|
|
86
91
|
s.add_dependency(%q<hashie>, [">= 0"])
|
87
92
|
s.add_dependency(%q<nokogiri>, [">= 0"])
|
88
93
|
s.add_dependency(%q<money>, [">= 0"])
|
94
|
+
s.add_dependency(%q<commander>, [">= 0"])
|
89
95
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
90
96
|
s.add_dependency(%q<bundler>, [">= 0"])
|
91
97
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
@@ -100,6 +106,7 @@ Gem::Specification.new do |s|
|
|
100
106
|
s.add_dependency(%q<hashie>, [">= 0"])
|
101
107
|
s.add_dependency(%q<nokogiri>, [">= 0"])
|
102
108
|
s.add_dependency(%q<money>, [">= 0"])
|
109
|
+
s.add_dependency(%q<commander>, [">= 0"])
|
103
110
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
104
111
|
s.add_dependency(%q<bundler>, [">= 0"])
|
105
112
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
#load File.expand_path("../../../bin/fletcher", __FILE__)
|
3
|
+
|
4
|
+
# def mock_terminal
|
5
|
+
# @input = StringIO.new
|
6
|
+
# @output = StringIO.new
|
7
|
+
# $terminal = HighLine.new @input, @output
|
8
|
+
# end
|
9
|
+
|
10
|
+
# describe "Fletcher CLI" do
|
11
|
+
# before :each do
|
12
|
+
# mock_terminal
|
13
|
+
# end
|
14
|
+
|
15
|
+
# describe "fetch command", :vcr do
|
16
|
+
# before :each do
|
17
|
+
# @command = command :fetch
|
18
|
+
# end
|
19
|
+
|
20
|
+
# it "should return prompt without url" do
|
21
|
+
# @command.run Factory(:amazon).url
|
22
|
+
# # @output.to_s.should == @command.syntax
|
23
|
+
# end
|
24
|
+
|
25
|
+
# it "works with valid product url" do
|
26
|
+
# lambda{
|
27
|
+
# @command.run Factory(:amazon).url
|
28
|
+
# }.should_not raise_error
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
|
32
|
+
# describe "websites command" do
|
33
|
+
# before :each do
|
34
|
+
# @command = command :websites
|
35
|
+
# end
|
36
|
+
|
37
|
+
# it "should work without any errors" do
|
38
|
+
# lambda{@command.run}.should_not raise_error
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
# end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fletcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-10-
|
13
|
+
date: 2012-10-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hashie
|
@@ -60,6 +60,22 @@ dependencies:
|
|
60
60
|
- - ! '>='
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: commander
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
63
79
|
- !ruby/object:Gem::Dependency
|
64
80
|
name: shoulda
|
65
81
|
requirement: !ruby/object:Gem::Requirement
|
@@ -207,7 +223,8 @@ dependencies:
|
|
207
223
|
description: Easily fetch product/model information from third party websites such
|
208
224
|
as Amazon, eBay, etc.
|
209
225
|
email: dave@hulihanapplications.com
|
210
|
-
executables:
|
226
|
+
executables:
|
227
|
+
- fletcher
|
211
228
|
extensions: []
|
212
229
|
extra_rdoc_files:
|
213
230
|
- LICENSE.txt
|
@@ -221,6 +238,8 @@ files:
|
|
221
238
|
- README.md
|
222
239
|
- Rakefile
|
223
240
|
- VERSION
|
241
|
+
- bin/fletcher
|
242
|
+
- config/locales/fletcher.en.yml
|
224
243
|
- fletcher.gemspec
|
225
244
|
- lib/fletcher.rb
|
226
245
|
- lib/fletcher/data.rb
|
@@ -235,6 +254,7 @@ files:
|
|
235
254
|
- lib/fletcher/models/thinkgeek.rb
|
236
255
|
- lib/fletcher/nokogiri.rb
|
237
256
|
- lib/fletcher/string.rb
|
257
|
+
- spec/bin/fletcher_spec.rb
|
238
258
|
- spec/factories/models.rb
|
239
259
|
- spec/lib/fletcher/data_spec.rb
|
240
260
|
- spec/lib/fletcher/models/amazon_spec.rb
|
@@ -270,7 +290,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
270
290
|
version: '0'
|
271
291
|
segments:
|
272
292
|
- 0
|
273
|
-
hash:
|
293
|
+
hash: 900298913943302851
|
274
294
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
275
295
|
none: false
|
276
296
|
requirements:
|