sitra_client 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,17 +1,17 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in sitra_client.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sitra_client.gemspec
4
+ gemspec
data/LICENSE.txt CHANGED
@@ -1,22 +1,22 @@
1
- Copyright (c) 2014 jeanbaptistevilain
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2014 jeanbaptistevilain
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,29 +1,29 @@
1
- # SitraClient
2
-
3
- TODO: Write a gem description
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'sitra_client'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install sitra_client
18
-
19
- ## Usage
20
-
21
- TODO: Write usage instructions here
22
-
23
- ## Contributing
24
-
25
- 1. Fork it
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
1
+ # SitraClient
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'sitra_client'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install sitra_client
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
3
-
4
- Rake::TestTask.new do |t|
5
- t.verbose = true
6
- t.pattern = '**/*_test.rb'
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.verbose = true
6
+ t.pattern = '**/*_test.rb'
7
7
  end
@@ -108,7 +108,9 @@ class TouristicObject
108
108
  end
109
109
 
110
110
  def address
111
- "#{address_details[:adresse1]}, #{address_details[:commune][:nom]}"
111
+ computed_address = ''
112
+ computed_address += "#{address_details[:adresse1]}, " unless address_details[:adresse1].nil?
113
+ computed_address + address_details[:commune][:nom]
112
114
  end
113
115
 
114
116
  def latitude
@@ -145,8 +147,8 @@ class TouristicObject
145
147
  eligible_populations.uniq
146
148
  end
147
149
 
148
- def adapted_tourism
149
- @prestations && @prestations[:tourismesAdaptes] && @prestations[:tourismesAdaptes].collect {|t| t[@libelle]}
150
+ def prestations(prestation_type)
151
+ @prestations && @prestations[prestation_type] && @prestations[prestation_type].collect {|t| t[@libelle]}
150
152
  end
151
153
 
152
154
  def environments
@@ -157,14 +159,6 @@ class TouristicObject
157
159
  @presentation && @presentation[:typologiesPromoSitra] && @presentation[:typologiesPromoSitra].collect {|t| t[@libelle]}
158
160
  end
159
161
 
160
- def services
161
- @prestations && @prestations[:services] && @prestations[:services].collect {|t| t[@libelle]}
162
- end
163
-
164
- def equipements
165
- @prestations && @prestations[:equipements] && @prestations[:equipements].collect {|t| t[@libelle]}
166
- end
167
-
168
162
  private
169
163
 
170
164
  def parse_geoloc_details
@@ -1,3 +1,3 @@
1
1
  module SitraClient
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
data/lib/sitra_client.rb CHANGED
@@ -1,65 +1,65 @@
1
- require 'sitra_client/version'
2
- require 'sitra_client/sitra_query'
3
- require 'sitra_client/sitra_response'
4
- require 'open-uri'
5
- require 'logger'
6
-
7
- module SitraClient
8
-
9
- MAX_COUNT = 100
10
-
11
- # Safety net
12
- MAX_LOOPS = 5
13
-
14
- # Configuration defaults
15
- @config = {
16
- :base_url => 'http://api.sitra-tourisme.com/api/v001',
17
- :api_key => '',
18
- :site_identifier => ''
19
- }
20
-
21
- @valid_config_keys = @config.keys
22
- @logger = Logger.new(STDOUT)
23
-
24
- # Configure through hash
25
- def self.configure(opts = {})
26
- opts.each {|k,v| @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym}
27
- end
28
-
29
- def self.config
30
- @config
31
- end
32
-
33
- def self.query(criteria, all_results = false)
34
- if all_results
35
- loops = 0
36
- criteria[:first] = 0
37
- criteria[:count] = MAX_COUNT
38
- response = get_response(criteria)
39
- results = response.as_array
40
- while response.results_count > results.length && loops < MAX_LOOPS
41
- loops += 1
42
- criteria[:first] += MAX_COUNT
43
- results += get_response(criteria).as_array
44
- end
45
- else
46
- response = get_response(criteria)
47
- results = response.as_array
48
- end
49
- results
50
- end
51
-
52
- private
53
-
54
- def self.get_response(criteria)
55
- response = SitraResponse.new
56
- query = SitraQuery.new(@config[:api_key], @config[:site_identifier], criteria)
57
- @logger.info "Search query : #{@config[:base_url]}/recherche/list-objets-touristiques?query=#{query.to_params}"
58
- open("#{@config[:base_url]}/recherche/list-objets-touristiques?query=#{CGI.escape query.to_params}") { |f|
59
- f.each_line {|line| response.append_line(line)}
60
- }
61
- @logger.info "Retrieved #{response.returned_count} of #{response.results_count} results"
62
- response
63
- end
64
-
65
- end
1
+ require 'sitra_client/version'
2
+ require 'sitra_client/sitra_query'
3
+ require 'sitra_client/sitra_response'
4
+ require 'open-uri'
5
+ require 'logger'
6
+
7
+ module SitraClient
8
+
9
+ MAX_COUNT = 100
10
+
11
+ # Safety net
12
+ MAX_LOOPS = 5
13
+
14
+ # Configuration defaults
15
+ @config = {
16
+ :base_url => 'http://api.sitra-tourisme.com/api/v001',
17
+ :api_key => '',
18
+ :site_identifier => ''
19
+ }
20
+
21
+ @valid_config_keys = @config.keys
22
+ @logger = Logger.new(STDOUT)
23
+
24
+ # Configure through hash
25
+ def self.configure(opts = {})
26
+ opts.each {|k,v| @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym}
27
+ end
28
+
29
+ def self.config
30
+ @config
31
+ end
32
+
33
+ def self.query(criteria, all_results = false)
34
+ if all_results
35
+ loops = 0
36
+ criteria[:first] = 0
37
+ criteria[:count] = MAX_COUNT
38
+ response = get_response(criteria)
39
+ results = response.as_array
40
+ while response.results_count > results.length && loops < MAX_LOOPS
41
+ loops += 1
42
+ criteria[:first] += MAX_COUNT
43
+ results += get_response(criteria).as_array
44
+ end
45
+ else
46
+ response = get_response(criteria)
47
+ results = response.as_array
48
+ end
49
+ results
50
+ end
51
+
52
+ private
53
+
54
+ def self.get_response(criteria)
55
+ response = SitraResponse.new
56
+ query = SitraQuery.new(@config[:api_key], @config[:site_identifier], criteria)
57
+ @logger.info "Search query : #{@config[:base_url]}/recherche/list-objets-touristiques?query=#{query.to_params}"
58
+ open("#{@config[:base_url]}/recherche/list-objets-touristiques?query=#{CGI.escape query.to_params}") { |f|
59
+ f.each_line {|line| response.append_line(line)}
60
+ }
61
+ @logger.info "Retrieved #{response.returned_count} of #{response.results_count} results"
62
+ response
63
+ end
64
+
65
+ end
data/sitra_client.gemspec CHANGED
@@ -1,27 +1,27 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'sitra_client/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "sitra_client"
8
- spec.version = SitraClient::VERSION
9
- spec.authors = ["jeanbaptistevilain"]
10
- spec.email = ["jbvilain@gmail.com"]
11
- spec.description = "Sitra Client Gem"
12
- spec.summary = "A simple Ruby wrapper for the SITRA JSON api"
13
- spec.homepage = "https://github.com/jeanbaptistevilain/sitra_client"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.0"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency "test-unit"
24
- spec.add_development_dependency "shoulda"
25
- spec.add_runtime_dependency "rails", "~> 3.2.14"
26
- spec.add_runtime_dependency "json"
27
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sitra_client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sitra_client"
8
+ spec.version = SitraClient::VERSION
9
+ spec.authors = ["jeanbaptistevilain"]
10
+ spec.email = ["jbvilain@gmail.com"]
11
+ spec.description = "Sitra Client Gem"
12
+ spec.summary = "A simple Ruby wrapper for the SITRA JSON api"
13
+ spec.homepage = "https://github.com/jeanbaptistevilain/sitra_client"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.0"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "test-unit"
24
+ spec.add_development_dependency "shoulda"
25
+ spec.add_runtime_dependency "rails", "~> 3.2.14"
26
+ spec.add_runtime_dependency "json"
27
+ end
@@ -125,11 +125,11 @@ class TouristicObjectTest < Test::Unit::TestCase
125
125
  assert_equal ['Familles'], touristic_object.population
126
126
  end
127
127
 
128
- should 'populate adapted tourism fields' do
128
+ should 'populate prestations fields' do
129
129
  hash_result = {:prestations => {:tourismesAdaptes => [{:libelleFr => "Accessible en fauteuil roulant en autonomie"}]}}
130
130
  touristic_object = TouristicObject.new(hash_result)
131
131
 
132
- assert_true touristic_object.adapted_tourism.include?('Accessible en fauteuil roulant en autonomie')
132
+ assert_true touristic_object.prestations(:tourismesAdaptes).include?('Accessible en fauteuil roulant en autonomie')
133
133
  end
134
134
 
135
135
  should 'retrieve merged general and specific information' do
@@ -167,4 +167,8 @@ class TouristicObjectTest < Test::Unit::TestCase
167
167
 
168
168
  assert_equal 'my_description_en', touristic_object.description
169
169
  end
170
+
171
+ should 'populate services data' do
172
+
173
+ end
170
174
  end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sitra_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - jeanbaptistevilain
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-07-28 00:00:00.000000000 Z
12
+ date: 2014-08-01 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ! '>='
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ! '>='
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: test-unit
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ! '>='
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ! '>='
53
60
  - !ruby/object:Gem::Version
@@ -55,6 +62,7 @@ dependencies:
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: shoulda
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ! '>='
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ! '>='
67
76
  - !ruby/object:Gem::Version
@@ -69,6 +78,7 @@ dependencies:
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: rails
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
83
  - - ~>
74
84
  - !ruby/object:Gem::Version
@@ -76,6 +86,7 @@ dependencies:
76
86
  type: :runtime
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
91
  - - ~>
81
92
  - !ruby/object:Gem::Version
@@ -83,6 +94,7 @@ dependencies:
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: json
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
99
  - - ! '>='
88
100
  - !ruby/object:Gem::Version
@@ -90,6 +102,7 @@ dependencies:
90
102
  type: :runtime
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
107
  - - ! '>='
95
108
  - !ruby/object:Gem::Version
@@ -119,26 +132,27 @@ files:
119
132
  homepage: https://github.com/jeanbaptistevilain/sitra_client
120
133
  licenses:
121
134
  - MIT
122
- metadata: {}
123
135
  post_install_message:
124
136
  rdoc_options: []
125
137
  require_paths:
126
138
  - lib
127
139
  required_ruby_version: !ruby/object:Gem::Requirement
140
+ none: false
128
141
  requirements:
129
142
  - - ! '>='
130
143
  - !ruby/object:Gem::Version
131
144
  version: '0'
132
145
  required_rubygems_version: !ruby/object:Gem::Requirement
146
+ none: false
133
147
  requirements:
134
148
  - - ! '>='
135
149
  - !ruby/object:Gem::Version
136
150
  version: '0'
137
151
  requirements: []
138
152
  rubyforge_project:
139
- rubygems_version: 2.3.0
153
+ rubygems_version: 1.8.24
140
154
  signing_key:
141
- specification_version: 4
155
+ specification_version: 3
142
156
  summary: A simple Ruby wrapper for the SITRA JSON api
143
157
  test_files:
144
158
  - test/sitra_client/sitra_query_test.rb
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YjljNjU4NmJlODE1NWUyNjU3MDdlMTQ4YmVhZGYzZGU3Y2FlNDZmZA==
5
- data.tar.gz: !binary |-
6
- YzAxZWUzYWFhNjIxZWVmNjQxZjc2NjRiOGQ2MDQ5YmZkMDc0YTQ0ZA==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- YjBjMWI2M2M3MzNiZWY5OTFlNTNjNzAzMmY3ZGNiZmY0OGVlYjc1YWJlZmVj
10
- NDk3Y2NkY2ZkY2M4ZThiYzE1OTYzMGVjMGZhMWVlYWViMjFjMDdiNzcwZWQw
11
- MDIyZDk0ZTEzYTM0NDJiNWFhYzNmMWNmYzU0YWU2YWIyYzFlZjE=
12
- data.tar.gz: !binary |-
13
- MzBlYmIzYmI0NTMyMjhjMjFhOTQ1MmY1MmE4MjU5ZmU2YjFiNDBhN2RlODM0
14
- MjM4YmRiMzc1NTUxMzhlYTY0YTFhY2U3MzFlNDFkNGFkYzgxOTE0ZjE0OTc2
15
- MjcwYmIzZDg5NzZlN2FiYzEyNzM4ODhmNGRkN2Q0NGQxOWI5OGM=