ives 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem "nokogiri"
7
+ gem "hashie"
8
+ gem "httpi"
9
+
10
+ # Add dependencies to develop your gem here.
11
+ # Include everything needed to run rake, tests, features, etc.
12
+ group :development do
13
+ gem "rspec", ">= 0"
14
+ gem "bundler", "~> 1.0.0"
15
+ gem "jeweler", "~> 1.5.2"
16
+ gem "rcov", ">= 0"
17
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,38 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.2)
5
+ git (1.2.5)
6
+ hashie (1.0.0)
7
+ httpi (0.9.3)
8
+ ntlm-http (>= 0.1.1)
9
+ rack
10
+ jeweler (1.5.2)
11
+ bundler (~> 1.0.0)
12
+ git (>= 1.2.5)
13
+ rake
14
+ nokogiri (1.4.4)
15
+ ntlm-http (0.1.1)
16
+ rack (1.2.2)
17
+ rake (0.8.7)
18
+ rcov (0.9.9)
19
+ rspec (2.5.0)
20
+ rspec-core (~> 2.5.0)
21
+ rspec-expectations (~> 2.5.0)
22
+ rspec-mocks (~> 2.5.0)
23
+ rspec-core (2.5.1)
24
+ rspec-expectations (2.5.0)
25
+ diff-lcs (~> 1.1.2)
26
+ rspec-mocks (2.5.0)
27
+
28
+ PLATFORMS
29
+ ruby
30
+
31
+ DEPENDENCIES
32
+ bundler (~> 1.0.0)
33
+ hashie
34
+ httpi
35
+ jeweler (~> 1.5.2)
36
+ nokogiri
37
+ rcov
38
+ rspec
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Stef Lewandowski
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,74 @@
1
+ International Venue and Event Standard
2
+ ======================================
3
+
4
+ "The IVES (International Venue and Event Standard) Project is an independent, non-profit partnership dedicated to the development and promotion of a standard suite of XML specifications and Venue identification tools, designed to ease the automation and exchange of event and venue data."
5
+
6
+ Translation - every cultural venue in the UK (and hopefully the World) will have a unique identifier that you can use in your project.
7
+
8
+ This is an unofficial gem to consume the XML API offered by the service.
9
+
10
+ Usage
11
+ -----
12
+
13
+ gem install ives
14
+
15
+ or with Bundler add this to your Gemfile
16
+
17
+ gem "ives"
18
+
19
+ What does it do?
20
+ ----------------
21
+
22
+ It currently provides a small subset of the API methods:
23
+
24
+ require 'ives'
25
+ kelvin_hall = IVES::Venue.get("r34lt")
26
+ => <#IVES::Venue address="1445 Argyle Street" alt_names="" country_code="GB" latitude="55.8685" longitude="-4.29354" postal_code="G3 8AW" previous_names="" radius="" region="" town="Glasgow" venue_name="Kelvin Hall International Sports Arena" vid_type="distinct">
27
+ kelvin_hall.latitude
28
+ => "55.8685"
29
+ irb(main):004:0> require 'pp'
30
+ => true
31
+ irb(main):005:0> pp kelvin_hall.to_hash
32
+ {"radius"=>"",
33
+ "region"=>"",
34
+ "address"=>"1445 Argyle Street",
35
+ "latitude"=>"55.8685",
36
+ "country_code"=>"GB",
37
+ "postal_code"=>"G3 8AW",
38
+ "previous_names"=>"",
39
+ "venue_name"=>"Kelvin Hall International Sports Arena",
40
+ "alt_names"=>"",
41
+ "vid_type"=>"distinct",
42
+ "longitude"=>"-4.29354",
43
+ "town"=>"Glasgow"}
44
+ => nil
45
+
46
+ Other methods
47
+ -------------
48
+
49
+ IVES::Venue.find(free_text)
50
+
51
+ This will search for a matching named venue. This is probably the 90% use case. "What is the name of the theatre you want?", etc.
52
+
53
+ IVES::Venue.find_by_postcode(postcode)
54
+
55
+ This will search against a venue postcode. No way of knowing if it strips spaces or not at the moment.
56
+
57
+ More methods to come as and when required.
58
+
59
+ Contributing to ives
60
+ ====================
61
+
62
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
63
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
64
+ * Fork the project
65
+ * Start a feature/bugfix branch
66
+ * Commit and push until you are happy with your contribution
67
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
68
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
69
+
70
+ Copyright
71
+ =========
72
+
73
+ Copyright (c) 2011 Stef Lewandowski. See LICENSE.txt for further details.
74
+
data/Rakefile ADDED
@@ -0,0 +1,57 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "ives"
16
+ gem.homepage = "http://github.com/stefl/ives"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Ruby gem to access the IVES Venue ID API}
19
+ gem.description = %Q{}
20
+ gem.email = "stef@stef.io"
21
+ gem.authors = ["stefl"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ gem.add_runtime_dependency 'hashie'
27
+ gem.add_runtime_dependency 'nokogiri'
28
+ gem.add_runtime_dependency 'httpi'
29
+
30
+ end
31
+ Jeweler::RubygemsDotOrgTasks.new
32
+
33
+ require 'rake/testtask'
34
+ Rake::TestTask.new(:test) do |test|
35
+ test.libs << 'lib' << 'test'
36
+ test.pattern = 'test/**/test_*.rb'
37
+ test.verbose = true
38
+ end
39
+
40
+ require 'rcov/rcovtask'
41
+ Rcov::RcovTask.new do |test|
42
+ test.libs << 'test'
43
+ test.pattern = 'test/**/test_*.rb'
44
+ test.verbose = true
45
+ end
46
+
47
+ task :default => :test
48
+
49
+ require 'rake/rdoctask'
50
+ Rake::RDocTask.new do |rdoc|
51
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
52
+
53
+ rdoc.rdoc_dir = 'rdoc'
54
+ rdoc.title = "ives #{version}"
55
+ rdoc.rdoc_files.include('README*')
56
+ rdoc.rdoc_files.include('lib/**/*.rb')
57
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/ives.gemspec ADDED
@@ -0,0 +1,82 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{ives}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["stefl"]
12
+ s.date = %q{2011-05-14}
13
+ s.description = %q{}
14
+ s.email = %q{stef@stef.io}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.md",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "ives.gemspec",
28
+ "lib/ives.rb",
29
+ "test/helper.rb",
30
+ "test/test_ives.rb"
31
+ ]
32
+ s.homepage = %q{http://github.com/stefl/ives}
33
+ s.licenses = ["MIT"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = %q{1.3.7}
36
+ s.summary = %q{Ruby gem to access the IVES Venue ID API}
37
+ s.test_files = [
38
+ "test/helper.rb",
39
+ "test/test_ives.rb"
40
+ ]
41
+
42
+ if s.respond_to? :specification_version then
43
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
48
+ s.add_runtime_dependency(%q<hashie>, [">= 0"])
49
+ s.add_runtime_dependency(%q<httpi>, [">= 0"])
50
+ s.add_development_dependency(%q<rspec>, [">= 0"])
51
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
52
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
53
+ s.add_development_dependency(%q<rcov>, [">= 0"])
54
+ s.add_runtime_dependency(%q<hashie>, [">= 0"])
55
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
56
+ s.add_runtime_dependency(%q<httpi>, [">= 0"])
57
+ else
58
+ s.add_dependency(%q<nokogiri>, [">= 0"])
59
+ s.add_dependency(%q<hashie>, [">= 0"])
60
+ s.add_dependency(%q<httpi>, [">= 0"])
61
+ s.add_dependency(%q<rspec>, [">= 0"])
62
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
63
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
64
+ s.add_dependency(%q<rcov>, [">= 0"])
65
+ s.add_dependency(%q<hashie>, [">= 0"])
66
+ s.add_dependency(%q<nokogiri>, [">= 0"])
67
+ s.add_dependency(%q<httpi>, [">= 0"])
68
+ end
69
+ else
70
+ s.add_dependency(%q<nokogiri>, [">= 0"])
71
+ s.add_dependency(%q<hashie>, [">= 0"])
72
+ s.add_dependency(%q<httpi>, [">= 0"])
73
+ s.add_dependency(%q<rspec>, [">= 0"])
74
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
75
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
76
+ s.add_dependency(%q<rcov>, [">= 0"])
77
+ s.add_dependency(%q<hashie>, [">= 0"])
78
+ s.add_dependency(%q<nokogiri>, [">= 0"])
79
+ s.add_dependency(%q<httpi>, [">= 0"])
80
+ end
81
+ end
82
+
data/lib/ives.rb ADDED
@@ -0,0 +1,49 @@
1
+ require 'nokogiri'
2
+ require 'hashie'
3
+ require 'open-uri'
4
+ require 'httpi'
5
+
6
+ module IVES
7
+ class Venue < Hashie::Mash
8
+ def self.get id
9
+ full_id = id.to_s
10
+ unless id.to_s =~ /ives\.info/
11
+ full_id = "http://ives.info/gb/#{id}"
12
+ end
13
+ doc = Nokogiri::XML(open("#{full_id}?format=xml")) do |config|
14
+ config.options = Nokogiri::XML::ParseOptions::NOBLANKS
15
+ end
16
+ attributes = {}
17
+ doc.at("venue").children.each do |node|
18
+ attributes[node.name] = node.children.to_s
19
+ end
20
+ self.new(attributes)
21
+ end
22
+
23
+ #venue_name Name of venue
24
+ #address Address of venue (will be matched against both address fields)
25
+ #town Town
26
+ #postal_code Postcode/Zipcode
27
+ def self.find terms={}
28
+ request = HTTPI::Request.new
29
+ request.url = "http://www.ives.info/search"
30
+ request.body = terms.collect{|k,v| "#{k}=#{v}"}.join("&")
31
+ result = HTTPI.post request
32
+ doc = Nokogiri::HTML(result.body)
33
+ top = doc.css("ul.searchResults li a").first.attributes["href"]
34
+ if top
35
+ Venue.get(top)
36
+ else
37
+ nil
38
+ end
39
+ end
40
+
41
+ def self.search name
42
+ find(:venue_name=>name)
43
+ end
44
+
45
+ def self.find_by_postcode postcode
46
+ find(:postal_code=>postcode)
47
+ end
48
+ end
49
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rspec'
11
+
12
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
14
+ require 'ives'
15
+
16
+ Spec::Runner.configure do |config|
17
+ end
data/test/test_ives.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestIves < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,222 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ives
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - stefl
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-05-14 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ name: nokogiri
33
+ prerelease: false
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ hash: 3
42
+ segments:
43
+ - 0
44
+ version: "0"
45
+ type: :runtime
46
+ name: hashie
47
+ prerelease: false
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ requirement: &id003 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ type: :runtime
60
+ name: httpi
61
+ prerelease: false
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ requirement: &id004 !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ type: :development
74
+ name: rspec
75
+ prerelease: false
76
+ version_requirements: *id004
77
+ - !ruby/object:Gem::Dependency
78
+ requirement: &id005 !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ hash: 23
84
+ segments:
85
+ - 1
86
+ - 0
87
+ - 0
88
+ version: 1.0.0
89
+ type: :development
90
+ name: bundler
91
+ prerelease: false
92
+ version_requirements: *id005
93
+ - !ruby/object:Gem::Dependency
94
+ requirement: &id006 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ~>
98
+ - !ruby/object:Gem::Version
99
+ hash: 7
100
+ segments:
101
+ - 1
102
+ - 5
103
+ - 2
104
+ version: 1.5.2
105
+ type: :development
106
+ name: jeweler
107
+ prerelease: false
108
+ version_requirements: *id006
109
+ - !ruby/object:Gem::Dependency
110
+ requirement: &id007 !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ hash: 3
116
+ segments:
117
+ - 0
118
+ version: "0"
119
+ type: :development
120
+ name: rcov
121
+ prerelease: false
122
+ version_requirements: *id007
123
+ - !ruby/object:Gem::Dependency
124
+ requirement: &id008 !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ hash: 3
130
+ segments:
131
+ - 0
132
+ version: "0"
133
+ type: :runtime
134
+ name: hashie
135
+ prerelease: false
136
+ version_requirements: *id008
137
+ - !ruby/object:Gem::Dependency
138
+ requirement: &id009 !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ hash: 3
144
+ segments:
145
+ - 0
146
+ version: "0"
147
+ type: :runtime
148
+ name: nokogiri
149
+ prerelease: false
150
+ version_requirements: *id009
151
+ - !ruby/object:Gem::Dependency
152
+ requirement: &id010 !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ hash: 3
158
+ segments:
159
+ - 0
160
+ version: "0"
161
+ type: :runtime
162
+ name: httpi
163
+ prerelease: false
164
+ version_requirements: *id010
165
+ description: ""
166
+ email: stef@stef.io
167
+ executables: []
168
+
169
+ extensions: []
170
+
171
+ extra_rdoc_files:
172
+ - LICENSE.txt
173
+ - README.md
174
+ files:
175
+ - .document
176
+ - Gemfile
177
+ - Gemfile.lock
178
+ - LICENSE.txt
179
+ - README.md
180
+ - Rakefile
181
+ - VERSION
182
+ - ives.gemspec
183
+ - lib/ives.rb
184
+ - test/helper.rb
185
+ - test/test_ives.rb
186
+ has_rdoc: true
187
+ homepage: http://github.com/stefl/ives
188
+ licenses:
189
+ - MIT
190
+ post_install_message:
191
+ rdoc_options: []
192
+
193
+ require_paths:
194
+ - lib
195
+ required_ruby_version: !ruby/object:Gem::Requirement
196
+ none: false
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ hash: 3
201
+ segments:
202
+ - 0
203
+ version: "0"
204
+ required_rubygems_version: !ruby/object:Gem::Requirement
205
+ none: false
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ hash: 3
210
+ segments:
211
+ - 0
212
+ version: "0"
213
+ requirements: []
214
+
215
+ rubyforge_project:
216
+ rubygems_version: 1.3.7
217
+ signing_key:
218
+ specification_version: 3
219
+ summary: Ruby gem to access the IVES Venue ID API
220
+ test_files:
221
+ - test/helper.rb
222
+ - test/test_ives.rb