zeit 0.0.1pre2 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +5 -1
- data/README.md +51 -2
- data/lib/zeit/api.rb +3 -2
- data/lib/zeit/resources/author.rb +2 -1
- data/lib/zeit/version.rb +1 -1
- data/spec/resources/author_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- data/zeit.gemspec +2 -0
- metadata +41 -5
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
zeit (0.0.
|
4
|
+
zeit (0.0.1)
|
5
5
|
faraday
|
6
6
|
|
7
7
|
GEM
|
@@ -20,6 +20,7 @@ GEM
|
|
20
20
|
guard-rspec (2.1.2)
|
21
21
|
guard (>= 1.1)
|
22
22
|
rspec (~> 2.11)
|
23
|
+
json (1.7.5)
|
23
24
|
listen (0.6.0)
|
24
25
|
lumberjack (1.0.2)
|
25
26
|
method_source (0.8.1)
|
@@ -40,6 +41,7 @@ GEM
|
|
40
41
|
slop (3.3.3)
|
41
42
|
thor (0.16.0)
|
42
43
|
vcr (2.3.0)
|
44
|
+
yard (0.8.3)
|
43
45
|
|
44
46
|
PLATFORMS
|
45
47
|
ruby
|
@@ -48,7 +50,9 @@ DEPENDENCIES
|
|
48
50
|
bundler (~> 1.0)
|
49
51
|
fakeweb (~> 1.3.0)
|
50
52
|
guard-rspec (~> 2.1.2)
|
53
|
+
json (~> 1.7.5)
|
51
54
|
rb-fsevent
|
52
55
|
rspec (~> 2.12.0)
|
53
56
|
vcr (~> 2.3.0)
|
57
|
+
yard
|
54
58
|
zeit!
|
data/README.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
# Zeit
|
2
2
|
|
3
|
-
|
3
|
+
This gem is a ruby client for the Zeit.de API (http://developer.zeit.de/).
|
4
|
+
|
5
|
+
The german newspaper "Die Zeit" recently announced a so called "content
|
6
|
+
API" to access their large collection of printed and online articles of
|
7
|
+
the past years. To access thir API you'll have to create an api-key which allows you to
|
8
|
+
make 10.000 requests per day, free of charge for non-commercial usage.
|
9
|
+
|
10
|
+
See http://developer.zeit.de/quickstart/
|
4
11
|
|
5
12
|
## Installation
|
6
13
|
|
@@ -18,7 +25,49 @@ Or install it yourself as:
|
|
18
25
|
|
19
26
|
## Usage
|
20
27
|
|
21
|
-
|
28
|
+
|
29
|
+
require 'zeit'
|
30
|
+
require 'json'
|
31
|
+
|
32
|
+
zeit = Zeit::API.new :api_key => 'aaabbccccdddeeeeeeffgggg'
|
33
|
+
|
34
|
+
# author
|
35
|
+
result = zeit.author.find '*Schmidt*'
|
36
|
+
|
37
|
+
data = JSON.parse(result.body)
|
38
|
+
data['matches'].inspect
|
39
|
+
|
40
|
+
# content
|
41
|
+
result = zeit.content.find '*Software*', :limit => 200, :offset => 100
|
42
|
+
|
43
|
+
data = JSON.parse(result.body)
|
44
|
+
data['matches'].inspect
|
45
|
+
|
46
|
+
# department
|
47
|
+
result = zeit.department.find '*internet*'
|
48
|
+
...
|
49
|
+
|
50
|
+
# keyword
|
51
|
+
result = zeit.keyword.find '*internet*'
|
52
|
+
...
|
53
|
+
|
54
|
+
# product
|
55
|
+
result = zeit.product.find '*ZEIT*'
|
56
|
+
|
57
|
+
# series
|
58
|
+
result = zeit.series.find 'Die*'
|
59
|
+
|
60
|
+
# client
|
61
|
+
result = zeit.client.get
|
62
|
+
data = JSON.parse(result.body)
|
63
|
+
# => {"reset"=>1353785293,
|
64
|
+
# "name"=>"my name",
|
65
|
+
# "quota"=>10000,
|
66
|
+
# "tier"=>"free",
|
67
|
+
# "requests"=>192,
|
68
|
+
# "api_key"=>"aaaaaaaabbbbbbbbbbcccc",
|
69
|
+
# "email"=>"email@example.com"}
|
70
|
+
|
22
71
|
|
23
72
|
## Contributing
|
24
73
|
|
data/lib/zeit/api.rb
CHANGED
@@ -3,6 +3,7 @@ module Zeit
|
|
3
3
|
|
4
4
|
def initialize(params = {})
|
5
5
|
@api_key = params[:api_key]
|
6
|
+
@debug = params[:debug]
|
6
7
|
@base_url = params[:base_url] || 'http://api.zeit.de/'
|
7
8
|
@faraday_adapter = params[:faraday_adapter] || Faraday.default_adapter
|
8
9
|
|
@@ -12,10 +13,10 @@ module Zeit
|
|
12
13
|
end
|
13
14
|
|
14
15
|
def connection
|
15
|
-
@connection ||= Faraday.new(url
|
16
|
+
@connection ||= Faraday.new(:url => @base_url) do |faraday|
|
16
17
|
faraday.use Zeit::AuthenticationMiddleware, @api_key
|
17
18
|
faraday.request :url_encoded
|
18
|
-
faraday.response
|
19
|
+
faraday.response(:logger) if @debug
|
19
20
|
faraday.adapter @faraday_adapter
|
20
21
|
end
|
21
22
|
end
|
data/lib/zeit/version.rb
CHANGED
@@ -7,7 +7,7 @@ describe Zeit::Resources::Author, :vcr do
|
|
7
7
|
context 'with a simple query' do
|
8
8
|
it_behaves_like 'a resource response' do
|
9
9
|
subject { Zeit::Resources::Author.new(api_connection).find(query) }
|
10
|
-
let(:query) { '*
|
10
|
+
let(:query) { '*Schmidt*' }
|
11
11
|
|
12
12
|
context 'when authorized' do
|
13
13
|
it_behaves_like 'a successful response with some matches'
|
data/spec/spec_helper.rb
CHANGED
@@ -12,10 +12,10 @@ Dir["./spec/support/**/*.rb"].sort.each {|f| require f}
|
|
12
12
|
|
13
13
|
def authorized_api_client
|
14
14
|
key = ENV['ZEIT_API_KEY'] || 'working'
|
15
|
-
Zeit::API.new api_key
|
15
|
+
Zeit::API.new :api_key => key
|
16
16
|
end
|
17
17
|
|
18
18
|
def unauthorized_api_client
|
19
|
-
Zeit::API.new api_key
|
19
|
+
Zeit::API.new :api_key => 'felix_von_springer' # bild.css
|
20
20
|
end
|
21
21
|
|
data/zeit.gemspec
CHANGED
@@ -24,9 +24,11 @@ Gem::Specification.new do |gem|
|
|
24
24
|
gem.add_dependency 'faraday'
|
25
25
|
|
26
26
|
gem.add_development_dependency 'bundler', '~> 1.0'
|
27
|
+
gem.add_development_dependency 'json', '~> 1.7.5'
|
27
28
|
gem.add_development_dependency 'rspec', '~> 2.12.0'
|
28
29
|
gem.add_development_dependency 'guard-rspec', '~> 2.1.2'
|
29
30
|
gem.add_development_dependency 'rb-fsevent'
|
30
31
|
gem.add_development_dependency 'vcr', '~> 2.3.0'
|
31
32
|
gem.add_development_dependency 'fakeweb', '~> 1.3.0'
|
33
|
+
gem.add_development_dependency 'yard'
|
32
34
|
end
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zeit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Roland Moriz
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '1.0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: json
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.7.5
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.7.5
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: rspec
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,6 +139,22 @@ dependencies:
|
|
123
139
|
- - ~>
|
124
140
|
- !ruby/object:Gem::Version
|
125
141
|
version: 1.3.0
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: yard
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
126
158
|
description: API client for Zeit.de API
|
127
159
|
email:
|
128
160
|
- roland@moriz.de
|
@@ -176,13 +208,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
176
208
|
version: '0'
|
177
209
|
segments:
|
178
210
|
- 0
|
179
|
-
hash:
|
211
|
+
hash: 1998897930141795511
|
180
212
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
213
|
none: false
|
182
214
|
requirements:
|
183
|
-
- - ! '
|
215
|
+
- - ! '>='
|
184
216
|
- !ruby/object:Gem::Version
|
185
|
-
version:
|
217
|
+
version: '0'
|
218
|
+
segments:
|
219
|
+
- 0
|
220
|
+
hash: 1998897930141795511
|
186
221
|
requirements: []
|
187
222
|
rubyforge_project:
|
188
223
|
rubygems_version: 1.8.23
|
@@ -201,3 +236,4 @@ test_files:
|
|
201
236
|
- spec/spec_helper.rb
|
202
237
|
- spec/support/shared_examples_for_resources.rb
|
203
238
|
- spec/support/vcr.rb
|
239
|
+
has_rdoc:
|