getyourguide 0.1.2 → 0.2.1
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 +4 -4
- data/.coveralls.yml +1 -0
- data/.rspec +1 -0
- data/.travis.yml +6 -0
- data/README.md +7 -1
- data/getyourguide.gemspec +3 -0
- data/lib/getyourguide.rb +6 -10
- data/lib/getyourguide/models/generator.rb +41 -0
- data/lib/getyourguide/parsers/categories.rb +2 -4
- data/lib/getyourguide/parsers/default.rb +10 -12
- data/lib/getyourguide/parsers/destinations.rb +6 -2
- data/lib/getyourguide/parsers/image_formats.rb +2 -4
- data/lib/getyourguide/parsers/products.rb +11 -13
- data/lib/getyourguide/parsers/top_categories.rb +2 -4
- data/lib/getyourguide/version.rb +1 -1
- data/spec/getyourguide/models/activity_spec.rb +83 -0
- data/spec/getyourguide/models/category_spec.rb +24 -0
- data/spec/getyourguide/models/destination_spec.rb +70 -0
- data/spec/getyourguide/models/image_format_spec.rb +36 -0
- data/spec/getyourguide/models/image_spec.rb +23 -0
- data/spec/getyourguide/models/location_spec.rb +35 -0
- data/spec/getyourguide/models/top_category_spec.rb +42 -0
- data/spec/spec_helper.rb +6 -0
- metadata +63 -11
- data/.rvmrc.01.29.2015-18:48:37 +0 -53
- data/lib/getyourguide/models/activity.rb +0 -19
- data/lib/getyourguide/models/category.rb +0 -12
- data/lib/getyourguide/models/destination.rb +0 -16
- data/lib/getyourguide/models/image.rb +0 -12
- data/lib/getyourguide/models/image_format.rb +0 -14
- data/lib/getyourguide/models/location.rb +0 -14
- data/lib/getyourguide/models/top_category.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c3763f617c97acdea4540cf6a70f18b8a24c4da
|
4
|
+
data.tar.gz: b0fa64b30b061bcd2fd3be3a38ca6bc0f04ab50a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b23f4ac816bbb9517b5a8cb149b1f9ce681664c04f60ac0ef10ac6c625acb762c71a15415599e5479ff667c7843f20e56eb2f633fda8891e702a875f6568ca5
|
7
|
+
data.tar.gz: 7e95f9ff37b88e5bf38702496958338598235928ed56cd82136ccbc11d15850ddab2b124a123b4a237ae80456d8a6ce475c47a05d5630e6f32ccdb12e5a36460
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--format documentation --color
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|

|
2
2
|
|
3
|
+
[](http://badge.fury.io/rb/getyourguide) [](https://travis-ci.org/Libertrip/getyourguide) [](https://codeclimate.com/github/Libertrip/getyourguide) [](https://coveralls.io/r/Libertrip/getyourguide?branch=master)
|
4
|
+
|
3
5
|
Read the [gem's wiki](https://github.com/Libertrip/getyourguide/wiki) for more features!
|
4
6
|
|
5
7
|
## Installation
|
@@ -20,7 +22,7 @@ Or install it yourself as:
|
|
20
22
|
|
21
23
|
## Usage
|
22
24
|
|
23
|
-
|
25
|
+
### I. The easy way
|
24
26
|
|
25
27
|
```ruby
|
26
28
|
require 'getyourguide'
|
@@ -39,6 +41,10 @@ api = GetYourGuide::ApiClient.new(partner_id, language)
|
|
39
41
|
parsed_activities = api.call_and_parse(options)
|
40
42
|
```
|
41
43
|
|
44
|
+
## Run tests
|
45
|
+
|
46
|
+
`bundle exec rspec`
|
47
|
+
|
42
48
|
## Contributing
|
43
49
|
|
44
50
|
1. Fork it ( [https://github.com/Libertrip/getyourguide/fork](https://github.com/Libertrip/getyourguide/fork) )
|
data/getyourguide.gemspec
CHANGED
@@ -19,7 +19,10 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
22
|
+
spec.add_development_dependency 'coveralls', '~> 0.7.8', '>= 0.7.8'
|
22
23
|
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.1', '>= 3.1.0'
|
25
|
+
|
23
26
|
spec.add_runtime_dependency 'nokogiri', '~> 1.5', '>= 1.5.0'
|
24
27
|
spec.add_runtime_dependency 'httpclient', '~> 2.3', '>= 2.3.1'
|
25
28
|
end
|
data/lib/getyourguide.rb
CHANGED
@@ -1,19 +1,15 @@
|
|
1
|
-
module GetYourGuide
|
2
|
-
end
|
3
|
-
|
4
1
|
require "getyourguide/version"
|
5
2
|
require "getyourguide/api_client"
|
3
|
+
require "getyourguide/models/generator"
|
6
4
|
require "getyourguide/errors/api_error"
|
7
|
-
require "getyourguide/models/activity"
|
8
|
-
require "getyourguide/models/category"
|
9
|
-
require "getyourguide/models/destination"
|
10
|
-
require "getyourguide/models/image"
|
11
|
-
require "getyourguide/models/image_format"
|
12
|
-
require "getyourguide/models/location"
|
13
|
-
require "getyourguide/models/top_category"
|
14
5
|
require "getyourguide/parsers/default"
|
15
6
|
require "getyourguide/parsers/categories"
|
16
7
|
require "getyourguide/parsers/destinations"
|
17
8
|
require "getyourguide/parsers/image_formats"
|
18
9
|
require "getyourguide/parsers/products"
|
19
10
|
require "getyourguide/parsers/top_categories"
|
11
|
+
|
12
|
+
module GetYourGuide
|
13
|
+
end
|
14
|
+
|
15
|
+
GetYourGuide::Models.generate_models
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module GetYourGuide
|
2
|
+
module Models
|
3
|
+
MODEL_NAMES = %w[Activity Category Destination Image ImageFormat Location TopCategory]
|
4
|
+
MODEL_ATTRIBUTES = {
|
5
|
+
'Activity' => [:provider_id, :title, :abstract, :categories, :locations, :starting_point, :indivative_price, :rating, :pictures],
|
6
|
+
'Category' => [:provider_id, :name],
|
7
|
+
'Destination' => [:provider_id, :name, :country, :unlocode, :iata, :destination_type],
|
8
|
+
'Image' => [:url, :ssl],
|
9
|
+
'ImageFormat' => [:provider_id, :width, :height, :comment],
|
10
|
+
'Location' => [:provider_id, :name, :country, :start_location],
|
11
|
+
'TopCategory' => [:provider_id, :name, :link, :picture, :rating]
|
12
|
+
}
|
13
|
+
|
14
|
+
def self.generate_models
|
15
|
+
GetYourGuide::Models::MODEL_NAMES.each do |klass_name|
|
16
|
+
klass_vars = GetYourGuide::Models::MODEL_ATTRIBUTES[klass_name.to_s]
|
17
|
+
klass = generate_class klass_vars
|
18
|
+
|
19
|
+
const_set klass_name, klass
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.generate_class(klass_vars)
|
24
|
+
Class.new do
|
25
|
+
klass_vars.each do |field|
|
26
|
+
define_method field.intern do
|
27
|
+
instance_variable_get("@#{field}")
|
28
|
+
end
|
29
|
+
define_method "#{field}=".intern do |arg|
|
30
|
+
instance_variable_set("@#{field}", arg)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
define_method :initialize do |args|
|
34
|
+
klass_vars.each do |field|
|
35
|
+
instance_variable_set("@#{field}", args[field])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -16,12 +16,10 @@ module GetYourGuide
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def parse_simgle_category(category_xml)
|
19
|
-
|
19
|
+
create_model('Category', {
|
20
20
|
:provider_id => category_xml.attr('id').to_i,
|
21
21
|
:name => category_xml.xpath('name').children.inner_text
|
22
|
-
}
|
23
|
-
|
24
|
-
GetYourGuide::Models::Category.new(category_attributes)
|
22
|
+
})
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
@@ -11,14 +11,12 @@ module GetYourGuide
|
|
11
11
|
locations = []
|
12
12
|
|
13
13
|
product_xml.xpath('destination').children.xpath('location').each do |location|
|
14
|
-
|
14
|
+
locations << create_model('Location', {
|
15
15
|
:provider_id => location.attr('id').to_i,
|
16
16
|
:name => location.inner_text,
|
17
17
|
:country => location.attr('country'),
|
18
18
|
:start_location => !location.attr('start_location').nil?
|
19
|
-
}
|
20
|
-
|
21
|
-
locations << GetYourGuide::Models::Location.new(location_attributes)
|
19
|
+
})
|
22
20
|
end
|
23
21
|
|
24
22
|
locations
|
@@ -28,12 +26,10 @@ module GetYourGuide
|
|
28
26
|
categories = []
|
29
27
|
|
30
28
|
product_xml.xpath('categories').children.each do |category|
|
31
|
-
|
29
|
+
categories << create_model('Category', {
|
32
30
|
:provider_id => category.attr('id').to_i,
|
33
31
|
:name => category.inner_text
|
34
|
-
}
|
35
|
-
|
36
|
-
categories << GetYourGuide::Models::Category.new(category_attributes)
|
32
|
+
})
|
37
33
|
end
|
38
34
|
|
39
35
|
categories
|
@@ -44,18 +40,20 @@ module GetYourGuide
|
|
44
40
|
|
45
41
|
pictures_xml.xpath('pictures').children.children.each do |picture|
|
46
42
|
unless picture.inner_text == ''
|
47
|
-
|
43
|
+
pictures << create_model('Image', {
|
48
44
|
:ssl => to_boolean(picture.attr('ssl')),
|
49
45
|
:url => picture.inner_text
|
50
|
-
}
|
51
|
-
|
52
|
-
pictures << GetYourGuide::Models::Image.new(picture_attributes)
|
46
|
+
})
|
53
47
|
end
|
54
48
|
end
|
55
49
|
|
56
50
|
pictures
|
57
51
|
end
|
58
52
|
|
53
|
+
def create_model(model_name, attributes)
|
54
|
+
Object.const_get("GetYourGuide::Models::#{model_name}").new attributes
|
55
|
+
end
|
56
|
+
|
59
57
|
def to_boolean(input)
|
60
58
|
input == 'true'
|
61
59
|
end
|
@@ -23,12 +23,16 @@ module GetYourGuide
|
|
23
23
|
:destination_type => destination_xml.attr('type').to_s
|
24
24
|
}
|
25
25
|
|
26
|
+
add_unlocode_and_iata destination_xml, destination_attributes
|
27
|
+
|
28
|
+
create_model('Destination', destination_attributes)
|
29
|
+
end
|
30
|
+
|
31
|
+
def add_unlocode_and_iata(destination_xml, destination_attributes)
|
26
32
|
if destination_xml.xpath('.//alias').children.size > 0
|
27
33
|
destination_attributes[:unlocode] = destination_xml.xpath('.//alias').children.first.inner_text
|
28
34
|
destination_attributes[:iata] = destination_xml.xpath('.//alias').children.last.inner_text
|
29
35
|
end
|
30
|
-
|
31
|
-
GetYourGuide::Models::Destination.new(destination_attributes)
|
32
36
|
end
|
33
37
|
end
|
34
38
|
end
|
@@ -16,14 +16,12 @@ module GetYourGuide
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def parse_simgle_image_format(image_format_xml)
|
19
|
-
|
19
|
+
create_model('ImageFormat', {
|
20
20
|
:provider_id => image_format_xml.attr('id').to_i,
|
21
21
|
:width => image_format_xml.xpath('width').children.inner_text.to_i,
|
22
22
|
:height => image_format_xml.xpath('height').children.inner_text.to_i,
|
23
23
|
:comment => image_format_xml.xpath('comment').children.inner_text
|
24
|
-
}
|
25
|
-
|
26
|
-
GetYourGuide::Models::ImageFormat.new(image_format_attributes)
|
24
|
+
})
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
@@ -16,19 +16,17 @@ module GetYourGuide
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def parse_simgle_product(product_xml)
|
19
|
-
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
}
|
30
|
-
|
31
|
-
GetYourGuide::Models::Activity.new attributes
|
19
|
+
create_model('Activity', {
|
20
|
+
provider_id: product_xml.attr('id').to_i,
|
21
|
+
title: product_xml.xpath('title').children.inner_text,
|
22
|
+
abstract: product_xml.xpath('abstract').children.inner_text,
|
23
|
+
categories: get_categories_list(product_xml),
|
24
|
+
locations: get_locations_list(product_xml),
|
25
|
+
starting_point: get_starting_point_list(product_xml),
|
26
|
+
indivative_price: get_indivative_price(product_xml),
|
27
|
+
rating: product_xml.xpath('rating').children.inner_text.to_f,
|
28
|
+
pictures: get_pictures_list(product_xml)
|
29
|
+
})
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
@@ -16,15 +16,13 @@ module GetYourGuide
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def parse_simgle_category(category_xml)
|
19
|
-
|
19
|
+
create_model('TopCategory', {
|
20
20
|
:provider_id => category_xml.attr('id').to_i,
|
21
21
|
:name => category_xml.xpath('name').children.inner_text,
|
22
22
|
:link => category_xml.xpath('link').children.inner_text,
|
23
23
|
:picture => category_xml.xpath('picture').children.inner_text,
|
24
24
|
:rating => category_xml.xpath('rating').children.inner_text.to_i
|
25
|
-
}
|
26
|
-
|
27
|
-
GetYourGuide::Models::TopCategory.new(category_attributes)
|
25
|
+
})
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
data/lib/getyourguide/version.rb
CHANGED
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GetYourGuide::Models::Activity do
|
4
|
+
subject(:category) {
|
5
|
+
GetYourGuide::Models::Category.new(
|
6
|
+
provider_id: 1,
|
7
|
+
name: 'Name'
|
8
|
+
)
|
9
|
+
}
|
10
|
+
subject(:location) {
|
11
|
+
GetYourGuide::Models::Location.new(
|
12
|
+
provider_id: 1,
|
13
|
+
name: 'Name',
|
14
|
+
country: 'Country',
|
15
|
+
start_location: false
|
16
|
+
)
|
17
|
+
}
|
18
|
+
subject(:image) {
|
19
|
+
GetYourGuide::Models::Image.new(
|
20
|
+
url: 'https://assets-cdn.github.com/images/modules/open_graph/github-mark.png',
|
21
|
+
ssl: true
|
22
|
+
)
|
23
|
+
}
|
24
|
+
subject(:activity) {
|
25
|
+
GetYourGuide::Models::Activity.new(
|
26
|
+
provider_id: 1,
|
27
|
+
title: 'Title',
|
28
|
+
abstract: 'Abstract description',
|
29
|
+
categories: [category],
|
30
|
+
locations: [location],
|
31
|
+
starting_point: true,
|
32
|
+
indivative_price: 100.50,
|
33
|
+
rating: 4.5,
|
34
|
+
pictures: [image]
|
35
|
+
)
|
36
|
+
}
|
37
|
+
|
38
|
+
it 'should be a GetYourGuide::Models::Activity object' do
|
39
|
+
expect(activity).to be_an_instance_of(GetYourGuide::Models::Activity)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should have a provider_id' do
|
43
|
+
expect(activity.provider_id).to eq(1)
|
44
|
+
expect(activity.provider_id).to be_an_instance_of(Fixnum)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should have a title' do
|
48
|
+
expect(activity.title).to eq('Title')
|
49
|
+
expect(activity.title).to be_an_instance_of(String)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should have a abstract description' do
|
53
|
+
expect(activity.abstract).to eq('Abstract description')
|
54
|
+
expect(activity.abstract).to be_an_instance_of(String)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should have a Boolean starting_point' do
|
58
|
+
expect(activity.starting_point).to eq(true).or eq(false)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should have a Float indivative_price' do
|
62
|
+
expect(activity.indivative_price).to be_an_instance_of(Float)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should have a Float rating' do
|
66
|
+
expect(activity.rating).to be_an_instance_of(Float)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should have an Array[GetYourGuide::Models::Category] as categories' do
|
70
|
+
expect(activity.categories).to be_an_instance_of(Array)
|
71
|
+
expect(activity.categories.first).to be_an_instance_of(GetYourGuide::Models::Category)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should have an Array[GetYourGuide::Models::Location] as locations' do
|
75
|
+
expect(activity.locations).to be_an_instance_of(Array)
|
76
|
+
expect(activity.locations.first).to be_an_instance_of(GetYourGuide::Models::Location)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should have an Array[GetYourGuide::Models::Image] as pictures' do
|
80
|
+
expect(activity.pictures).to be_an_instance_of(Array)
|
81
|
+
expect(activity.pictures.first).to be_an_instance_of(GetYourGuide::Models::Image)
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GetYourGuide::Models::Category do
|
4
|
+
subject(:category) {
|
5
|
+
GetYourGuide::Models::Category.new(
|
6
|
+
provider_id: 1,
|
7
|
+
name: 'Name'
|
8
|
+
)
|
9
|
+
}
|
10
|
+
|
11
|
+
it 'should be a GetYourGuide::Models::Category object' do
|
12
|
+
expect(category).to be_an_instance_of(GetYourGuide::Models::Category)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should have a provider_id' do
|
16
|
+
expect(category.provider_id).to eq(1)
|
17
|
+
expect(category.provider_id).to be_an_instance_of(Fixnum)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should have a name' do
|
21
|
+
expect(category.name).to eq('Name')
|
22
|
+
expect(category.name).to be_an_instance_of(String)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GetYourGuide::Models::Destination do
|
4
|
+
subject(:destination) {
|
5
|
+
GetYourGuide::Models::Destination.new(
|
6
|
+
provider_id: 1,
|
7
|
+
name: 'Name',
|
8
|
+
country: 'Country',
|
9
|
+
unlocode: 'FR',
|
10
|
+
iata: 'EUR',
|
11
|
+
destination_type: 'Destination Type'
|
12
|
+
)
|
13
|
+
}
|
14
|
+
subject(:destination_with_nil_attributes) {
|
15
|
+
GetYourGuide::Models::Destination.new(
|
16
|
+
provider_id: 1,
|
17
|
+
name: 'Name',
|
18
|
+
country: 'Country',
|
19
|
+
unlocode: nil,
|
20
|
+
iata: nil,
|
21
|
+
destination_type: 'Destination Type'
|
22
|
+
)
|
23
|
+
}
|
24
|
+
|
25
|
+
it 'should be a GetYourGuide::Models::Destination object' do
|
26
|
+
expect(destination).to be_an_instance_of(GetYourGuide::Models::Destination)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should have a provider_id' do
|
30
|
+
expect(destination.provider_id).to eq(1)
|
31
|
+
expect(destination.provider_id).to be_an_instance_of(Fixnum)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should have a name' do
|
35
|
+
expect(destination.name).to eq('Name')
|
36
|
+
expect(destination.name).to be_an_instance_of(String)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should have a country' do
|
40
|
+
expect(destination.country).to eq('Country')
|
41
|
+
expect(destination.country).to be_an_instance_of(String)
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'WITH iata and un/locode' do
|
45
|
+
it 'should have a not null iata' do
|
46
|
+
expect(destination.iata).to eq('EUR')
|
47
|
+
expect(destination.iata).to be_an_instance_of(String)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should have a not null un/locode' do
|
51
|
+
expect(destination.unlocode).to eq('FR')
|
52
|
+
expect(destination.unlocode).to be_an_instance_of(String)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'WITHOUT iata and un/locode' do
|
57
|
+
it 'should have a null iata' do
|
58
|
+
expect(destination_with_nil_attributes.iata).to be_nil
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should have a null un/locode' do
|
62
|
+
expect(destination_with_nil_attributes.unlocode).to be_nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should have a destination_type' do
|
67
|
+
expect(destination.destination_type).to eq('Destination Type')
|
68
|
+
expect(destination.destination_type).to be_an_instance_of(String)
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GetYourGuide::Models::ImageFormat do
|
4
|
+
subject(:image_format) {
|
5
|
+
GetYourGuide::Models::ImageFormat.new(
|
6
|
+
provider_id: 1,
|
7
|
+
width: 200,
|
8
|
+
height: 300,
|
9
|
+
comment: 'Comment'
|
10
|
+
)
|
11
|
+
}
|
12
|
+
|
13
|
+
it 'should be a GetYourGuide::Models::ImageFormat object' do
|
14
|
+
expect(image_format).to be_an_instance_of(GetYourGuide::Models::ImageFormat)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have a provider_id' do
|
18
|
+
expect(image_format.provider_id).to eq(1)
|
19
|
+
expect(image_format.provider_id).to be_an_instance_of(Fixnum)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should have a width' do
|
23
|
+
expect(image_format.width).to eq(200)
|
24
|
+
expect(image_format.width).to be_an_instance_of(Fixnum)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should have a height' do
|
28
|
+
expect(image_format.height).to eq(300)
|
29
|
+
expect(image_format.height).to be_an_instance_of(Fixnum)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should have a comment' do
|
33
|
+
expect(image_format.comment).to eq('Comment')
|
34
|
+
expect(image_format.comment).to be_an_instance_of(String)
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GetYourGuide::Models::Image do
|
4
|
+
subject(:image) {
|
5
|
+
GetYourGuide::Models::Image.new(
|
6
|
+
url: 'https://assets-cdn.github.com/images/modules/open_graph/github-mark.png',
|
7
|
+
ssl: true
|
8
|
+
)
|
9
|
+
}
|
10
|
+
|
11
|
+
it 'should be a GetYourGuide::Models::Image object' do
|
12
|
+
expect(image).to be_an_instance_of(GetYourGuide::Models::Image)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should have a String url' do
|
16
|
+
expect(image.url).to eq('https://assets-cdn.github.com/images/modules/open_graph/github-mark.png')
|
17
|
+
expect(image.url).to be_an_instance_of(String)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should have a Boolean ssl' do
|
21
|
+
expect(image.ssl).to eq(true).or eq(false)
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GetYourGuide::Models::Location do
|
4
|
+
subject(:location) {
|
5
|
+
GetYourGuide::Models::Location.new(
|
6
|
+
provider_id: 1,
|
7
|
+
name: 'Name',
|
8
|
+
country: 'Country',
|
9
|
+
start_location: true
|
10
|
+
)
|
11
|
+
}
|
12
|
+
|
13
|
+
it 'should be a GetYourGuide::Models::Location object' do
|
14
|
+
expect(location).to be_an_instance_of(GetYourGuide::Models::Location)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have a provider_id' do
|
18
|
+
expect(location.provider_id).to eq(1)
|
19
|
+
expect(location.provider_id).to be_an_instance_of(Fixnum)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should have a name' do
|
23
|
+
expect(location.name).to eq('Name')
|
24
|
+
expect(location.name).to be_an_instance_of(String)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should have a country' do
|
28
|
+
expect(location.country).to eq('Country')
|
29
|
+
expect(location.country).to be_an_instance_of(String)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should have a start_location' do
|
33
|
+
expect(location.start_location).to eq(true).or eq(false)
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GetYourGuide::Models::TopCategory do
|
4
|
+
subject(:top_category) {
|
5
|
+
GetYourGuide::Models::TopCategory.new(
|
6
|
+
provider_id: 1,
|
7
|
+
name: 'Name',
|
8
|
+
link: 'Link',
|
9
|
+
picture: 'Picture',
|
10
|
+
rating: 'Rating'
|
11
|
+
)
|
12
|
+
}
|
13
|
+
|
14
|
+
it 'should be a GetYourGuide::Models::TopCategory object' do
|
15
|
+
expect(top_category).to be_an_instance_of(GetYourGuide::Models::TopCategory)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have a provider_id' do
|
19
|
+
expect(top_category.provider_id).to eq(1)
|
20
|
+
expect(top_category.provider_id).to be_an_instance_of(Fixnum)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should have a name' do
|
24
|
+
expect(top_category.name).to eq('Name')
|
25
|
+
expect(top_category.name).to be_an_instance_of(String)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should have a link' do
|
29
|
+
expect(top_category.link).to eq('Link')
|
30
|
+
expect(top_category.link).to be_an_instance_of(String)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should have a picture' do
|
34
|
+
expect(top_category.picture).to eq('Picture')
|
35
|
+
expect(top_category.picture).to be_an_instance_of(String)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should have a rating' do
|
39
|
+
expect(top_category.rating).to eq('Rating')
|
40
|
+
expect(top_category.rating).to be_an_instance_of(String)
|
41
|
+
end
|
42
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: getyourguide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rémi Delhaye
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-02-
|
12
|
+
date: 2015-02-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -25,6 +25,26 @@ dependencies:
|
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.7'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: coveralls
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.7.8
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.7.8
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - "~>"
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 0.7.8
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.7.8
|
28
48
|
- !ruby/object:Gem::Dependency
|
29
49
|
name: rake
|
30
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,6 +59,26 @@ dependencies:
|
|
39
59
|
- - "~>"
|
40
60
|
- !ruby/object:Gem::Version
|
41
61
|
version: '10.0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.1'
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 3.1.0
|
72
|
+
type: :development
|
73
|
+
prerelease: false
|
74
|
+
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - "~>"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '3.1'
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 3.1.0
|
42
82
|
- !ruby/object:Gem::Dependency
|
43
83
|
name: nokogiri
|
44
84
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,8 +127,10 @@ executables: []
|
|
87
127
|
extensions: []
|
88
128
|
extra_rdoc_files: []
|
89
129
|
files:
|
130
|
+
- ".coveralls.yml"
|
90
131
|
- ".gitignore"
|
91
|
-
- ".
|
132
|
+
- ".rspec"
|
133
|
+
- ".travis.yml"
|
92
134
|
- Gemfile
|
93
135
|
- LICENSE.txt
|
94
136
|
- README.md
|
@@ -97,13 +139,7 @@ files:
|
|
97
139
|
- lib/getyourguide.rb
|
98
140
|
- lib/getyourguide/api_client.rb
|
99
141
|
- lib/getyourguide/errors/api_error.rb
|
100
|
-
- lib/getyourguide/models/
|
101
|
-
- lib/getyourguide/models/category.rb
|
102
|
-
- lib/getyourguide/models/destination.rb
|
103
|
-
- lib/getyourguide/models/image.rb
|
104
|
-
- lib/getyourguide/models/image_format.rb
|
105
|
-
- lib/getyourguide/models/location.rb
|
106
|
-
- lib/getyourguide/models/top_category.rb
|
142
|
+
- lib/getyourguide/models/generator.rb
|
107
143
|
- lib/getyourguide/parsers/categories.rb
|
108
144
|
- lib/getyourguide/parsers/default.rb
|
109
145
|
- lib/getyourguide/parsers/destinations.rb
|
@@ -111,6 +147,14 @@ files:
|
|
111
147
|
- lib/getyourguide/parsers/products.rb
|
112
148
|
- lib/getyourguide/parsers/top_categories.rb
|
113
149
|
- lib/getyourguide/version.rb
|
150
|
+
- spec/getyourguide/models/activity_spec.rb
|
151
|
+
- spec/getyourguide/models/category_spec.rb
|
152
|
+
- spec/getyourguide/models/destination_spec.rb
|
153
|
+
- spec/getyourguide/models/image_format_spec.rb
|
154
|
+
- spec/getyourguide/models/image_spec.rb
|
155
|
+
- spec/getyourguide/models/location_spec.rb
|
156
|
+
- spec/getyourguide/models/top_category_spec.rb
|
157
|
+
- spec/spec_helper.rb
|
114
158
|
homepage: https://github.com/Libertrip/getyourguide
|
115
159
|
licenses:
|
116
160
|
- MIT
|
@@ -136,4 +180,12 @@ rubygems_version: 2.2.2
|
|
136
180
|
signing_key:
|
137
181
|
specification_version: 4
|
138
182
|
summary: A simple ruby on rails client for GetYourGuide partner XML API
|
139
|
-
test_files:
|
183
|
+
test_files:
|
184
|
+
- spec/getyourguide/models/activity_spec.rb
|
185
|
+
- spec/getyourguide/models/category_spec.rb
|
186
|
+
- spec/getyourguide/models/destination_spec.rb
|
187
|
+
- spec/getyourguide/models/image_format_spec.rb
|
188
|
+
- spec/getyourguide/models/image_spec.rb
|
189
|
+
- spec/getyourguide/models/location_spec.rb
|
190
|
+
- spec/getyourguide/models/top_category_spec.rb
|
191
|
+
- spec/spec_helper.rb
|
data/.rvmrc.01.29.2015-18:48:37
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
-
# development environment upon cd'ing into the directory
|
5
|
-
|
6
|
-
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
-
# Only full ruby name is supported here, for short names use:
|
8
|
-
# echo "rvm use 2.1.4@getyourguide" > .rvmrc
|
9
|
-
environment_id="ruby-2.1.4@getyourguide"
|
10
|
-
|
11
|
-
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
-
# rvmrc_rvm_version="1.25.33 (stable)" # 1.10.1 seems like a safe start
|
13
|
-
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | __rvm_awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
-
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
-
# return 1
|
16
|
-
# }
|
17
|
-
|
18
|
-
# First we attempt to load the desired environment directly from the environment
|
19
|
-
# file. This is very fast and efficient compared to running through the entire
|
20
|
-
# CLI and selector. If you want feedback on which environment was used then
|
21
|
-
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
-
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
-
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
-
then
|
25
|
-
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
-
for __hook in "${rvm_path:-$HOME/.rvm}/hooks/after_use"*
|
27
|
-
do
|
28
|
-
if [[ -f "${__hook}" && -x "${__hook}" && -s "${__hook}" ]]
|
29
|
-
then \. "${__hook}" || true
|
30
|
-
fi
|
31
|
-
done
|
32
|
-
unset __hook
|
33
|
-
if (( ${rvm_use_flag:=1} >= 1 )) # display automatically
|
34
|
-
then
|
35
|
-
if [[ $- == *i* ]] # check for interactive shells
|
36
|
-
then printf "%b" "Using: $(tput setaf 2 2>/dev/null)$GEM_HOME$(tput sgr0 2>/dev/null)
|
37
|
-
" # show the user the ruby and gemset they are using in green
|
38
|
-
else printf "%b" "Using: $GEM_HOME
|
39
|
-
" # don't use colors in non-interactive shells
|
40
|
-
fi
|
41
|
-
fi
|
42
|
-
else
|
43
|
-
# If the environment file has not yet been created, use the RVM CLI to select.
|
44
|
-
rvm --create use "$environment_id" || {
|
45
|
-
echo "Failed to create RVM environment '${environment_id}'."
|
46
|
-
return 1
|
47
|
-
}
|
48
|
-
fi
|
49
|
-
|
50
|
-
# If you use bundler, this might be useful to you:
|
51
|
-
# if [[ -s Gemfile ]] && {
|
52
|
-
# ! builtin command -v bundle >/dev/null ||
|
53
|
-
# builtin command -v bundle | GREP_OPTIONS=""
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module GetYourGuide
|
2
|
-
module Models
|
3
|
-
class Activity
|
4
|
-
attr_accessor :provider_id, :title, :abstract, :categories, :locations, :starting_point, :indivative_price, :rating, :pictures
|
5
|
-
|
6
|
-
def initialize(attributes)
|
7
|
-
@provider_id = attributes[:provider_id]
|
8
|
-
@title = attributes[:title]
|
9
|
-
@abstract = attributes[:abstract]
|
10
|
-
@categories = attributes[:categories]
|
11
|
-
@locations = attributes[:locations]
|
12
|
-
@starting_point = attributes[:starting_point]
|
13
|
-
@indivative_price = attributes[:indivative_price]
|
14
|
-
@rating = attributes[:rating]
|
15
|
-
@pictures = attributes[:pictures]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module GetYourGuide
|
2
|
-
module Models
|
3
|
-
class Destination
|
4
|
-
attr_accessor :provider_id, :name, :country, :unlocode, :iata, :destination_type
|
5
|
-
|
6
|
-
def initialize(attributes)
|
7
|
-
@provider_id = attributes[:provider_id]
|
8
|
-
@name = attributes[:name]
|
9
|
-
@country = attributes[:country]
|
10
|
-
@unlocode = attributes[:unlocode]
|
11
|
-
@iata = attributes[:iata]
|
12
|
-
@destination_type = attributes[:destination_type]
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module GetYourGuide
|
2
|
-
module Models
|
3
|
-
class ImageFormat
|
4
|
-
attr_accessor :provider_id, :width, :height, :comment
|
5
|
-
|
6
|
-
def initialize(attributes)
|
7
|
-
@provider_id = attributes[:provider_id]
|
8
|
-
@width = attributes[:width]
|
9
|
-
@height = attributes[:height]
|
10
|
-
@comment = attributes[:comment]
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module GetYourGuide
|
2
|
-
module Models
|
3
|
-
class Location
|
4
|
-
attr_accessor :provider_id, :name, :country, :start_location
|
5
|
-
|
6
|
-
def initialize(attributes)
|
7
|
-
@provider_id = attributes[:provider_id]
|
8
|
-
@name = attributes[:name]
|
9
|
-
@country = attributes[:country]
|
10
|
-
@start_location = attributes[:start_location]
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module GetYourGuide
|
2
|
-
module Models
|
3
|
-
class TopCategory
|
4
|
-
attr_accessor :provider_id, :name, :link, :picture, :rating
|
5
|
-
|
6
|
-
def initialize(attributes)
|
7
|
-
@provider_id = attributes[:provider_id]
|
8
|
-
@name = attributes[:name]
|
9
|
-
@link = attributes[:link]
|
10
|
-
@picture = attributes[:picture]
|
11
|
-
@rating = attributes[:rating]
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|