mygasfeed 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mygasfeed.rb +1 -0
- data/lib/mygasfeed/version.rb +1 -1
- data/mygasfeed.gemspec +4 -6
- data/spec/dsl/get_address_spec.rb +19 -0
- data/spec/dsl/get_brands.rb +17 -0
- data/spec/dsl/get_close_by_spec.rb +23 -0
- data/spec/dsl/get_details_spec.rb +18 -0
- data/spec/dsl/get_history_spec.rb +18 -0
- data/spec/dsl/get_stations_spec.rb +25 -0
- data/spec/dsl/update_price_spec.rb +20 -0
- data/spec/mygasfeed_spec.rb +7 -0
- data/spec/resources/brand_spec.rb +22 -0
- data/spec/resources/location_spec.rb +39 -0
- data/spec/resources/previous_price_spec.rb +26 -0
- data/spec/resources/station_spec.rb +55 -0
- data/spec/spec_helper.rb +10 -0
- metadata +32 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34935e6c17e6f39bb4ee14ea1fd03d63ec634425
|
4
|
+
data.tar.gz: b96161c0ddd8047c82349770ebe1ba03cf906aa5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7429a66ec7e566f9d3e28ce75881499486b772e4806a92e2d5063402de0ba378325e5bd5afcff34e4951a27d94ea9183316249b63a2ec4899139bbf7afd40b1
|
7
|
+
data.tar.gz: 039d92cd26039ba08298a498f0bca2999cca5cfbda61cf989a858a586bcf9ca6e802a20a843b965cfdb9b8b47bcd9a22e1f6476bfc7f4929190edaf007666995
|
data/lib/mygasfeed.rb
CHANGED
data/lib/mygasfeed/version.rb
CHANGED
data/mygasfeed.gemspec
CHANGED
@@ -1,26 +1,24 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'mygasfeed
|
4
|
+
require 'mygasfeed'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "mygasfeed"
|
8
8
|
spec.version = Mygasfeed::VERSION
|
9
9
|
spec.authors = ["Mason Wiley"]
|
10
10
|
spec.email = ["masonwiley92@gmail.com"]
|
11
|
-
|
12
11
|
spec.summary = %q{Ruby API client for www.mygasfeed.org}
|
13
12
|
spec.description = %q{Provides a Ruby gem wrapper for MyGasFeed API.}
|
14
13
|
spec.homepage = "https://github.com/mwiley/mygasfeed"
|
15
14
|
spec.license = "MIT"
|
16
15
|
|
17
|
-
spec.files = `git ls-files
|
18
|
-
spec.
|
19
|
-
spec.
|
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)/})
|
20
19
|
spec.require_paths = ["lib"]
|
21
20
|
|
22
21
|
spec.add_dependency 'httparty'
|
23
|
-
spec.add_dependency 'addressable'
|
24
22
|
|
25
23
|
spec.add_development_dependency "bundler", "~> 1.8"
|
26
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mygasfeed do
|
4
|
+
describe '.get_address' do
|
5
|
+
subject { described_class.get_address(lat, lng) }
|
6
|
+
|
7
|
+
context "when valid params are given" do
|
8
|
+
let(:lat) { 45.5092499 }
|
9
|
+
let(:lng) { -73.7167247 }
|
10
|
+
|
11
|
+
context 'when request succeeds' do
|
12
|
+
it "should be a Mygasfeed:Location object" do
|
13
|
+
expect(subject).to be_a(Mygasfeed::Location)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mygasfeed do
|
4
|
+
describe '.get_brands' do
|
5
|
+
subject { described_class.get_brands }
|
6
|
+
|
7
|
+
context 'when request succeeds' do
|
8
|
+
it { should be_an Array }
|
9
|
+
it { should_not be_empty }
|
10
|
+
|
11
|
+
it "should contain Mygasfeed:Brand objects" do
|
12
|
+
expect(subject.first).to be_a(Mygasfeed::Brand)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mygasfeed do
|
4
|
+
describe '.get_close_by' do
|
5
|
+
subject { described_class.get_close_by(station_id, limit) }
|
6
|
+
|
7
|
+
context "when valid params are given" do
|
8
|
+
let(:station_id) { 101595 }
|
9
|
+
let(:limit) { 5 }
|
10
|
+
|
11
|
+
|
12
|
+
context 'when request succeeds' do
|
13
|
+
it { should be_an Array }
|
14
|
+
it { should_not be_empty }
|
15
|
+
|
16
|
+
it "should contain Mygasfeed:Station objects" do
|
17
|
+
expect(subject.first).to be_a(Mygasfeed::Station)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mygasfeed do
|
4
|
+
describe '.get_details' do
|
5
|
+
subject { described_class.get_details station_id }
|
6
|
+
|
7
|
+
context "when valid params are given" do
|
8
|
+
let(:station_id) { 33862 }
|
9
|
+
|
10
|
+
context 'when request succeeds' do
|
11
|
+
it "should be a Mygasfeed:Station object" do
|
12
|
+
expect(subject).to be_a(Mygasfeed::Station)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mygasfeed do
|
4
|
+
describe '.get_history' do
|
5
|
+
subject { described_class.get_history station_id }
|
6
|
+
|
7
|
+
context "when valid params are given" do
|
8
|
+
let(:station_id) { 101595 }
|
9
|
+
|
10
|
+
|
11
|
+
context 'when request succeeds' do
|
12
|
+
it { should be_an Array }
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mygasfeed do
|
4
|
+
describe '.get_stations' do
|
5
|
+
subject { described_class.get_stations(latitude, longitude, distance, fuel_type, sort_by) }
|
6
|
+
|
7
|
+
context "when valid params are given" do
|
8
|
+
let(:latitude) { 39.7400 }
|
9
|
+
let(:longitude) { -121.8356 }
|
10
|
+
let(:distance) { 1 }
|
11
|
+
let(:fuel_type) { "reg" }
|
12
|
+
let(:sort_by) { "distance" }
|
13
|
+
|
14
|
+
context 'when request succeeds' do
|
15
|
+
it { should be_an Array }
|
16
|
+
it { should_not be_empty }
|
17
|
+
|
18
|
+
it "should contain Mygasfeed:Station objects" do
|
19
|
+
expect(subject.first).to be_a(Mygasfeed::Station)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mygasfeed do
|
4
|
+
describe '.update_price' do
|
5
|
+
subject { described_class.update_price(price, fuel_type, station_id) }
|
6
|
+
|
7
|
+
context "when valid params are given" do
|
8
|
+
let(:price) { 4.15 }
|
9
|
+
let(:fuel_type) { "diesel" }
|
10
|
+
let(:station_id) { 110244 }
|
11
|
+
|
12
|
+
context 'when request succeeds' do
|
13
|
+
it "should be a Mygasfeed:Station object" do
|
14
|
+
expect(subject).to be_a(Mygasfeed::Station)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec/its'
|
3
|
+
|
4
|
+
describe Mygasfeed::Brand do
|
5
|
+
describe '.build' do
|
6
|
+
subject { described_class.build data }
|
7
|
+
|
8
|
+
context 'when valid data provided' do
|
9
|
+
let(:data) {
|
10
|
+
{
|
11
|
+
"id" => "123",
|
12
|
+
"name" => "Shell"
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
it { should be_a described_class }
|
17
|
+
its(:id) { should eq 123 }
|
18
|
+
its(:name) { should eq "Shell" }
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec/its'
|
3
|
+
|
4
|
+
describe Mygasfeed::Location do
|
5
|
+
describe '.build' do
|
6
|
+
subject { described_class.build data }
|
7
|
+
|
8
|
+
context 'when valid data provided' do
|
9
|
+
let(:data) {
|
10
|
+
{
|
11
|
+
"country_short" => "CA",
|
12
|
+
"lat" => "45.5092499",
|
13
|
+
"lng" => "-73.7167247",
|
14
|
+
"country_long" => "Canada",
|
15
|
+
"region_short" => "QC",
|
16
|
+
"region_long" => "Quebec",
|
17
|
+
"city_long" => "Saint-Laurent",
|
18
|
+
"city_short" => "SL",
|
19
|
+
"address" => "14073, Boulevard Cavendish",
|
20
|
+
"result" => "OK"
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
it { should be_a described_class }
|
25
|
+
|
26
|
+
its(:country_short) { should eq "CA" }
|
27
|
+
its(:lat) { should eq 45.5092499}
|
28
|
+
its(:lng) { should eq -73.7167247 }
|
29
|
+
its(:country_long) { should eq "Canada" }
|
30
|
+
its(:region_short) { should eq "QC" }
|
31
|
+
its(:region_long) { should eq "Quebec" }
|
32
|
+
its(:city_long) { should eq "Saint-Laurent" }
|
33
|
+
its(:city_short) { should eq "SL" }
|
34
|
+
its(:address) { should eq "14073, Boulevard Cavendish" }
|
35
|
+
its(:result) { should eq "OK" }
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec/its'
|
3
|
+
|
4
|
+
describe Mygasfeed::PreviousPrice do
|
5
|
+
describe '.build' do
|
6
|
+
subject { described_class.build data }
|
7
|
+
|
8
|
+
context 'when valid data provided' do
|
9
|
+
let(:data) {
|
10
|
+
{
|
11
|
+
"type" => "Pre",
|
12
|
+
"price" => "3.33",
|
13
|
+
"date" => "1 day ago",
|
14
|
+
"via" => "myGasFeed Dev"
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
it { should be_a described_class }
|
19
|
+
its(:type) { should eq "Pre"}
|
20
|
+
its(:price) { should eq 3.33 }
|
21
|
+
its(:date) { should eq "1 day ago" }
|
22
|
+
its(:via) { should eq "myGasFeed Dev" }
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec/its'
|
3
|
+
|
4
|
+
describe Mygasfeed::Station do
|
5
|
+
describe '.build' do
|
6
|
+
subject { described_class.build data }
|
7
|
+
|
8
|
+
context 'when valid data provided' do
|
9
|
+
let(:data) {
|
10
|
+
{
|
11
|
+
"country" => "Canada",
|
12
|
+
"reg_price" => "3.65",
|
13
|
+
"mid_price" => "3.66",
|
14
|
+
"pre_price" => "3.67",
|
15
|
+
"diesel_price" => "3.68",
|
16
|
+
"address" => "3885, Boulevard Saint-Rose",
|
17
|
+
"diesel" => "0",
|
18
|
+
"id" => "33862",
|
19
|
+
"lat" => "45.492367",
|
20
|
+
"lng" => "-73.710915",
|
21
|
+
"station" => "Shell",
|
22
|
+
"region" => "Quebec",
|
23
|
+
"city" => "Saint-Laurent",
|
24
|
+
"reg_date" => "3 hours ago",
|
25
|
+
"mid_date" => "4 hours ago",
|
26
|
+
"pre_date" => "5 hours ago",
|
27
|
+
"diesel_date" => "6 hours ago",
|
28
|
+
"distance" => "1.9km"
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
it { should be_a described_class }
|
33
|
+
|
34
|
+
its(:country) { should eq "Canada"}
|
35
|
+
its(:reg_price) { should eq 3.65 }
|
36
|
+
its(:mid_price) { should eq 3.66 }
|
37
|
+
its(:pre_price) { should eq 3.67 }
|
38
|
+
its(:diesel_price) { should eq 3.68 }
|
39
|
+
its(:address) { should eq "3885, Boulevard Saint-Rose" }
|
40
|
+
its(:diesel) { should eq false }
|
41
|
+
its(:id) { should eq 33862 }
|
42
|
+
its(:lat) { should eq 45.492367 }
|
43
|
+
its(:lng) { should eq -73.710915 }
|
44
|
+
its(:station) { should eq "Shell" }
|
45
|
+
its(:region) { should eq "Quebec" }
|
46
|
+
its(:city) { should eq "Saint-Laurent" }
|
47
|
+
its(:reg_date) { should eq "3 hours ago" }
|
48
|
+
its(:mid_date) { should eq "4 hours ago" }
|
49
|
+
its(:pre_date) { should eq "5 hours ago" }
|
50
|
+
its(:diesel_date) { should eq "6 hours ago" }
|
51
|
+
its(:distance) { should eq "1.9km" }
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mygasfeed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mason Wiley
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2015-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: addressable
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: bundler
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,7 +83,9 @@ dependencies:
|
|
97
83
|
description: Provides a Ruby gem wrapper for MyGasFeed API.
|
98
84
|
email:
|
99
85
|
- masonwiley92@gmail.com
|
100
|
-
executables:
|
86
|
+
executables:
|
87
|
+
- console
|
88
|
+
- setup
|
101
89
|
extensions: []
|
102
90
|
extra_rdoc_files: []
|
103
91
|
files:
|
@@ -126,6 +114,19 @@ files:
|
|
126
114
|
- lib/mygasfeed/resources/station.rb
|
127
115
|
- lib/mygasfeed/version.rb
|
128
116
|
- mygasfeed.gemspec
|
117
|
+
- spec/dsl/get_address_spec.rb
|
118
|
+
- spec/dsl/get_brands.rb
|
119
|
+
- spec/dsl/get_close_by_spec.rb
|
120
|
+
- spec/dsl/get_details_spec.rb
|
121
|
+
- spec/dsl/get_history_spec.rb
|
122
|
+
- spec/dsl/get_stations_spec.rb
|
123
|
+
- spec/dsl/update_price_spec.rb
|
124
|
+
- spec/mygasfeed_spec.rb
|
125
|
+
- spec/resources/brand_spec.rb
|
126
|
+
- spec/resources/location_spec.rb
|
127
|
+
- spec/resources/previous_price_spec.rb
|
128
|
+
- spec/resources/station_spec.rb
|
129
|
+
- spec/spec_helper.rb
|
129
130
|
homepage: https://github.com/mwiley/mygasfeed
|
130
131
|
licenses:
|
131
132
|
- MIT
|
@@ -150,4 +151,17 @@ rubygems_version: 2.2.2
|
|
150
151
|
signing_key:
|
151
152
|
specification_version: 4
|
152
153
|
summary: Ruby API client for www.mygasfeed.org
|
153
|
-
test_files:
|
154
|
+
test_files:
|
155
|
+
- spec/dsl/get_address_spec.rb
|
156
|
+
- spec/dsl/get_brands.rb
|
157
|
+
- spec/dsl/get_close_by_spec.rb
|
158
|
+
- spec/dsl/get_details_spec.rb
|
159
|
+
- spec/dsl/get_history_spec.rb
|
160
|
+
- spec/dsl/get_stations_spec.rb
|
161
|
+
- spec/dsl/update_price_spec.rb
|
162
|
+
- spec/mygasfeed_spec.rb
|
163
|
+
- spec/resources/brand_spec.rb
|
164
|
+
- spec/resources/location_spec.rb
|
165
|
+
- spec/resources/previous_price_spec.rb
|
166
|
+
- spec/resources/station_spec.rb
|
167
|
+
- spec/spec_helper.rb
|