velibe 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/CHANGELOG.md +7 -1
- data/Rakefile +15 -4
- data/features/step_definitions/config_steps.rb +5 -0
- data/features/support/aruba.rb +1 -0
- data/features/support/env.rb +26 -0
- data/features/velibe_favorites.feature +16 -0
- data/features/velibe_query.feature +25 -0
- data/lib/velibe.rb +1 -1
- data/lib/velibe/config.rb +15 -0
- data/lib/velibe/db/database.rb +2 -5
- data/lib/velibe/db/kv_store.rb +20 -10
- data/lib/velibe/version.rb +1 -1
- data/spec/kv_store_spec.rb +78 -0
- data/spec/spec_helper.rb +6 -0
- data/velibe.gemspec +2 -0
- metadata +43 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53bf1830ce882ba66e706edbf383b5c97f0a3fa8
|
4
|
+
data.tar.gz: 22d9f6e371bf02de9e399f7f72797acff029aa07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 881572db58c41d7c2ff371781661b743f1498005718dce68d0f7ddff0474105692f8c664679ea2a8841174fa2f54c7ebf5a345ec312c88cdb85f9b04a528531c
|
7
|
+
data.tar.gz: 214b62a2c0ace61ec874eb8b0cc1492a08c99894fcfab161c6dfad811745eefdb1cfb0f03a74d9107accf21b1734084b8fa0b3b42751a1a8b7b460f8ee6812bf
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@ All notable changes to *Velibe* will be documented in this file.
|
|
4
4
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
5
5
|
|
6
6
|
## [Unreleased][unreleased]
|
7
|
+
## [0.2.3] - 2015-12-04
|
8
|
+
### Fixed
|
9
|
+
- ensure favorites stations are stored as integer
|
10
|
+
- prevent running test to destroy your config :)
|
7
11
|
|
8
12
|
## [0.2.2] - 2015-12-02
|
9
13
|
### Fixed
|
@@ -38,7 +42,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
38
42
|
## [0.0.1] - 2015-07-04
|
39
43
|
- Initial Release
|
40
44
|
|
41
|
-
[unreleased]: https://github.com/AdrieanKhisbe/velibe/compare/v0.2.
|
45
|
+
[unreleased]: https://github.com/AdrieanKhisbe/velibe/compare/v0.2.3...HEAD
|
46
|
+
[0.2.3]: https://github.com/AdrieanKhisbe/velibe/compare/v0.2.2...v0.2.3
|
47
|
+
[0.2.2]: https://github.com/AdrieanKhisbe/velibe/compare/v0.2.1...v0.2.2
|
42
48
|
[0.2.1]: https://github.com/AdrieanKhisbe/velibe/compare/v0.2.0...v0.2.1
|
43
49
|
[0.2.0]: https://github.com/AdrieanKhisbe/velibe/compare/v0.1.0...v0.2.0
|
44
50
|
[0.1.0]: https://github.com/AdrieanKhisbe/velibe/compare/v0.0.2...v0.1.0
|
data/Rakefile
CHANGED
@@ -1,8 +1,19 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
require 'cucumber'
|
5
|
+
require 'cucumber/rake/task'
|
6
|
+
|
7
|
+
# §todo: see task offered : -T flag
|
4
8
|
# see -> http://pablocantero.com/blog/2011/01/02/new-gem-with-bundler-sample-rakefile/
|
5
9
|
|
6
10
|
RSpec::Core::RakeTask.new(:spec)
|
11
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
12
|
+
t.cucumber_opts = 'features --format pretty'
|
13
|
+
end
|
14
|
+
|
15
|
+
task test: [:spec, :features]
|
16
|
+
task default: :test
|
17
|
+
|
18
|
+
|
7
19
|
|
8
|
-
task :default => :spec
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'aruba/cucumber'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'aruba/cucumber'
|
2
|
+
velibe_lib = File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
ENV['VELIBE_DB_PATH'] = '/tmp/velibe.db'
|
5
|
+
ENV['VELIBE_CONFIG_PATH'] = '/tmp/velibe.yaml'
|
6
|
+
ENV['VELIBE_TOKEN'] = 'fake-test-value'
|
7
|
+
|
8
|
+
if ENV['TRAVIS']
|
9
|
+
require 'simplecov'
|
10
|
+
require 'coveralls'
|
11
|
+
|
12
|
+
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
13
|
+
SimpleCov.start do
|
14
|
+
# No need to report coverage metrics for the test code
|
15
|
+
add_filter 'test'
|
16
|
+
add_filter 'features'
|
17
|
+
add_filter 'data'
|
18
|
+
end
|
19
|
+
|
20
|
+
# Eager load the entire lib directory so that SimpleCov is able to report
|
21
|
+
# accurate code coverage metrics.
|
22
|
+
at_exit { Dir["#{velibe_lib}/**/*.rb"].each { |rb| require(rb) } }
|
23
|
+
end
|
24
|
+
|
25
|
+
$LOAD_PATH.unshift velibe_lib
|
26
|
+
require 'velibe'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Feature: Playing with favorites
|
2
|
+
In order to see not specify each time wich station i'm interested in
|
3
|
+
As a user of the velibe cli
|
4
|
+
I want to be handle to manage favorite
|
5
|
+
|
6
|
+
|
7
|
+
Background: Favorites Exists
|
8
|
+
Given my favorites stations are 22, 42, 68
|
9
|
+
|
10
|
+
Scenario: List favorites
|
11
|
+
|
12
|
+
Scenario: Add a Favorite
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
Scenario: Force Reset of favorites
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Feature: Querying the API
|
2
|
+
In order to see if I can take a bike at a given station
|
3
|
+
As a user of the velibe cli
|
4
|
+
I want to be able to query the api through the velibe cli
|
5
|
+
|
6
|
+
Background: Favorites Exists
|
7
|
+
Given my favorites stations are 22, 42, 68
|
8
|
+
|
9
|
+
Scenario: By Default, my favorites are queried
|
10
|
+
Given a file named "file.txt" with:
|
11
|
+
"""
|
12
|
+
Hello World
|
13
|
+
"""
|
14
|
+
Then the file "file.txt" should contain:
|
15
|
+
"""
|
16
|
+
Hello World
|
17
|
+
"""
|
18
|
+
|
19
|
+
|
20
|
+
Scenario: I can specify the station i'm interested into
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Scenario: Wrong arguments are ignored and warning is printed
|
data/lib/velibe.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Velibe
|
2
|
+
module Config
|
3
|
+
# §see: http://stackoverflow.com/questions/7828066/accessing-files-packaged-into-a-ruby-gem
|
4
|
+
|
5
|
+
DB_NAME = ENV['VELIBE_DB_PATH'] || '~/.velib.db'
|
6
|
+
DB_PATH = Pathname.new(DB_NAME).expand_path # .to_s?
|
7
|
+
DATA_CSV = '../../data/Paris.csv'
|
8
|
+
|
9
|
+
DATA_CSV_FILE = File.join(File.dirname(File.expand_path(__FILE__)), DATA_CSV)
|
10
|
+
|
11
|
+
KV_NAME = ENV['VELIBE_CONFIG_PATH'] || '~/.velib.yaml'
|
12
|
+
KV_PATH = Pathname.new(KV_NAME).expand_path
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
data/lib/velibe/db/database.rb
CHANGED
@@ -6,15 +6,12 @@ require 'sqlite3'
|
|
6
6
|
require 'active_record'
|
7
7
|
require 'csv'
|
8
8
|
require 'velibe/db/models'
|
9
|
+
require 'velibe/config'
|
9
10
|
|
10
11
|
module Velibe
|
11
12
|
|
12
13
|
module Database
|
13
|
-
|
14
|
-
DB_PATH = Pathname.new(DB_NAME).expand_path # .to_s?
|
15
|
-
DATA_CSV = '../../../data/Paris.csv'
|
16
|
-
DATA_CSV_FILE = File.join(File.dirname(File.expand_path(__FILE__)), DATA_CSV)
|
17
|
-
# §see: http://stackoverflow.com/questions/7828066/accessing-files-packaged-into-a-ruby-gem
|
14
|
+
include Config
|
18
15
|
|
19
16
|
def self.exist?
|
20
17
|
DB_PATH.exist? # §check
|
data/lib/velibe/db/kv_store.rb
CHANGED
@@ -1,34 +1,44 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
require 'moneta'
|
3
3
|
require 'pathname'
|
4
|
+
require 'velibe/config'
|
4
5
|
|
5
6
|
module Velibe
|
6
7
|
|
7
8
|
module KvStore
|
8
|
-
|
9
|
-
PATH = Pathname.new(NAME).expand_path
|
10
|
-
DB = Moneta.new(:YAML, file: PATH)
|
9
|
+
include Config
|
11
10
|
|
11
|
+
KV_DB = Moneta.new(:YAML, file: KV_PATH)
|
12
12
|
FAV_KEY = 'favorites'
|
13
13
|
|
14
|
+
def self.db
|
15
|
+
KV_DB
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.fav_key
|
19
|
+
FAV_KEY
|
20
|
+
end
|
21
|
+
|
14
22
|
def self.token
|
15
|
-
|
23
|
+
KV_DB['token']
|
16
24
|
end
|
17
25
|
|
18
|
-
def self.reset_favorite_stations
|
19
|
-
|
26
|
+
def self.reset_favorite_stations(*new_stations)
|
27
|
+
KV_DB[FAV_KEY] = new_stations.collect(&:to_i)
|
20
28
|
end
|
21
29
|
|
22
30
|
def self.favorite_stations
|
23
|
-
|
31
|
+
KV_DB[FAV_KEY]
|
24
32
|
end
|
25
33
|
|
26
34
|
def self.add_favorite_station(*stations)
|
27
|
-
fav =
|
35
|
+
fav = KV_DB[FAV_KEY]
|
28
36
|
# TODO: handle setup
|
29
37
|
# TODO: check existing station
|
30
|
-
stations.each
|
31
|
-
|
38
|
+
stations.collect(&:to_i).each do |station|
|
39
|
+
fav.push(station) unless fav.include?(station)
|
40
|
+
end
|
41
|
+
KV_DB[FAV_KEY] = fav
|
32
42
|
end
|
33
43
|
|
34
44
|
end
|
data/lib/velibe/version.rb
CHANGED
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe Velibe::KvStore do
|
5
|
+
|
6
|
+
|
7
|
+
before { Velibe::KvStore.db[Velibe::KvStore.fav_key] = [2, 3, 4] }
|
8
|
+
let(:favorites) { Velibe::KvStore.favorite_stations }
|
9
|
+
|
10
|
+
|
11
|
+
describe '#token' do
|
12
|
+
let(:token) { Velibe::KvStore.token }
|
13
|
+
context 'no token in conf' do
|
14
|
+
before { Velibe::KvStore.db.delete 'token'}
|
15
|
+
it { expect(token).to be_nil }
|
16
|
+
end
|
17
|
+
context 'with token in conf' do
|
18
|
+
before { Velibe::KvStore.db['token'] = 'fake-test-value' }
|
19
|
+
it { expect(token).to eq 'fake-test-value' }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#favorite_stations' do
|
24
|
+
it { expect(favorites).to eq [2, 3, 4] }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#reset_favorite_stations' do
|
28
|
+
|
29
|
+
context 'default arguments' do
|
30
|
+
before { Velibe::KvStore.reset_favorite_stations }
|
31
|
+
it { expect(favorites).to eq [] }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'specific arguments' do
|
35
|
+
before { Velibe::KvStore.reset_favorite_stations 12, 42 }
|
36
|
+
it { expect(favorites).to eq [12, 42] }
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'specific arguments as string' do
|
40
|
+
before { Velibe::KvStore.reset_favorite_stations '33' }
|
41
|
+
it { expect(favorites).to eq [33] }
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#add_favorite_station' do
|
47
|
+
before { Velibe::KvStore.add_favorite_station *new_fav }
|
48
|
+
let(:final_fav) { Velibe::KvStore.favorite_stations }
|
49
|
+
|
50
|
+
context 'single new favorite' do
|
51
|
+
let(:new_fav) { 5 }
|
52
|
+
it { expect(final_fav).to eq (2..5).to_a }
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'list of favorites' do
|
56
|
+
let(:new_fav) { (5..10).to_a }
|
57
|
+
it { expect(final_fav).to eq (2..10).to_a }
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'single new as string' do
|
61
|
+
let(:new_fav) { '5' }
|
62
|
+
it { expect(final_fav).to eq (2..5).to_a }
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'ignore duplicates' do
|
66
|
+
let(:new_fav) { (3..5).to_a }
|
67
|
+
it { expect(final_fav).to eq (2..5).to_a }
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'no values' do
|
71
|
+
let(:new_fav) {}
|
72
|
+
it { expect(final_fav).to eq (2..4).to_a }
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
velibe_lib = File.expand_path('../../lib', __FILE__)
|
2
2
|
|
3
|
+
ENV['VELIBE_DB_PATH'] = '/tmp/velibe.db'
|
4
|
+
ENV['VELIBE_CONFIG_PATH'] = '/tmp/velibe.yaml'
|
5
|
+
ENV['VELIBE_TOKEN'] = 'fake-test-value'
|
6
|
+
|
3
7
|
if ENV['TRAVIS']
|
4
8
|
require 'simplecov'
|
5
9
|
require 'coveralls'
|
@@ -8,6 +12,8 @@ if ENV['TRAVIS']
|
|
8
12
|
SimpleCov.start do
|
9
13
|
# No need to report coverage metrics for the test code
|
10
14
|
add_filter 'test'
|
15
|
+
add_filter 'features'
|
16
|
+
add_filter 'data'
|
11
17
|
end
|
12
18
|
|
13
19
|
# Eager load the entire lib directory so that SimpleCov is able to report
|
data/velibe.gemspec
CHANGED
@@ -26,6 +26,8 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
27
27
|
spec.add_development_dependency 'rake'
|
28
28
|
spec.add_development_dependency 'rspec'
|
29
|
+
spec.add_development_dependency 'cucumber'
|
30
|
+
spec.add_development_dependency 'aruba', '~> 0.11.1'
|
29
31
|
spec.add_development_dependency 'simplecov'
|
30
32
|
spec.add_development_dependency 'coveralls'
|
31
33
|
spec.add_development_dependency 'jazz_fingers'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: velibe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adriean Khisbe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -108,6 +108,34 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: cucumber
|
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
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: aruba
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.11.1
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.11.1
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
140
|
name: simplecov
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -186,13 +214,20 @@ files:
|
|
186
214
|
- bin/velibe
|
187
215
|
- data/Paris.csv
|
188
216
|
- data/Paris.json
|
217
|
+
- features/step_definitions/config_steps.rb
|
218
|
+
- features/support/aruba.rb
|
219
|
+
- features/support/env.rb
|
220
|
+
- features/velibe_favorites.feature
|
221
|
+
- features/velibe_query.feature
|
189
222
|
- lib/velibe.rb
|
190
223
|
- lib/velibe/api_velib.rb
|
224
|
+
- lib/velibe/config.rb
|
191
225
|
- lib/velibe/db/database.rb
|
192
226
|
- lib/velibe/db/kv_store.rb
|
193
227
|
- lib/velibe/db/models.rb
|
194
228
|
- lib/velibe/station_status.rb
|
195
229
|
- lib/velibe/version.rb
|
230
|
+
- spec/kv_store_spec.rb
|
196
231
|
- spec/spec_helper.rb
|
197
232
|
- spec/station_status_spec.rb
|
198
233
|
- velibe.gemspec
|
@@ -222,6 +257,12 @@ signing_key:
|
|
222
257
|
specification_version: 4
|
223
258
|
summary: Small Velib Utility
|
224
259
|
test_files:
|
260
|
+
- features/step_definitions/config_steps.rb
|
261
|
+
- features/support/aruba.rb
|
262
|
+
- features/support/env.rb
|
263
|
+
- features/velibe_favorites.feature
|
264
|
+
- features/velibe_query.feature
|
265
|
+
- spec/kv_store_spec.rb
|
225
266
|
- spec/spec_helper.rb
|
226
267
|
- spec/station_status_spec.rb
|
227
268
|
has_rdoc:
|