nl_gas_stations 0.1.0
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 +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +15 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +79 -0
- data/Rakefile +2 -0
- data/lib/nl_gas_stations.rb +28 -0
- data/lib/nl_gas_stations/configuration.rb +23 -0
- data/lib/nl_gas_stations/gas_stations.rb +25 -0
- data/lib/nl_gas_stations/parser.rb +105 -0
- data/lib/nl_gas_stations/scraper.rb +48 -0
- data/lib/nl_gas_stations/version.rb +3 -0
- data/nl_gas_stations.gemspec +28 -0
- data/spec/fixtures/afstand_10_brandstof_Diesel_plaats_postcode_9983_zoeken_Zoeken.yml +1447 -0
- data/spec/fixtures/afstand_10_brandstof_Euro_2095_plaats_postcode_9983_zoeken_Zoeken.yml +1432 -0
- data/spec/fixtures/afstand_5_brandstof_LPG_plaats_postcode_9983_zoeken_Zoeken.yml +1393 -0
- data/spec/gas_stations_spec.rb +69 -0
- data/spec/spec_helper.rb +27 -0
- metadata +181 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe NlGasStations::GasStations do
|
5
|
+
|
6
|
+
|
7
|
+
after :each do
|
8
|
+
NlGasStations.reset
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'cache testing' do
|
12
|
+
before {
|
13
|
+
NlGasStations.configure do |config|
|
14
|
+
config.cache = ActiveSupport::Cache::NullStore.new
|
15
|
+
end
|
16
|
+
}
|
17
|
+
|
18
|
+
context 'check if cache exists' do
|
19
|
+
subject(:cache) { NlGasStations.configuration.cache }
|
20
|
+
|
21
|
+
it 'must not be nill' do
|
22
|
+
expect(cache).to be_a ActiveSupport::Cache::Store
|
23
|
+
expect(cache).to_not be nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'check funtionality with cache' do
|
28
|
+
subject(:stations) { described_class.find_stations('9983', :euro_95, 10) }
|
29
|
+
|
30
|
+
it 'should find data' do
|
31
|
+
station_2 = stations[1]
|
32
|
+
puts stations
|
33
|
+
expect(station_2[:gas_station][:city]).to eq 'EEMSHAVEN'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
describe 'find gas stations' do
|
41
|
+
|
42
|
+
context 'search by short distance' do
|
43
|
+
subject(:stations) { described_class.find_stations('9983', :lpg, 5) }
|
44
|
+
|
45
|
+
it 'should return no results' do
|
46
|
+
expect(stations).to eq []
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'search by a valid postal code and distance' do
|
51
|
+
subject(:stations) { described_class.find_stations('9983', :diesel, 10) }
|
52
|
+
|
53
|
+
it 'should find data' do
|
54
|
+
puts stations
|
55
|
+
station_1 = stations[0]
|
56
|
+
expect(station_1[:gas_station][:name]).to eq 'Texaco Eemshaven'
|
57
|
+
expect(station_1[:gas_station][:street_address]).to eq 'Schildweg 4a'
|
58
|
+
expect(station_1[:gas_station][:postal_code]).to eq '9979XR'
|
59
|
+
expect(station_1[:gas_station][:city]).to eq 'EEMSHAVEN'
|
60
|
+
expect(station_1[:fuel_type]).to eq :diesel
|
61
|
+
expect(station_1[:price]).to eq 1.239
|
62
|
+
expect(station_1[:date]).to eq Date.new(2015, 2, 11)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear!
|
3
|
+
|
4
|
+
require 'active_support/all'
|
5
|
+
require 'vcr'
|
6
|
+
|
7
|
+
Dir.glob(File.join(Dir.pwd, '/lib/*.rb')).each do |file|
|
8
|
+
require file
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
VCR.configure do |c|
|
13
|
+
c.cassette_library_dir = 'spec/fixtures'
|
14
|
+
c.hook_into :webmock
|
15
|
+
# c.debug_logger = $stdout
|
16
|
+
|
17
|
+
c.around_http_request do |request|
|
18
|
+
uri = URI(request.uri)
|
19
|
+
name = uri.query
|
20
|
+
VCR.use_cassette(name, &request)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
RSpec.configure do |config|
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nl_gas_stations
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Arjan Frans
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activesupport
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: coveralls
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description:
|
126
|
+
email:
|
127
|
+
- arjanfrans.nl@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".coveralls.yml"
|
133
|
+
- ".gitignore"
|
134
|
+
- ".idea/scopes/scope_settings.xml"
|
135
|
+
- ".travis.yml"
|
136
|
+
- Gemfile
|
137
|
+
- LICENSE.txt
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- lib/nl_gas_stations.rb
|
141
|
+
- lib/nl_gas_stations/configuration.rb
|
142
|
+
- lib/nl_gas_stations/gas_stations.rb
|
143
|
+
- lib/nl_gas_stations/parser.rb
|
144
|
+
- lib/nl_gas_stations/scraper.rb
|
145
|
+
- lib/nl_gas_stations/version.rb
|
146
|
+
- nl_gas_stations.gemspec
|
147
|
+
- spec/fixtures/afstand_10_brandstof_Diesel_plaats_postcode_9983_zoeken_Zoeken.yml
|
148
|
+
- spec/fixtures/afstand_10_brandstof_Euro_2095_plaats_postcode_9983_zoeken_Zoeken.yml
|
149
|
+
- spec/fixtures/afstand_5_brandstof_LPG_plaats_postcode_9983_zoeken_Zoeken.yml
|
150
|
+
- spec/gas_stations_spec.rb
|
151
|
+
- spec/spec_helper.rb
|
152
|
+
homepage: https://github.com/ArjanFrans/nl-gas-stations
|
153
|
+
licenses:
|
154
|
+
- MIT
|
155
|
+
metadata: {}
|
156
|
+
post_install_message:
|
157
|
+
rdoc_options: []
|
158
|
+
require_paths:
|
159
|
+
- lib
|
160
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
requirements: []
|
171
|
+
rubyforge_project:
|
172
|
+
rubygems_version: 2.4.4
|
173
|
+
signing_key:
|
174
|
+
specification_version: 4
|
175
|
+
summary: Get the prices of gas stations in The Netherlands.
|
176
|
+
test_files:
|
177
|
+
- spec/fixtures/afstand_10_brandstof_Diesel_plaats_postcode_9983_zoeken_Zoeken.yml
|
178
|
+
- spec/fixtures/afstand_10_brandstof_Euro_2095_plaats_postcode_9983_zoeken_Zoeken.yml
|
179
|
+
- spec/fixtures/afstand_5_brandstof_LPG_plaats_postcode_9983_zoeken_Zoeken.yml
|
180
|
+
- spec/gas_stations_spec.rb
|
181
|
+
- spec/spec_helper.rb
|