goodwill 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.rubocop.yml +11 -0
- data/.travis.yml +3 -0
- data/README.md +18 -4
- data/Rakefile +5 -3
- data/bin/console +3 -3
- data/goodwill.gemspec +1 -0
- data/lib/goodwill/account.rb +5 -2
- data/lib/goodwill/auction.rb +16 -7
- data/lib/goodwill/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTdiMmFhNjFlNjYzZWQzOTI1ZmY4YTM0Zjc2ZmQyNTUyZGFiYTUyMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWZlOTA3NDljN2ZmM2I3Y2Q2NzJiZWRhNzBjYjUyZmVlZGQ1MGJhNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGMwNzc0Y2U4NWUxNGZhMjcxZDkyNjc2OTdlNWRhZjdiNDVmNTU2YjIxMDg5
|
10
|
+
OGJiYzA4M2UxODNkODQ0YzFmN2RhMTVmZWMwOTg2MmMwY2Q3MDIxYjA0ZWRk
|
11
|
+
MzE5YzVlYWZiZDZhOTQ4MmZiNjE2YjdjYTViMjE4NTJjMDVjN2U=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MGUxNmVmMTFmY2M5NjhjOGM1NTI5MWZkNmIxZjI2YWY1YzdhMTFkMGEwMmFk
|
14
|
+
MWU2ZmFkOTkyMDMwNTUzZTNhMWNjMGVjZTU2YTA0MjAwNGVlMWZmODQzOTY3
|
15
|
+
YzBmNmY2ZGUzNDViMWQxNjMxNGNlNzA4YTVkNDQ0Njk3ODZiNWQ=
|
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
[![Inline docs](http://inch-ci.org/github/dudemcbacon/goodwill.svg?branch=master)](http://inch-ci.org/github/dudemcbacon/goodwill)
|
5
5
|
# Goodwill
|
6
6
|
|
7
|
-
|
7
|
+
Goodwill is a simple web scraper for ShopGoodwill.com. You can query login to your account, view your currently in progress auction, search for items, and even bid on new options. It also includes a small CLI for interacting with ShopGoodwill.com from the command-line.
|
8
8
|
|
9
9
|
TODO: Delete this and the text above, and describe your gem
|
10
10
|
|
@@ -26,7 +26,22 @@ Or install it yourself as:
|
|
26
26
|
|
27
27
|
## Usage
|
28
28
|
|
29
|
-
|
29
|
+
```ruby
|
30
|
+
gem 'goodwill'
|
31
|
+
|
32
|
+
account = Goodwill::Account.new('username', 'password')
|
33
|
+
|
34
|
+
pp account.search('famicom')
|
35
|
+
[#<Goodwill::Auction:0x007fbf50ec0c18
|
36
|
+
@bidding=false,
|
37
|
+
@bids="8",
|
38
|
+
@current="$66.00",
|
39
|
+
@end="",
|
40
|
+
@href="http://www.shopgoodwill.com/viewItem.asp?itemID=25576979",
|
41
|
+
@item="Two Nintendo Super Famicom Game Consoles 020",
|
42
|
+
@itemid="25576979",
|
43
|
+
@seller="Columbia Goodwill">]
|
44
|
+
```
|
30
45
|
|
31
46
|
## Development
|
32
47
|
|
@@ -36,5 +51,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
36
51
|
|
37
52
|
## Contributing
|
38
53
|
|
39
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
40
|
-
|
54
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/dudemcbacon/goodwill.
|
data/Rakefile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
3
4
|
|
4
5
|
RSpec::Core::RakeTask.new(:spec)
|
6
|
+
RuboCop::RakeTask.new
|
5
7
|
|
6
|
-
task :
|
8
|
+
task default: :spec
|
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'goodwill'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "goodwill"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start
|
data/goodwill.gemspec
CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ['lib']
|
29
29
|
|
30
|
+
spec.add_development_dependency 'simplecov'
|
30
31
|
spec.add_development_dependency 'rake', '~> 10.0'
|
31
32
|
spec.add_development_dependency 'rspec', '~> 3.3'
|
32
33
|
spec.add_development_dependency 'rubocop', '~> 0.34'
|
data/lib/goodwill/account.rb
CHANGED
@@ -6,6 +6,9 @@ require 'mechanize'
|
|
6
6
|
require 'parallel'
|
7
7
|
|
8
8
|
module Goodwill
|
9
|
+
#
|
10
|
+
# Allows for basic account interaction
|
11
|
+
#
|
9
12
|
class Account
|
10
13
|
include Goodwill::Mechanize
|
11
14
|
include URLPaths
|
@@ -30,8 +33,8 @@ module Goodwill
|
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
33
|
-
def search(
|
34
|
-
search_page = mechanize.get(SEARCH_URL +
|
36
|
+
def search(item_title)
|
37
|
+
search_page = mechanize.get(SEARCH_URL + item_title)
|
35
38
|
pages(total_items(search_page)).times.map do |i|
|
36
39
|
search_page = search_page.link_with(text: 'Next').click unless i == 0
|
37
40
|
Parallel.map(search_page.search('table.productresults tbody > tr'), in_threads: @threads) do |row|
|
data/lib/goodwill/auction.rb
CHANGED
@@ -5,6 +5,9 @@ require 'goodwill/urlpaths'
|
|
5
5
|
require 'goodwill/mechanize'
|
6
6
|
|
7
7
|
module Goodwill
|
8
|
+
#
|
9
|
+
# A ShopGoodwill Auction
|
10
|
+
#
|
8
11
|
class Auction
|
9
12
|
include Goodwill::Mechanize
|
10
13
|
include CSSPaths
|
@@ -27,22 +30,28 @@ module Goodwill
|
|
27
30
|
|
28
31
|
@href = ITEM_SEARCH_URL + itemid.to_s
|
29
32
|
item_page = mechanize.get(@href)
|
30
|
-
@bids = item_page.search(BIDS_PATH).text[/\d+/]
|
31
|
-
@current = item_page.search(CURRENT_PRICE_PATH).text
|
32
|
-
@end = item_page.search(END_TIME_PATH).text
|
33
|
+
@bids = item_page.search(BIDS_PATH).text[/\d+/].to_i
|
34
|
+
@current = item_page.search(CURRENT_PRICE_PATH).text.tr('$', '').to_f
|
35
|
+
@end = DateTime.strptime(item_page.search(END_TIME_PATH).text, '%m/%d/%Y %l:%M:%S %p %Z')
|
33
36
|
@item = item_page.search(ITEM_TITLE_PATH).text
|
34
37
|
@seller = item_page.search(SELLER_PATH).text
|
35
38
|
@bidding = false
|
36
39
|
@shipping = calculate_shipping(@itemid, @zipcode, @state, @country)
|
37
40
|
end
|
38
41
|
|
39
|
-
def ==(
|
40
|
-
|
42
|
+
def ==(other)
|
43
|
+
itemid == other.itemid
|
41
44
|
end
|
42
45
|
|
43
46
|
def to_hash
|
44
47
|
hash = {}
|
45
|
-
instance_variables.each
|
48
|
+
instance_variables.each do |var|
|
49
|
+
if var == :@end
|
50
|
+
hash[var.to_s.delete('@')] = instance_variable_get(var).to_s
|
51
|
+
else
|
52
|
+
hash[var.to_s.delete('@')] = instance_variable_get(var)
|
53
|
+
end
|
54
|
+
end
|
46
55
|
hash
|
47
56
|
end
|
48
57
|
|
@@ -51,7 +60,7 @@ module Goodwill
|
|
51
60
|
def calculate_shipping(itemid, zipcode, state, country)
|
52
61
|
params = "?itemid=#{itemid}&zip=#{zipcode}&state=#{state}&country=#{country}"
|
53
62
|
page = mechanize.get(SHIPPING_URL + params)
|
54
|
-
page.search(SHIPPING_PATH).text
|
63
|
+
page.search(SHIPPING_PATH).text.tr('$', '').to_f
|
55
64
|
end
|
56
65
|
end
|
57
66
|
end
|
data/lib/goodwill/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: goodwill
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Burnett
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: simplecov
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rake
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -175,6 +189,7 @@ files:
|
|
175
189
|
- .env
|
176
190
|
- .gitignore
|
177
191
|
- .rspec
|
192
|
+
- .rubocop.yml
|
178
193
|
- .travis.yml
|
179
194
|
- Gemfile
|
180
195
|
- Gemfile.old
|