spritpreisrechner 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +77 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/spritpreisrechner.rb +34 -0
- data/lib/spritpreisrechner/contact.rb +13 -0
- data/lib/spritpreisrechner/location.rb +14 -0
- data/lib/spritpreisrechner/offer_information.rb +24 -0
- data/lib/spritpreisrechner/opening_hour.rb +13 -0
- data/lib/spritpreisrechner/payment_arrangement.rb +19 -0
- data/lib/spritpreisrechner/payment_method.rb +25 -0
- data/lib/spritpreisrechner/price.rb +12 -0
- data/lib/spritpreisrechner/region.rb +40 -0
- data/lib/spritpreisrechner/response.rb +31 -0
- data/lib/spritpreisrechner/station.rb +81 -0
- data/lib/spritpreisrechner/version.rb +3 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/spritpreisrechner_spec.rb +61 -0
- data/spritpreisrechner.gemspec +27 -0
- metadata +138 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a7af3c68304a0e3b069e1d761e9e98771fa7c60ea803ee1af8f6a368b244900e
|
4
|
+
data.tar.gz: 8179c5dc05dde1098c4fab8c2811dd70f0f116e29a52384bdff813379f86a37f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0cffc76792aa63fc2db499d66fa5f0290f8753d7a532973710ef7c83698ac3749f876663ed915cf74c9bd624b1ddf9edcae3459ef305bddc2396f604a532e8ce
|
7
|
+
data.tar.gz: 18fcfd66436229b45f0fa1aecf5b26f3004a7b96d9db0c315b114ea67563331a65f01bf718ccaac1c8bb658d84f8b13ea28e215b78243d0a396e65c7bc431fb6
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Marco Roth
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# Spritpreisrechner
|
2
|
+
![](https://api.travis-ci.com/marcoroth/spritpreisrechner-ruby.svg?branch=master)
|
3
|
+
|
4
|
+
This is a Ruby Wrapper for the [e-Control.at Spritpreisrechner HTTP API](https://www.spritpreisrechner.at). Have a look at the [Swagger docs](https://api.e-control.at/sprit/1.0/doc/index.html?url=https://api.e-control.at/sprit/1.0/api-docs%3Fgroup%3Dpublic-api) for detailed info about the API.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'spritpreisrechner'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install spritpreisrechner
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Getting stations by LAT/LNG coordinates. The available Fuel Types are: `DIE` , `SUP` and `GAS`. The `closed` parameter is optional.
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
response = Spritpreisrechner::Station.by_address(lat: 48.208, lng: 16.373, fuel_type: 'DIE', closed: 'true')
|
28
|
+
# => #<Spritpreisrechner::Response @stations=[#<Spritpreisrechner::Station @id=692206, @name="SPRIT-INN" ...>, #<Spritpreisrechner::Station @id=5093, @name="Turmöl" ...>, ... ] ... >
|
29
|
+
|
30
|
+
```
|
31
|
+
|
32
|
+
Getting stations by region:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
response = Spritpreisrechner::Station.by_region(code: 1, region_type: "BL", fuel_type: 'DIE', closed: 'true')
|
36
|
+
# => #<Spritpreisrechner::Response @stations=[#<Spritpreisrechner::Station @id=394, @name="Avanti" ...>, #<Spritpreisrechner::Station @id=7586, @name="Landestankstelle Rdf. Partner Luisser" ...>, ... ] ... >
|
37
|
+
|
38
|
+
```
|
39
|
+
|
40
|
+
|
41
|
+
Getting all available regions:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
regions = Spritpreisrechner::Region.all
|
45
|
+
# => [#<Sprtpreisrechner::Region @code=1, @type="BL", @name="Burgenland" ...>, #<Spritpreisrechner::Region @code=2, @type="BL", @name="Kärnten" ...> ...]
|
46
|
+
```
|
47
|
+
|
48
|
+
Getting a specific region:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
region = Spritpreisrechner::Region.find(1)
|
52
|
+
# => #<Sprtpreisrechner::Region @code=1, @type="BL", @name="Burgenland" ...>
|
53
|
+
```
|
54
|
+
|
55
|
+
|
56
|
+
## Development
|
57
|
+
|
58
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
59
|
+
|
60
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
61
|
+
|
62
|
+
## Contributing
|
63
|
+
|
64
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/marcoroth/spritpreisrechner.
|
65
|
+
|
66
|
+
## License
|
67
|
+
|
68
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
69
|
+
|
70
|
+
## More Information
|
71
|
+
|
72
|
+
[Spritpreisrechner Website](https://www.spritpreisrechner.at/)
|
73
|
+
|
74
|
+
[RubyGems](https://rubygems.org/gems/spritpreisrechner)
|
75
|
+
|
76
|
+
[Source Code](https://github.com/marcoroth/spritpreisrechner-ruby)
|
77
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "spritpreisrechner"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
require 'spritpreisrechner/version'
|
5
|
+
require 'spritpreisrechner/contact'
|
6
|
+
require 'spritpreisrechner/location'
|
7
|
+
require 'spritpreisrechner/offer_information'
|
8
|
+
require 'spritpreisrechner/opening_hour'
|
9
|
+
require 'spritpreisrechner/payment_arrangement'
|
10
|
+
require 'spritpreisrechner/payment_method'
|
11
|
+
require 'spritpreisrechner/price'
|
12
|
+
require 'spritpreisrechner/region'
|
13
|
+
require 'spritpreisrechner/response'
|
14
|
+
require 'spritpreisrechner/station'
|
15
|
+
|
16
|
+
module Spritpreisrechner
|
17
|
+
@api_base = 'https://api.e-control.at/sprit/1.0/'
|
18
|
+
|
19
|
+
class << self
|
20
|
+
attr_accessor :api_base
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.conn
|
24
|
+
if defined?(@conn)
|
25
|
+
@conn
|
26
|
+
else
|
27
|
+
@conn = Faraday.new(@api_base)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.conn=(conn)
|
32
|
+
@conn = conn
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Spritpreisrechner
|
2
|
+
class Location
|
3
|
+
attr_reader :address, :postal_code, :city, :longitude, :latitude
|
4
|
+
|
5
|
+
def initialize(location)
|
6
|
+
@address = location[:address]
|
7
|
+
@postal_code = location[:postalCode]
|
8
|
+
@city = location[:city]
|
9
|
+
@longitude = location[:longitude]
|
10
|
+
@latitude = location[:latitude]
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Spritpreisrechner
|
2
|
+
class OfferInformation
|
3
|
+
attr_reader :service, :self_service, :unattended
|
4
|
+
|
5
|
+
def initialize(offer_information)
|
6
|
+
@service = offer_information[:service]
|
7
|
+
@self_service = offer_information[:selfService]
|
8
|
+
@unattended = offer_information[:unattended]
|
9
|
+
end
|
10
|
+
|
11
|
+
def service?
|
12
|
+
@service == true
|
13
|
+
end
|
14
|
+
|
15
|
+
def self_service?
|
16
|
+
@self_service == true
|
17
|
+
end
|
18
|
+
|
19
|
+
def unattended?
|
20
|
+
@unattended == true
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Spritpreisrechner
|
2
|
+
class OpeningHour
|
3
|
+
attr_reader :day, :label, :order, :from, :to
|
4
|
+
|
5
|
+
def initialize(opening_hour)
|
6
|
+
@day = opening_hour[:day]
|
7
|
+
@label = opening_hour[:label]
|
8
|
+
@order = opening_hour[:order]
|
9
|
+
@from = opening_hour[:from]
|
10
|
+
@to = opening_hour[:to]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Spritpreisrechner
|
2
|
+
class PaymentArrengement
|
3
|
+
attr_reader :cooperative, :club_card
|
4
|
+
|
5
|
+
def initialize(payment_arrengement)
|
6
|
+
@cooperative = payment_arrengement[:cooperative]
|
7
|
+
@club_card = payment_arrengement[:clubCard]
|
8
|
+
end
|
9
|
+
|
10
|
+
def cooperative?
|
11
|
+
@cooperative == true
|
12
|
+
end
|
13
|
+
|
14
|
+
def club_card?
|
15
|
+
@club_card == true
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Spritpreisrechner
|
2
|
+
class PaymentMethod
|
3
|
+
attr_reader :cash, :debit_card, :credit_card, :others
|
4
|
+
|
5
|
+
def initialize(payment_method)
|
6
|
+
@cash = payment_method[:cash]
|
7
|
+
@debit_card = payment_method[:debitCard]
|
8
|
+
@credit_card = payment_method[:creditCard]
|
9
|
+
@others = payment_method[:others]&.split(', ')
|
10
|
+
end
|
11
|
+
|
12
|
+
def cash?
|
13
|
+
@cash == true
|
14
|
+
end
|
15
|
+
|
16
|
+
def debit_card?
|
17
|
+
@debit_card == true
|
18
|
+
end
|
19
|
+
|
20
|
+
def credit_card?
|
21
|
+
@debit_card == true
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Spritpreisrechner
|
2
|
+
class Region
|
3
|
+
attr_reader :code, :type, :name, :sub_regions, :postal_codes
|
4
|
+
|
5
|
+
def initialize(region)
|
6
|
+
@code = region[:code]
|
7
|
+
@type = region[:type]
|
8
|
+
@name = region[:name]
|
9
|
+
@sub_regions = []
|
10
|
+
|
11
|
+
region[:subRegions].each do |sub_region|
|
12
|
+
@sub_regions << Region.new(sub_region)
|
13
|
+
end
|
14
|
+
|
15
|
+
@postal_codes = region[:postalCodes]
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.all
|
19
|
+
response = conn.get('regions')
|
20
|
+
attributes = JSON.parse(response.body, symbolize_names: true)
|
21
|
+
|
22
|
+
regions = []
|
23
|
+
|
24
|
+
attributes.each do |region|
|
25
|
+
regions << Region.new(region)
|
26
|
+
end
|
27
|
+
|
28
|
+
regions
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.find(code)
|
32
|
+
all.select { |r| r.code == code }.first
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.conn
|
36
|
+
Spritpreisrechner.conn
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Spritpreisrechner
|
2
|
+
class Response
|
3
|
+
attr_reader :uuid, :errors, :code, :name
|
4
|
+
attr_accessor :stations
|
5
|
+
|
6
|
+
def initialize(response)
|
7
|
+
@uuid = response[:uuid] rescue nil
|
8
|
+
@errors = response[:errors] rescue []
|
9
|
+
@code = response[:code] rescue nil
|
10
|
+
@name = response[:name] rescue nil
|
11
|
+
@stations = []
|
12
|
+
end
|
13
|
+
|
14
|
+
def success?
|
15
|
+
@errors.empty?
|
16
|
+
end
|
17
|
+
|
18
|
+
def error?
|
19
|
+
@errors.any?
|
20
|
+
end
|
21
|
+
|
22
|
+
def any?
|
23
|
+
@stations.any?
|
24
|
+
end
|
25
|
+
|
26
|
+
def count
|
27
|
+
@stations.count
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module Spritpreisrechner
|
2
|
+
class Station
|
3
|
+
attr_reader :id, :name, :other_service_offers, :position, :open, :distance
|
4
|
+
attr_reader :location, :contact, :opening_hours, :offer_information, :payment_methods, :payment_arrangements, :prices
|
5
|
+
|
6
|
+
FUEL_TYPES = %w[DIE SUP GAS].freeze
|
7
|
+
REGION_TYPES = %w[BL PB].freeze
|
8
|
+
|
9
|
+
def initialize(station)
|
10
|
+
@id = station[:id]
|
11
|
+
@name = station[:name]
|
12
|
+
@location = Location.new(station[:location])
|
13
|
+
@contact = Contact.new(station[:contact])
|
14
|
+
@opening_hours = []
|
15
|
+
@offer_information = OfferInformation.new(station[:offerInformation])
|
16
|
+
@payment_methods = PaymentMethod.new(station[:paymentMethods])
|
17
|
+
@payment_arrangements = PaymentArrengement.new(station[:paymentArrangements])
|
18
|
+
@other_service_offers = station[:otherServiceOffers]&.split(', ')
|
19
|
+
@position = station[:position].to_i
|
20
|
+
@open = station[:open]
|
21
|
+
@distance = station[:distance].to_f
|
22
|
+
@prices = []
|
23
|
+
|
24
|
+
station[:openingHours].each do |opening_hour|
|
25
|
+
@opening_hours << OpeningHour.new(opening_hour)
|
26
|
+
end
|
27
|
+
|
28
|
+
station[:prices].each do |price|
|
29
|
+
@prices << Price.new(price)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def self.by_address(lat: nil, lng: nil, fuel_type: 'DIE', closed: 'true')
|
35
|
+
errors = []
|
36
|
+
errors << 'you need to submit a valid latitude coordinate' if lat.nil?
|
37
|
+
errors << 'you need to submit a valid longitude coordinate' if lng.nil?
|
38
|
+
errors << "you need to submit a valid Fuel Type. The options are #{FUEL_TYPES}" if fuel_type.nil? || !FUEL_TYPES.include?(fuel_type)
|
39
|
+
return Response.new(errors: errors) if errors.any?
|
40
|
+
|
41
|
+
response = conn.get('search/gas-stations/by-address', latitude: lat, longitude: lng, fuelType: fuel_type, includeClosed: closed)
|
42
|
+
attributes = JSON.parse(response.body, symbolize_names: true)
|
43
|
+
response = Response.new(attributes)
|
44
|
+
response.stations = []
|
45
|
+
|
46
|
+
if response.success?
|
47
|
+
attributes.each do |station|
|
48
|
+
response.stations << Station.new(station)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
response
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.by_region(code: nil, region_type: nil, fuel_type: 'DIE', closed: 'true')
|
56
|
+
errors = []
|
57
|
+
errors << 'you need to submit a valid region code' if code.nil?
|
58
|
+
errors << "you need to submit a valid region type. The options are #{REGION_TYPES}" if region_type.nil? || !REGION_TYPES.include?(region_type)
|
59
|
+
errors << "you need to submit a valid Fuel Type. The options are #{FUEL_TYPES}" if fuel_type.nil? || !FUEL_TYPES.include?(fuel_type)
|
60
|
+
return Response.new(errors: errors) if errors.any?
|
61
|
+
|
62
|
+
response = conn.get('search/gas-stations/by-region', code: code, type: region_type, fuelType: fuel_type, includeClosed: closed)
|
63
|
+
attributes = JSON.parse(response.body, symbolize_names: true)
|
64
|
+
response = Response.new(attributes)
|
65
|
+
response.stations = []
|
66
|
+
|
67
|
+
if response.success?
|
68
|
+
attributes.each do |station|
|
69
|
+
response.stations << Station.new(station)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
response
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.conn
|
77
|
+
Spritpreisrechner.conn
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require "spritpreisrechner"
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
# Enable flags like --only-failures and --next-failure
|
6
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
7
|
+
|
8
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
9
|
+
config.disable_monkey_patching!
|
10
|
+
|
11
|
+
config.expect_with :rspec do |c|
|
12
|
+
c.syntax = :expect
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
RSpec.describe Spritpreisrechner do
|
2
|
+
it 'has a version number' do
|
3
|
+
expect(Spritpreisrechner::VERSION).not_to be nil
|
4
|
+
end
|
5
|
+
|
6
|
+
it 'returns stations by_address' do
|
7
|
+
lat = 48.2081743
|
8
|
+
lng = 16.37381890000006
|
9
|
+
stations = Spritpreisrechner::Station.by_address(lat: lat, lng: lng, fuel_type: 'DIE')
|
10
|
+
expect(stations.any?).to eq(true)
|
11
|
+
stations = Spritpreisrechner::Station.by_address(lat: lat, lng: lng, fuel_type: 'SUP')
|
12
|
+
expect(stations.any?).to eq(true)
|
13
|
+
stations = Spritpreisrechner::Station.by_address(lat: lat, lng: lng, fuel_type: 'GAS')
|
14
|
+
expect(stations.any?).to eq(true)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'returns stations by_region' do
|
18
|
+
code = 1
|
19
|
+
region_type = 'BL'
|
20
|
+
stations = Spritpreisrechner::Station.by_region(code: code, region_type: region_type, fuel_type: 'DIE')
|
21
|
+
expect(stations.any?).to eq(true)
|
22
|
+
stations = Spritpreisrechner::Station.by_region(code: code, region_type: region_type, fuel_type: 'SUP')
|
23
|
+
expect(stations.any?).to eq(true)
|
24
|
+
stations = Spritpreisrechner::Station.by_region(code: code, region_type: region_type, fuel_type: 'GAS')
|
25
|
+
expect(stations.any?).to eq(true)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns coordinate errors from Station#by_address' do
|
29
|
+
lat = nil
|
30
|
+
lng = nil
|
31
|
+
fuel_type = 'DIE'
|
32
|
+
stations = Spritpreisrechner::Station.by_address(lat: lat, lng: lng, fuel_type: fuel_type)
|
33
|
+
expect(stations.any?).to eq(false)
|
34
|
+
expect(stations.errors[0]).to eq('you need to submit a valid latitude coordinate')
|
35
|
+
expect(stations.errors[1]).to eq('you need to submit a valid longitude coordinate')
|
36
|
+
expect(stations.errors.count).to eq(2)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns parameter errors from Station#by_region' do
|
40
|
+
code = nil
|
41
|
+
region_type = nil
|
42
|
+
fuel_type = 'DIE'
|
43
|
+
stations = Spritpreisrechner::Station.by_region(code: code, region_type: region_type, fuel_type: fuel_type)
|
44
|
+
expect(stations.any?).to eq(false)
|
45
|
+
expect(stations.errors[0]).to eq('you need to submit a valid region code')
|
46
|
+
expect(stations.errors[1]).to eq('you need to submit a valid region type. The options are ["BL", "PB"]')
|
47
|
+
expect(stations.errors.count).to eq(2)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'returns regions' do
|
51
|
+
regions = Spritpreisrechner::Region.all
|
52
|
+
expect(regions.any?).to eq(true)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'finds a region by id' do
|
56
|
+
region = Spritpreisrechner::Region.find(1)
|
57
|
+
expect(region.nil?).to eq(false)
|
58
|
+
expect(region.code).to eq(1)
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "spritpreisrechner/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "spritpreisrechner"
|
7
|
+
spec.version = Spritpreisrechner::VERSION
|
8
|
+
spec.authors = ["Marco Roth"]
|
9
|
+
spec.email = ["marco.roth@intergga.ch"]
|
10
|
+
|
11
|
+
spec.summary = "Ruby Wrapper for the e-control.at Spritpreisrechner HTTP API"
|
12
|
+
spec.description = "Ruby Wrapper for the e-control.at Spritpreisrechner HTTP API"
|
13
|
+
spec.homepage = "https://github.com/marcoroth/spritpreisrechner-ruby"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split("\n")
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
|
25
|
+
spec.add_dependency "faraday"
|
26
|
+
spec.add_dependency "json"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spritpreisrechner
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marco Roth
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-11-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: faraday
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
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: json
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Ruby Wrapper for the e-control.at Spritpreisrechner HTTP API
|
84
|
+
email:
|
85
|
+
- marco.roth@intergga.ch
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- bin/console
|
98
|
+
- bin/setup
|
99
|
+
- lib/spritpreisrechner.rb
|
100
|
+
- lib/spritpreisrechner/contact.rb
|
101
|
+
- lib/spritpreisrechner/location.rb
|
102
|
+
- lib/spritpreisrechner/offer_information.rb
|
103
|
+
- lib/spritpreisrechner/opening_hour.rb
|
104
|
+
- lib/spritpreisrechner/payment_arrangement.rb
|
105
|
+
- lib/spritpreisrechner/payment_method.rb
|
106
|
+
- lib/spritpreisrechner/price.rb
|
107
|
+
- lib/spritpreisrechner/region.rb
|
108
|
+
- lib/spritpreisrechner/response.rb
|
109
|
+
- lib/spritpreisrechner/station.rb
|
110
|
+
- lib/spritpreisrechner/version.rb
|
111
|
+
- spec/spec_helper.rb
|
112
|
+
- spec/spritpreisrechner_spec.rb
|
113
|
+
- spritpreisrechner.gemspec
|
114
|
+
homepage: https://github.com/marcoroth/spritpreisrechner-ruby
|
115
|
+
licenses:
|
116
|
+
- MIT
|
117
|
+
metadata: {}
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
requirements: []
|
133
|
+
rubyforge_project:
|
134
|
+
rubygems_version: 2.7.3
|
135
|
+
signing_key:
|
136
|
+
specification_version: 4
|
137
|
+
summary: Ruby Wrapper for the e-control.at Spritpreisrechner HTTP API
|
138
|
+
test_files: []
|