festivals_lab 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- festivals_lab (0.0.2)
4
+ festivals_lab (0.0.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/README.md CHANGED
@@ -4,10 +4,12 @@ An unofficial library to access festival data from the Edinburgh Festivals Innov
4
4
 
5
5
  ## Description ##
6
6
 
7
- Festivals Lab is an open data initiative which provides free access to the events of the 12 annual Edinburgh festivals.
7
+ [Festivals Lab][festivalslab] is an open data initiative which provides free access to the events of the 12 annual Edinburgh festivals.
8
8
 
9
9
  The `festivals_lab` gem wraps the API and ties it with a Ruby bow
10
10
 
11
+ [festivalslab]: http://festivalslab.com/
12
+
11
13
  ## Compatibility ##
12
14
 
13
15
  * As an alpha, `festivals_lab` is only developed and tested against Ruby 1.9.3 (other rubies should work, but run the tests first).
@@ -38,7 +40,7 @@ The parameters for library method calls match the [official documentation][query
38
40
  * The library exclusively requests JSON responses from the API, and the `pretty` parameter is invalid.
39
41
 
40
42
  [gettingstarted]: http://api.festivalslab.com/documentation#gettingstarted
41
- [querying]: http://api.festivalslab.com/documentation#Querying the API
43
+ [querying]: http://api.festivalslab.com/documentation#Querying%20the%20API
42
44
 
43
45
  ### Sample usage ###
44
46
 
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.email = ["g@rethada.ms"]
7
7
  gem.description = %q{Accesses festival data from the Edinburgh Festivals Innovation Lab API}
8
8
  gem.summary = %q{The Edinburgh Festivals API is an ambitious project which aims to create open access to the event listings data of Edinburgh’s 12 major Festivals}
9
- gem.homepage = "http://festivalslab.com/"
9
+ gem.homepage = "https://github.com/gareth/festivals_lab"
10
10
 
11
11
  gem.files = `git ls-files`.split($\)
12
12
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -1,3 +1,3 @@
1
1
  class FestivalsLab
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/festivals_lab.rb CHANGED
@@ -14,6 +14,11 @@ class FestivalsLab
14
14
  @secret_token = secret_token
15
15
  end
16
16
 
17
+ # Searches the API for events matching the given `params`
18
+ #
19
+ # See the API documentation at
20
+ # http://api.festivalslab.com/documentation#Querying%20the%20API for valid
21
+ # parameters
17
22
  def events params = {}
18
23
  params = params.dup
19
24
 
@@ -39,11 +44,18 @@ class FestivalsLab
39
44
  FestivalsLab.request access_key, secret_token, '/events', params
40
45
  end
41
46
 
47
+ # Returns the known data for an event based on the event's UUID
48
+ #
49
+ # The only way to obtain the UUID for an event is to extract it from the
50
+ # `url` property returned by the `events` endpoint
42
51
  def event uuid
43
52
  FestivalsLab.request access_key, secret_token, "/event/#{uuid}"
44
53
  end
45
54
 
46
55
  class << self
56
+ # Makes a signed API request to the given endpoint
57
+ #
58
+ # Requests the data in JSON format and parses the response as JSON
47
59
  def request access_key, secret_token, endpoint, params = {}
48
60
  uri = FestivalsLab.signed_uri access_key, secret_token, endpoint, params
49
61
  Net::HTTP.start(uri.host, uri.port) do |http|
@@ -58,6 +70,8 @@ class FestivalsLab
58
70
  end
59
71
  end
60
72
 
73
+ # Returns a URI containing the correct signature for the given endpoint and
74
+ # query string parameters
61
75
  def signed_uri access_key, secret_token, endpoint, params = {}
62
76
  params = params.dup
63
77
  raise Error, "Missing API access key" unless access_key
@@ -78,12 +92,12 @@ class FestivalsLab
78
92
  URI.parse(uri.to_s)
79
93
  end
80
94
 
95
+ # Returns the correct API signature for the given URL and secret token
81
96
  def signature secret_token, url
82
97
  OpenSSL::HMAC.hexdigest 'sha1', secret_token, url
83
98
  end
84
99
  end
85
100
 
86
-
87
101
  Error = Class.new(StandardError)
88
102
  ArgumentError = Class.new(::ArgumentError)
89
103
  ApiError = Class.new(StandardError) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: festivals_lab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-14 00:00:00.000000000 Z
12
+ date: 2013-08-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -79,7 +79,7 @@ files:
79
79
  - lib/festivals_lab/version.rb
80
80
  - test/lib/test_festivals_lab.rb
81
81
  - test/test_helper.rb
82
- homepage: http://festivalslab.com/
82
+ homepage: https://github.com/gareth/festivals_lab
83
83
  licenses: []
84
84
  post_install_message:
85
85
  rdoc_options: []
@@ -93,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  segments:
95
95
  - 0
96
- hash: 4234472854470534461
96
+ hash: -3698572132411797010
97
97
  required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  none: false
99
99
  requirements:
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  segments:
104
104
  - 0
105
- hash: 4234472854470534461
105
+ hash: -3698572132411797010
106
106
  requirements: []
107
107
  rubyforge_project:
108
108
  rubygems_version: 1.8.24