kickstapi 0.2.2 → 0.2.3
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.
- checksums.yaml +4 -4
- data/README.md +10 -1
- data/kickstapi.gemspec +1 -0
- data/lib/kickstapi/kickstarter_gateway.rb +5 -5
- data/lib/kickstapi/project.rb +0 -4
- data/lib/kickstapi/version.rb +1 -1
- data/spec/kickstapi_spec.rb +26 -9
- data/spec/spec_helper.rb +1 -0
- metadata +16 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2869081e9bfd1e157100a7960f40d906f8061b57
|
4
|
+
data.tar.gz: 105327f31ecc0cceb1c04ef954e17f707e6eef89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 711d0a54dfdd3974e3820994efd4408c85471691a5c4d19b42f50581cf66449ac657aaaacae426831edd83c9089f48544b173ac4eda58d5dc32b9e3d97c20d82
|
7
|
+
data.tar.gz: bc19606e041cf23513738b0a11e777fdc5fa9b73b922c4c52a3841fe6cab16d5144cdc4a1c167e608bc6b14d373c7282e367a048b51b7c6ef3d0e7090628a88f
|
data/README.md
CHANGED
@@ -8,10 +8,16 @@ Note that this library is not created nor endorsed by Kickstarter
|
|
8
8
|
|
9
9
|
## Remarks
|
10
10
|
|
11
|
-
Kickstarter offers an undocumented API, but recently added a disclaimer that it is against their ToS to use this API by third party applications. Regardless of this, I still want people to get access to
|
11
|
+
Kickstarter offers an undocumented API, but recently added a disclaimer that it is against their ToS to use this API by third party applications. Regardless of this, I still want people to get access to Kickstarter statistics in an easy way. So the only legal way to do this, is to parse the website itself, whom anyone is allowed visit.
|
12
12
|
|
13
13
|
This means that sometimes Kickstarter can change things, which might break functionality. I've written the project in such a way that it separates the scraping concerns from the actual objects and the mapping thereof. This means, that when a change occurs, it has no effect on the end-user methods that the gem offers, and is merely a backend change. So update often!
|
14
14
|
|
15
|
+
## Who uses this gem?
|
16
|
+
|
17
|
+
This gem is being used as a backend for the wildly popular [Kickstarter Tracker Widget](https://play.google.com/store/apps/details?id=com.rovgo.android.kickstarterwidget&hl=en) for Android.
|
18
|
+
|
19
|
+
(Send me a request if you want to be featured here too)
|
20
|
+
|
15
21
|
## Installation
|
16
22
|
|
17
23
|
Add this line to your application's Gemfile:
|
@@ -79,3 +85,6 @@ projects.first.load
|
|
79
85
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
80
86
|
4. Push to the branch (`git push origin my-new-feature`)
|
81
87
|
5. Create new Pull Request
|
88
|
+
|
89
|
+
Make sure all the tests are passing before creating the pull request!
|
90
|
+
|
data/kickstapi.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "rspec-its"
|
24
25
|
spec.add_development_dependency "simplecov"
|
25
26
|
|
26
27
|
["mechanize"].each do |gem_name|
|
@@ -11,7 +11,7 @@ module Kickstapi
|
|
11
11
|
should_page = true
|
12
12
|
|
13
13
|
agent.get(search_url) do |page|
|
14
|
-
page.search("div.project-card-
|
14
|
+
page.search("div.project-card-tall").each do |project|
|
15
15
|
p = Hash.new(0)
|
16
16
|
|
17
17
|
bb_card = project.search("h6.project-title")
|
@@ -20,7 +20,7 @@ module Kickstapi
|
|
20
20
|
p[:name] = bb_card_link.content
|
21
21
|
p[:url] = "https://www.kickstarter.com#{bb_card_link.attributes["href"].value.split('?').first}"
|
22
22
|
p[:id] = JSON.parse(project.attributes["data-project"])["id"].to_i
|
23
|
-
p[:creator] = project.search("div.project-card-
|
23
|
+
p[:creator] = project.search("div.project-card-content > p.project-byline").text.gsub(/\n|by/, '')
|
24
24
|
|
25
25
|
projects << p
|
26
26
|
end
|
@@ -33,8 +33,8 @@ module Kickstapi
|
|
33
33
|
def project_by_url(url)
|
34
34
|
project = {}
|
35
35
|
agent.get(url) do |page|
|
36
|
-
project[:name] = page.search(%Q{//h2[@class
|
37
|
-
project[:creator] = page.search(%Q{//
|
36
|
+
project[:name] = page.search(%Q{//div[contains(@class, 'NS_projects__header')]/h2[contains(@class,'mb1')]/a}).first.text
|
37
|
+
project[:creator] = page.search(%Q{//p[contains(@class, 'h5 mb0 mobile-hide')]/b/a}).first.text
|
38
38
|
project[:url] = url
|
39
39
|
project[:id] = page.search('div').select { |div| div[:class] =~ /^Project\d+/ }.map { |div| div[:class].to_s }.uniq.first.scan(/(\d+)/).flatten.first.to_i
|
40
40
|
project[:backers] = page.search(%Q{//data[@itemprop='Project[backers_count]']}).first.attributes["data-value"].value.to_i
|
@@ -44,7 +44,7 @@ module Kickstapi
|
|
44
44
|
project[:percentage_funded] = page.search(%Q{//div[@id='pledged']}).first.attributes['data-percent-raised'].value.to_f * 100
|
45
45
|
project[:end_date] = DateTime.parse page.search(%Q{//span[@id='project_duration_data']}).first.attributes['data-end_time'].value
|
46
46
|
project[:hours_left] = page.search(%Q{//span[@id='project_duration_data']}).first.attributes['data-hours-remaining'].value.to_f
|
47
|
-
project[:rewards] = parse_rewards(page.search(%Q{//
|
47
|
+
project[:rewards] = parse_rewards(page.search(%Q{//div[@class='NS_projects__rewards_list']}).first)
|
48
48
|
end
|
49
49
|
project
|
50
50
|
end
|
data/lib/kickstapi/project.rb
CHANGED
data/lib/kickstapi/version.rb
CHANGED
data/spec/kickstapi_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Kickstapi do
|
4
4
|
it 'should have a version number' do
|
5
|
-
Kickstapi::VERSION.
|
5
|
+
expect(Kickstapi::VERSION).not_to be_nil
|
6
6
|
end
|
7
7
|
|
8
8
|
before :all do
|
@@ -27,6 +27,22 @@ describe Kickstapi do
|
|
27
27
|
its(:name) { should_not be_eql :not_loaded } # the name object should still be fetched
|
28
28
|
end
|
29
29
|
|
30
|
+
context 'Planetary Annihilation data' do
|
31
|
+
subject { @projects.first } # This is the planetary annihilation project
|
32
|
+
|
33
|
+
its(:creator) { should be_eql 'Uber Entertainment Inc'}
|
34
|
+
its(:name) { should be_eql 'Planetary Annihilation - A Next Generation RTS' }
|
35
|
+
its(:id) { should be_eql 1957695328 }
|
36
|
+
its(:url) { should be_eql 'https://www.kickstarter.com/projects/659943965/planetary-annihilation-a-next-generation-rts'}
|
37
|
+
its(:pledged) { should be_eql 2229344.0 }
|
38
|
+
its(:percentage_funded) { should be_eql 247.7049288888889 }
|
39
|
+
its(:backers) { should be_eql 44162 }
|
40
|
+
its(:status) { should be_eql :successful }
|
41
|
+
its(:currency) { should be_eql 'USD' }
|
42
|
+
its(:goal) { should be_eql 900000.0 }
|
43
|
+
its(:hours_left) { should be_eql 0.0 }
|
44
|
+
end
|
45
|
+
|
30
46
|
context 'a project' do
|
31
47
|
subject { @projects.first}
|
32
48
|
|
@@ -42,7 +58,7 @@ describe Kickstapi do
|
|
42
58
|
|
43
59
|
it "should be in ghost state when first fetched" do
|
44
60
|
temp_project = Kickstapi.find_projects_with_filter("Ewe Topia").first
|
45
|
-
temp_project.load_state.
|
61
|
+
expect(temp_project.load_state).to eq(:ghost)
|
46
62
|
end
|
47
63
|
|
48
64
|
it "should do an initial fetch of some fields, while in ghost state" do
|
@@ -51,35 +67,36 @@ describe Kickstapi do
|
|
51
67
|
temp_project.creator
|
52
68
|
temp_project.url
|
53
69
|
temp_project.name
|
54
|
-
temp_project.load_state.
|
70
|
+
expect(temp_project.load_state).to eq(:ghost)
|
55
71
|
end
|
56
72
|
|
57
73
|
it "should lazily load all the arguments" do
|
58
74
|
temp_project = Kickstapi.find_projects_with_filter("Ewe Topia").first
|
59
75
|
temp_project.backers # fetch an item that is lazily loaded
|
60
|
-
temp_project.load_state.
|
76
|
+
expect(temp_project.load_state).to eq(:loaded)
|
61
77
|
end
|
62
78
|
|
63
79
|
it "should be retrievable from it's URL" do
|
64
80
|
temp_project = Kickstapi.find_project_by_url(@failure.url)
|
65
|
-
temp_project.name.
|
81
|
+
expect(temp_project.name).to eq(@failure.name)
|
82
|
+
expect(temp_project.creator).to eq(@failure.creator)
|
66
83
|
end
|
67
84
|
|
68
85
|
it "should be comparable" do
|
69
86
|
temp_project = Kickstapi.find_project_by_url(@projects.first.url)
|
70
|
-
(temp_project == @projects.first).
|
87
|
+
expect(temp_project == @projects.first).to eq(true)
|
71
88
|
end
|
72
89
|
|
73
90
|
it "should be different from another project" do
|
74
|
-
(@projects.first == @failure).
|
91
|
+
expect(@projects.first == @failure).to eq(false)
|
75
92
|
end
|
76
93
|
|
77
94
|
it "should mark a successful project" do
|
78
|
-
@projects.first.status.
|
95
|
+
expect(@projects.first.status).to eq(:successful)
|
79
96
|
end
|
80
97
|
|
81
98
|
it "should mark an unsuccessful project" do
|
82
|
-
@failure.status.
|
99
|
+
expect(@failure.status).to eq(:failed)
|
83
100
|
end
|
84
101
|
end
|
85
102
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kickstapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kristof Vannotten
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-its
|
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'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: simplecov
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,4 +145,3 @@ summary: This gem offers an API for Kickstarter
|
|
131
145
|
test_files:
|
132
146
|
- spec/kickstapi_spec.rb
|
133
147
|
- spec/spec_helper.rb
|
134
|
-
has_rdoc:
|