bdz 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bdz.gemspec +2 -1
- data/lib/bdz/train.rb +9 -1
- data/lib/bdz/version.rb +1 -1
- data/lib/bdz.rb +2 -1
- data/spec/bdz/client_spec.rb +3 -8
- data/spec/bdz/train_spec.rb +12 -0
- metadata +21 -2
data/bdz.gemspec
CHANGED
@@ -14,9 +14,10 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.name = "bdz"
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = Bdz::VERSION
|
17
|
-
|
17
|
+
|
18
18
|
gem.add_runtime_dependency "faraday"
|
19
19
|
gem.add_runtime_dependency "nokogiri"
|
20
|
+
gem.add_runtime_dependency "json"
|
20
21
|
|
21
22
|
gem.add_development_dependency "pry"
|
22
23
|
gem.add_development_dependency "rake"
|
data/lib/bdz/train.rb
CHANGED
@@ -13,5 +13,13 @@ module Bdz
|
|
13
13
|
instance_variable_set("@#{name}", value) if respond_to?(name)
|
14
14
|
end
|
15
15
|
end
|
16
|
+
|
17
|
+
def as_json
|
18
|
+
hash = {}
|
19
|
+
self.instance_variables.each do |var|
|
20
|
+
hash[var] = self.instance_variable_get var
|
21
|
+
end
|
22
|
+
hash.to_json
|
23
|
+
end
|
16
24
|
end
|
17
|
-
end
|
25
|
+
end
|
data/lib/bdz/version.rb
CHANGED
data/lib/bdz.rb
CHANGED
data/spec/bdz/client_spec.rb
CHANGED
@@ -4,16 +4,11 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
4
4
|
describe Bdz::Client do
|
5
5
|
let(:client) { Bdz::Client.new }
|
6
6
|
|
7
|
-
describe '#build_params' do
|
7
|
+
describe '#build_params' do
|
8
8
|
it 'should merge defaults with params' do
|
9
9
|
params = client.send :build_params, {:from => 'Пловдив'}
|
10
|
-
params.should == {:from=>'Пловдив', :action=>"listOptions", :dep_arr=>"1", :time_from=>"00:00", :time_to=>"24:00",
|
10
|
+
params.should == {:from=>'Пловдив', :action=>"listOptions", :dep_arr=>"1", :time_from=>"00:00", :time_to=>"24:00",
|
11
11
|
:all_cats=>"checked", :cardId=>"30", :sort_by=>"0"}
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
15
|
-
describe '#search' do
|
16
|
-
it 'should return content' do
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#encoding: UTF-8
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
3
|
+
|
4
|
+
describe Bdz::Train do
|
5
|
+
let(:train) { Bdz::Train.new({:id => "1", :leaves => "00:00"}) }
|
6
|
+
|
7
|
+
describe 'Train object methods and instance_variables' do
|
8
|
+
it 'should have a method serialize to json that returns intance vars to json' do
|
9
|
+
train.as_json.should == "{\"@id\":\"1\",\"@leaves\":\"00:00\"}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bdz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: json
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: pry
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,6 +145,7 @@ files:
|
|
129
145
|
- lib/bdz/version.rb
|
130
146
|
- spec/bdz/client_spec.rb
|
131
147
|
- spec/bdz/parser/schedule_spec.rb
|
148
|
+
- spec/bdz/train_spec.rb
|
132
149
|
- spec/bdz_spec.rb
|
133
150
|
- spec/mocks/response.html
|
134
151
|
- spec/spec_helper.rb
|
@@ -159,6 +176,8 @@ summary: The Bulgarian State Railways schedule retriever
|
|
159
176
|
test_files:
|
160
177
|
- spec/bdz/client_spec.rb
|
161
178
|
- spec/bdz/parser/schedule_spec.rb
|
179
|
+
- spec/bdz/train_spec.rb
|
162
180
|
- spec/bdz_spec.rb
|
163
181
|
- spec/mocks/response.html
|
164
182
|
- spec/spec_helper.rb
|
183
|
+
has_rdoc:
|