scraperwiki-api 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # The ScraperWiki API Ruby Gem
2
2
 
3
- A Ruby wrapper for the ScraperWiki API.
3
+ A Ruby wrapper for the [ScraperWiki](https://scraperwiki.com/) [API](https://scraperwiki.com/docs/api).
4
+
5
+ [![Build Status](https://secure.travis-ci.org/opennorth/scraperwiki-api-ruby.png)](http://travis-ci.org/opennorth/scraperwiki-api-ruby)
6
+ [![Dependency Status](https://gemnasium.com/opennorth/scraperwiki-api-ruby.png)](https://gemnasium.com/opennorth/scraperwiki-api-ruby)
7
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/opennorth/scraperwiki-api-ruby)
4
8
 
5
9
  ## Installation
6
10
 
data/USAGE CHANGED
@@ -1 +1 @@
1
- See README.md for full usage details.
1
+ See README.md for full usage details.
@@ -7,9 +7,6 @@ module ScraperWiki
7
7
  include HTTParty
8
8
  base_uri 'api.scraperwiki.com/api/1.0'
9
9
 
10
- class Error < StandardError; end
11
- class ScraperNotFound < Error; end
12
-
13
10
  RUN_INTERVALS = {
14
11
  never: -1,
15
12
  monthly: 2678400,
@@ -79,8 +76,8 @@ module ScraperWiki
79
76
  # @param [Hash] opts optional arguments
80
77
  # @option opts [String] :format one of "jsondict", "jsonlist", "csv",
81
78
  # "htmltable" or "rss2"
82
- # @option opts [String] :attach ";"-delimited list of shortnames of other
83
- # scrapers whose data you need to access
79
+ # @option opts [Array,String] :attach ";"-delimited list of shortnames of
80
+ # other scrapers whose data you need to access
84
81
  # @return [Array,Hash,String]
85
82
  # @see https://scraperwiki.com/docs/ruby/ruby_help_documentation/
86
83
  #
@@ -189,12 +186,13 @@ module ScraperWiki
189
186
  # @option opts [String] :version version number (-1 for most recent) [default -1]
190
187
  # @option opts [String] :history_start_date history and runevents are
191
188
  # restricted to this date or after, enter as YYYY-MM-DD
192
- # @option opts [String] :quietfields "|"-delimited list of fields to exclude
193
- # from the output. Must be a subset of 'code|runevents|datasummary|userroles|history'
189
+ # @option opts [Array,String] :quietfields "|"-delimited list of fields to
190
+ # exclude from the output. Must be a subset of 'code|runevents|datasummary|userroles|history'
194
191
  # @return [Array]
195
192
  #
196
193
  # @note Returns an array although the array seems to always have only one item
197
194
  # @note The +tags+ field seems to always be an empty array
195
+ # @note Fields like +last_run+ seem to follow British Summer Time.
198
196
  # @note The query string parameter is +name+, not +shortname+
199
197
  # {https://scraperwiki.com/docs/api#getinfo as in the ScraperWiki docs}
200
198
  def scraper_getinfo(shortname, opts = {})
@@ -318,8 +316,8 @@ module ScraperWiki
318
316
  # @param [Hash] opts optional arguments
319
317
  # @option opts [String] :searchquery search terms
320
318
  # @option opts [Integer] :maxrows number of results to return [default 5]
321
- # @option opts [String] :nolist space-separated list of usernames to exclude
322
- # from the output
319
+ # @option opts [Array,String] :nolist space-separated list of usernames to
320
+ # exclude from the output
323
321
  # @option opts [String] :requestinguser the name of the user making the
324
322
  # search, which changes the order of the matches
325
323
  # @return [Array]
@@ -1,4 +1,7 @@
1
+ require 'time'
2
+
1
3
  require 'rspec'
4
+ require 'yajl'
2
5
 
3
6
  module ScraperWiki
4
7
  class API
@@ -168,6 +171,68 @@ module ScraperWiki
168
171
  RunIntervalMatcher.new :never
169
172
  end
170
173
 
174
+ class LastRunMatcher < ScraperInfoMatcher
175
+ def months
176
+ @multiplier = 2592000 # 30 days
177
+ self
178
+ end
179
+ alias :month :months
180
+
181
+ def weeks
182
+ @multiplier = 604800
183
+ self
184
+ end
185
+ alias :week :weeks
186
+
187
+ def days
188
+ @multiplier = 86400
189
+ self
190
+ end
191
+ alias :day :days
192
+
193
+ def hours
194
+ @multiplier = 3600
195
+ self
196
+ end
197
+ alias :hour :hours
198
+
199
+ def minutes
200
+ @multiplier = 60
201
+ self
202
+ end
203
+ alias :minute :minutes
204
+
205
+ def seconds
206
+ @multiplier = 3600
207
+ self
208
+ end
209
+ alias :second :seconds
210
+
211
+ # @todo +last_run+ seems to follow British Summer Time, in which case it
212
+ # will be +00, not +01, for part of the year.
213
+ def matches?(actual)
214
+ super
215
+ Time.now - Time.parse("#{@actual['last_run']}+01") < span
216
+ end
217
+
218
+ def span
219
+ @expected * (@multiplier || 1)
220
+ end
221
+
222
+ def failure_message
223
+ "expected #{@actual['short_name']} to have run within #{span} seconds"
224
+ end
225
+
226
+ def negative_failure_message
227
+ "expected #{@actual['short_name']} to not have run within #{span} seconds"
228
+ end
229
+ end
230
+ # @example
231
+ # it {should have_run_within(7).days}
232
+ def have_run_within(expected)
233
+ LastRunMatcher.new expected
234
+ end
235
+
171
236
  class TablesMatcher < ScraperInfoMatcher
172
237
  def on(table)
173
238
  @table = table
@@ -1,5 +1,5 @@
1
1
  module ScraperWiki
2
2
  class API
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
@@ -20,4 +20,5 @@ Gem::Specification.new do |s|
20
20
  s.add_runtime_dependency('yajl-ruby', '~> 1.0')
21
21
  s.add_runtime_dependency('httparty', '~> 0.8.0')
22
22
  s.add_development_dependency('rspec', '~> 2.10')
23
+ s.add_development_dependency('rake')
23
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scraperwiki-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-01 00:00:00.000000000 Z
12
+ date: 2012-09-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yajl-ruby
16
- requirement: &70265218891100 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70265218891100
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: httparty
27
- requirement: &70265218882020 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,18 +37,44 @@ dependencies:
32
37
  version: 0.8.0
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70265218882020
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.8.0
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rspec
38
- requirement: &70265218880500 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.10'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
39
57
  none: false
40
58
  requirements:
41
59
  - - ~>
42
60
  - !ruby/object:Gem::Version
43
61
  version: '2.10'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
44
70
  type: :development
45
71
  prerelease: false
46
- version_requirements: *70265218880500
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
47
78
  description: A Ruby wrapper for the ScraperWiki API
48
79
  email:
49
80
  - info@opennorth.ca
@@ -52,6 +83,7 @@ extensions: []
52
83
  extra_rdoc_files: []
53
84
  files:
54
85
  - .gitignore
86
+ - .travis.yml
55
87
  - Gemfile
56
88
  - LICENSE
57
89
  - README.md
@@ -83,10 +115,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
115
  version: '0'
84
116
  requirements: []
85
117
  rubyforge_project:
86
- rubygems_version: 1.8.12
118
+ rubygems_version: 1.8.24
87
119
  signing_key:
88
120
  specification_version: 3
89
121
  summary: The ScraperWiki API Ruby Gem
90
122
  test_files:
91
123
  - spec/scraperwiki-api_spec.rb
92
124
  - spec/spec_helper.rb
125
+ has_rdoc: