kickscraper 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: 3f6f503fbfc07375adac3a6428900538bc719c09
4
- data.tar.gz: 77b4eacbe2cc343ff714eabb3b2cb5875d8ceae3
3
+ metadata.gz: b6beac10ab4c441cb0ad864c19db53fc9444d7dd
4
+ data.tar.gz: 9f329bab1ad747b1628e05135cfa9277cf448054
5
5
  SHA512:
6
- metadata.gz: a65e9ba0572ccaad62b31da732d10835dabcd9560d76a3caf2b305c7adf628d288c73e471eeb1cbea4c8d9150b99dff4f6b67d1959eaf4363d935bfcc4c4a36a
7
- data.tar.gz: 904dfef7ee80aed0a81bf101e56e889428aa0e44d6eb498af74ce703647423c57dac338ba4b4aa2d8ab5d997f42b26f559bd1ea989b2ad066af01b9821ca7b6e
6
+ metadata.gz: c36917a86555a5918178cb16fcad90486c6974c9e4f53edbeb0c5b0a4786e9f972c1a6190699df5e1ebb82d1cc1b71a9f6d96aeac81b0eca3898d6449a6e581c
7
+ data.tar.gz: c0d543246c89957a79b8002ef383acb6cb0ad54d2450c81fd0208e2dd77f869f6c6098372a14433c97e2d02c38b8cb54759579dcff26b01a7645b232071fc85e
data/Gemfile CHANGED
@@ -4,6 +4,6 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :test, :development do
7
- gem 'guard-rspec'
7
+ gem 'guard-rspec', '~> 4.2.5'
8
8
  gem 'terminal-notifier-guard'
9
9
  end
data/kickscraper.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec-core"
23
+ spec.add_development_dependency "rspec-core", "~> 2.14"
24
24
 
25
25
  spec.add_runtime_dependency('faraday', ['>= 0.7', '< 0.9'])
26
26
  spec.add_runtime_dependency('faraday_middleware', '~> 0.8')
@@ -32,8 +32,8 @@ module Kickscraper
32
32
  self::process_api_call "project", id_or_slug.to_s
33
33
  end
34
34
 
35
- def search_projects(search_terms, page = nil)
36
- self::process_api_call "projects", "advanced", search_terms, page
35
+ def search_projects(search_terms, page = nil, category_id = nil, state = nil)
36
+ self::process_api_call "projects", "advanced", search_terms, page, category_id, state
37
37
  end
38
38
 
39
39
  def ending_soon_projects(page = nil)
@@ -58,7 +58,7 @@ module Kickscraper
58
58
 
59
59
  def load_more_projects
60
60
  if self::more_projects_available?
61
- self::process_api_call @last_api_call_params[:request_for], @last_api_call_params[:additional_path], @last_api_call_params[:search_terms], (@last_api_call_params[:page] + 1)
61
+ self::process_api_call @last_api_call_params[:request_for], @last_api_call_params[:additional_path], @last_api_call_params[:search_terms], (@last_api_call_params[:page] + 1), @last_api_call_params[:category_id], @last_api_call_params[:state]
62
62
  else
63
63
  []
64
64
  end
@@ -74,18 +74,20 @@ module Kickscraper
74
74
  end
75
75
 
76
76
 
77
- def process_api_call(request_for, additional_path, search_terms = "", page = nil)
77
+ def process_api_call(request_for, additional_path, search_terms = "", page = nil, category_id = nil, state = nil)
78
78
 
79
79
  # save the parameters for this call, so we can repeat it to get the next page of results
80
80
  @last_api_call_params = {
81
81
  request_for: request_for,
82
82
  additional_path: additional_path,
83
83
  search_terms: search_terms,
84
- page: page.nil? ? 1 : page
84
+ page: page.nil? ? 1 : page,
85
+ category_id: category_id,
86
+ state: state
85
87
  }
86
88
 
87
89
  # make the api call (to the API resource we want)
88
- response = self::make_api_call(request_for, additional_path, search_terms, page)
90
+ response = self::make_api_call(request_for, additional_path, search_terms, page, category_id,state)
89
91
 
90
92
  # handle the response, returning an object with the results
91
93
  self::coerce_api_response(request_for, response)
@@ -189,7 +191,7 @@ module Kickscraper
189
191
  end
190
192
 
191
193
 
192
- def make_api_call(request_for, additional_path = "", search_terms = "", page = nil)
194
+ def make_api_call(request_for, additional_path = "", search_terms = "", page = nil, category_id = nil, state = nil)
193
195
 
194
196
  # set the url/path differently for each type of request
195
197
  case request_for.downcase
@@ -216,7 +218,8 @@ module Kickscraper
216
218
  params = {}
217
219
  params[:term] = search_terms unless search_terms.empty?
218
220
  params[:page] = page unless page.nil?
219
-
221
+ params[:category_id] = category_id unless category_id.nil?
222
+ params[:state] = state unless state.nil?
220
223
 
221
224
  # make the connection and return the response
222
225
  connection(api_or_search).get(path, params)
@@ -1,3 +1,3 @@
1
1
  module Kickscraper
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -69,6 +69,22 @@ shared_examples_for "search projects" do
69
69
  projects[0].id.should be 373368980
70
70
  end
71
71
 
72
+ it "searches projects for a specific one with wrong category" do
73
+ projects = client.search_projects('Spark Core Wi-Fi for Everything', nil, 1)
74
+ projects.length.should be 0
75
+ end
76
+
77
+ it "searches projects for a specific one with wrong state" do
78
+ projects = client.search_projects('Spark Core Wi-Fi for Everything', nil, nil, 'live')
79
+ projects.length.should be 0
80
+ end
81
+
82
+ it "searches projects for a specific one with correct category and state" do
83
+ projects = client.search_projects('Spark Core Wi-Fi for Everything', nil, 16, 'successful')
84
+ projects.length.should be > 0
85
+ projects[0].id.should be 373368980
86
+ end
87
+
72
88
  describe "match search results seen in UI for projects with special characters" do
73
89
  # https://www.kickstarter.com/projects/search?utf8=✓&term=%22angels%22+%26+demons+%21%40%23%24%27%25%5E%26*%28%29
74
90
  it "handles searching for projects with isolated special characters" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kickscraper
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
  - Mark Olson
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-04-12 00:00:00.000000000 Z
14
+ date: 2015-04-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -45,16 +45,16 @@ dependencies:
45
45
  name: rspec-core
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - ">="
48
+ - - "~>"
49
49
  - !ruby/object:Gem::Version
50
- version: '0'
50
+ version: '2.14'
51
51
  type: :development
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - ">="
55
+ - - "~>"
56
56
  - !ruby/object:Gem::Version
57
- version: '0'
57
+ version: '2.14'
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: faraday
60
60
  requirement: !ruby/object:Gem::Requirement