sitra_client 0.0.8 → 0.0.9

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.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NzIwOGY2MWJmNmVmZGFjNDcwOWMzZDdiYjlhYzhlYTU2OTIzYTk3Ng==
5
+ data.tar.gz: !binary |-
6
+ MzBjODk5MDYyNjA5MzU1NDZlNGE1ZDdmMWM0MDRiOTg0NTUyYTMwNA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MmYyZTRhZjgxYmM2MDA4YzM4MWQyNTcyOTM0M2FlZDYwOWFlNmZiNDQ4ZTJm
10
+ OWY4YTVkNzBmODhmM2VjMjg1YWQwYjA1NmY4YmY4NjA3Y2YzZmJhZmRhN2I2
11
+ OTQwMjEzZGJkZGZhZmQyNDgzNTdlNDVhMjJmNDcwNzBlM2M5NDY=
12
+ data.tar.gz: !binary |-
13
+ Yjk4OTlmNTZmMThhYmViOTQ5ZjY0ZTdiZDI4NTI5OGMyNDVhZWRhZTljNWM3
14
+ ZTZhNzczYjlhOTUzMWU0ZjRiODRjMDZkZDFjODViZjA1ZjNiMmZjNjY3MGVh
15
+ ZjI4ZjUxZTA0YjViNmI5Yzk4YjM0YjcyMDVjMzM2NmEzOGNlZjY=
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
@@ -159,6 +159,32 @@ class TouristicObject
159
159
  @presentation && @presentation[:typologiesPromoSitra] && @presentation[:typologiesPromoSitra].collect {|t| t[@libelle]}
160
160
  end
161
161
 
162
+ def resa
163
+ if @reservation
164
+ @reservation[:organismes]
165
+ end
166
+ end
167
+
168
+ def pdf_link
169
+ @multimedias
170
+ end
171
+
172
+ def reservation
173
+ if @reservation[:complement]
174
+ @reservation[:complement][:libelleFr] || @reservation[:complement][DEFAULT_LIBELLE]
175
+ end
176
+ end
177
+
178
+ def bonplan
179
+ if @presentation[:bonsPlans]
180
+ @presentation[:bonsPlans][@libelle] || @presentation[:bonsPlans][DEFAULT_LIBELLE]
181
+ end
182
+ end
183
+
184
+ def cpltaccueil
185
+ @prestations && @prestations[:complementAccueil] && @prestations[:complementAccueil][:libelleFr]
186
+ end
187
+
162
188
  private
163
189
 
164
190
  def parse_geoloc_details
@@ -1,3 +1,3 @@
1
1
  module SitraClient
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
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
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sitra_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
5
- prerelease:
4
+ version: 0.0.9
6
5
  platform: ruby
7
6
  authors:
8
7
  - jeanbaptistevilain
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-08-01 00:00:00.000000000 Z
11
+ date: 2014-08-22 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: test-unit
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: shoulda
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rails
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: json
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ! '>='
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :runtime
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ! '>='
108
95
  - !ruby/object:Gem::Version
@@ -132,27 +119,26 @@ files:
132
119
  homepage: https://github.com/jeanbaptistevilain/sitra_client
133
120
  licenses:
134
121
  - MIT
122
+ metadata: {}
135
123
  post_install_message:
136
124
  rdoc_options: []
137
125
  require_paths:
138
126
  - lib
139
127
  required_ruby_version: !ruby/object:Gem::Requirement
140
- none: false
141
128
  requirements:
142
129
  - - ! '>='
143
130
  - !ruby/object:Gem::Version
144
131
  version: '0'
145
132
  required_rubygems_version: !ruby/object:Gem::Requirement
146
- none: false
147
133
  requirements:
148
134
  - - ! '>='
149
135
  - !ruby/object:Gem::Version
150
136
  version: '0'
151
137
  requirements: []
152
138
  rubyforge_project:
153
- rubygems_version: 1.8.24
139
+ rubygems_version: 2.4.1
154
140
  signing_key:
155
- specification_version: 3
141
+ specification_version: 4
156
142
  summary: A simple Ruby wrapper for the SITRA JSON api
157
143
  test_files:
158
144
  - test/sitra_client/sitra_query_test.rb