kickstapi 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +10 -2
- data/lib/kickstapi/kickstarter_gateway.rb +1 -1
- data/lib/kickstapi/project.rb +1 -0
- data/lib/kickstapi/project_mapper.rb +1 -1
- data/lib/kickstapi/reward.rb +14 -0
- data/lib/kickstapi/version.rb +1 -1
- data/spec/kickstapi_spec.rb +11 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec24eaf5d7b36b006e3700336d0c86cfbd390ac4
|
4
|
+
data.tar.gz: 40e0cab8496bb4a325edd23a71f610e3f3405c5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c13f5d3f1d5bbf355ce58afdd7ebbf294d4a56fb8cc97677ef296d21b650f53865c2cd00987783a55bd3eb2c78d5c4a4de2b8544dae634bca3b249bbf1ff709
|
7
|
+
data.tar.gz: 99d92848c9908c2d8d9f583ecbdc9b58b3dc1f8edaa1f2170b8e2b3c103a462e5c84769c0fc988202804f8cd7d175d2f99c428d77851f52c8e38d605efd99dd9
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,17 @@
|
|
1
|
-
# Kickstapi [![Build Status](https://travis-ci.org/kvannotten/kickstapi.png?branch=master)](https://travis-ci.org/kvannotten/kickstapi) [![Gem Version](https://badge.fury.io/rb/kickstapi.
|
1
|
+
# Kickstapi [![Build Status](https://travis-ci.org/kvannotten/kickstapi.png?branch=master)](https://travis-ci.org/kvannotten/kickstapi) [![Gem Version](https://badge.fury.io/rb/kickstapi.png)](http://badge.fury.io/rb/kickstapi)
|
2
2
|
|
3
|
-
|
3
|
+
## General
|
4
|
+
|
5
|
+
This gem scrapes Kickstarter to create an API that facilitates the creation of applications querying Kickstarter. It does this by parsing the HTML on the website itself.
|
4
6
|
|
5
7
|
Note that this library is not created nor endorsed by Kickstarter
|
6
8
|
|
9
|
+
## Remarks
|
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 Kickstart 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
|
+
|
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
|
+
|
7
15
|
## Installation
|
8
16
|
|
9
17
|
Add this line to your application's Gemfile:
|
data/lib/kickstapi/project.rb
CHANGED
data/lib/kickstapi/reward.rb
CHANGED
@@ -9,5 +9,19 @@ module Kickstapi
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
|
13
|
+
def to_hash
|
14
|
+
hash = {}
|
15
|
+
self.instance_variables.each do |var|
|
16
|
+
sym = var.to_s.gsub(/@/, '')
|
17
|
+
hash[sym.to_sym] = self.instance_variable_get var
|
18
|
+
end
|
19
|
+
hash
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_json(*a)
|
23
|
+
self.to_hash.to_json
|
24
|
+
end
|
25
|
+
|
12
26
|
end
|
13
27
|
end
|
data/lib/kickstapi/version.rb
CHANGED
data/spec/kickstapi_spec.rb
CHANGED
@@ -8,6 +8,7 @@ describe Kickstapi do
|
|
8
8
|
before :all do
|
9
9
|
@projects = Kickstapi.find_projects_with_filter "Planetary Annihilation" # succesful project
|
10
10
|
@failure = Kickstapi.find_projects_with_filter("Quala").first # failing project
|
11
|
+
@project_by_name = Kickstapi.find_projects_by_username("kristofv").first
|
11
12
|
end
|
12
13
|
|
13
14
|
context 'projects' do
|
@@ -18,6 +19,14 @@ describe Kickstapi do
|
|
18
19
|
it { should_not be_empty }
|
19
20
|
end
|
20
21
|
|
22
|
+
context 'a username project' do
|
23
|
+
subject { @project_by_name }
|
24
|
+
|
25
|
+
its(:creator) { should be_eql :not_loaded } # the creator field cannot be fetched from this page
|
26
|
+
|
27
|
+
its(:name) { should_not be_eql :not_loaded } # the name object should still be fetched
|
28
|
+
end
|
29
|
+
|
21
30
|
context 'a project' do
|
22
31
|
subject { @projects.first}
|
23
32
|
|
@@ -28,7 +37,7 @@ describe Kickstapi do
|
|
28
37
|
its(:pledged) { should be_kind_of Float }
|
29
38
|
|
30
39
|
it "returns valid json" do
|
31
|
-
expect { JSON.parse @projects.first.to_json }.not_to raise_error
|
40
|
+
expect { @projects.first.load; JSON.parse @projects.first.to_json }.not_to raise_error
|
32
41
|
end
|
33
42
|
|
34
43
|
it "should be in ghost state when first fetched" do
|
@@ -66,7 +75,7 @@ describe Kickstapi do
|
|
66
75
|
end
|
67
76
|
|
68
77
|
it "should mark a successful project" do
|
69
|
-
@projects.first.status.should be_eql :
|
78
|
+
@projects.first.status.should be_eql :successful
|
70
79
|
end
|
71
80
|
|
72
81
|
it "should mark an unsuccessful project" do
|