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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 202f1c5ea493fcf383df3a87f710f8506aed3bd8
4
- data.tar.gz: dcba2cf074591251e5ffaadd43500b92e034d73e
3
+ metadata.gz: ec24eaf5d7b36b006e3700336d0c86cfbd390ac4
4
+ data.tar.gz: 40e0cab8496bb4a325edd23a71f610e3f3405c5c
5
5
  SHA512:
6
- metadata.gz: 92a015b4dd986392ea283175951073ab90369e728724b60b1089f186f3ef6e3d736d1cff7721fd10dc558a224da1dc620ba7d2ba2807f3dc6acf9ac3a90d9820
7
- data.tar.gz: 9509895f049e5dc8ae183b2f3f84a1e4a38be60c3008c55200b6d47a4b7486ba2beb2369c1c741bca35d77b7f305047815a9b91615003ab686860ff8581d4e7a
6
+ metadata.gz: 7c13f5d3f1d5bbf355ce58afdd7ebbf294d4a56fb8cc97677ef296d21b650f53865c2cd00987783a55bd3eb2c78d5c4a4de2b8544dae634bca3b249bbf1ff709
7
+ data.tar.gz: 99d92848c9908c2d8d9f583ecbdc9b58b3dc1f8edaa1f2170b8e2b3c103a462e5c84769c0fc988202804f8cd7d175d2f99c428d77851f52c8e38d605efd99dd9
data/.travis.yml CHANGED
@@ -2,3 +2,4 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
+ - 2.1.1
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.svg)](http://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
- This gem scrapes Kickstarter to create an API that facilitates the creation of applications querying Kickstarter.
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:
@@ -66,7 +66,7 @@ module Kickstapi
66
66
  end
67
67
  end
68
68
 
69
- p projects
69
+ projects
70
70
  end
71
71
 
72
72
  private
@@ -40,6 +40,7 @@ module Kickstapi
40
40
  hash = {}
41
41
  self.instance_variables.each do |var|
42
42
  sym = var.to_s.gsub(/@/, '')
43
+ next if ['load_state', 'data_source'].include? sym
43
44
  hash[sym.to_sym] = self.instance_variable_get var
44
45
  end
45
46
  hash
@@ -72,7 +72,7 @@ module Kickstapi
72
72
  end
73
73
  else
74
74
  if project.end_date < DateTime.now
75
- project.status = :succesful
75
+ project.status = :successful
76
76
  else
77
77
  project.status = :running_already_achieved
78
78
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Kickstapi
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -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 :succesful
78
+ @projects.first.status.should be_eql :successful
70
79
  end
71
80
 
72
81
  it "should mark an unsuccessful project" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kickstapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristof Vannotten