spbus 0.0.2 → 0.0.3

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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/example.rb +14 -18
  3. data/lib/spbus/bus.rb +2 -3
  4. data/lib/spbus/request.rb +31 -0
  5. data/lib/spbus/route.rb +6 -40
  6. data/lib/spbus/scrapers/locations.rb +48 -0
  7. data/lib/spbus/scrapers/route_details.rb +56 -0
  8. data/lib/spbus/scrapers/routes.rb +74 -0
  9. data/lib/spbus/version.rb +1 -1
  10. data/lib/spbus.rb +23 -5
  11. data/spbus.gemspec +1 -1
  12. data/spec/bus_spec.rb +12 -0
  13. data/spec/cassettes/auth_request.yml +278 -0
  14. data/spec/cassettes/{SpBus_Crawler/_fetch_routes/returns_all_bus_routes.yml → bus_routes.yml} +26269 -26401
  15. data/spec/cassettes/buses_locations.yml +276 -0
  16. data/spec/cassettes/invalid_route_detail.yml +276 -0
  17. data/spec/cassettes/normal_request.yml +136 -0
  18. data/spec/cassettes/normal_route_detail.yml +278 -0
  19. data/spec/cassettes/one_way_route_detail.yml +278 -0
  20. data/spec/request_spec.rb +39 -0
  21. data/spec/route_spec.rb +23 -32
  22. data/spec/scrapers/locations_scraper_spec.rb +24 -0
  23. data/spec/scrapers/route_details_scraper_spec.rb +68 -0
  24. data/spec/scrapers/routes_scraper_spec.rb +30 -0
  25. data/spec/spbus_spec.rb +40 -0
  26. data/spec/spec_helper.rb +1 -1
  27. metadata +35 -25
  28. data/lib/spbus/crawler.rb +0 -52
  29. data/lib/spbus/locations.rb +0 -37
  30. data/spec/cassettes/SpBus_Crawler/_fetch_routes/returns_creates_a_Route_object_for_every_found_route.yml +0 -32809
  31. data/spec/cassettes/SpBus_Locations/_fetch_locations/retrieves_all_buses_locations.yml +0 -34
  32. data/spec/cassettes/SpBus_Route/_fetch_details/sets_destination_attribute.yml +0 -36
  33. data/spec/cassettes/SpBus_Route/_fetch_details/sets_origin_attribute.yml +0 -36
  34. data/spec/cassettes/SpBus_Route/_fetch_details/sets_route_position_codes.yml +0 -36
  35. data/spec/cassettes/SpBus_Route/_to_h/returns_a_hash.yml +0 -36
  36. data/spec/crawler_spec.rb +0 -20
  37. data/spec/locations_spec.rb +0 -18
@@ -1,34 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://200.189.189.54/InternetServices/PosicaoLinha?codigoLinha=59
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - '*/*; q=0.5, application/xml'
12
- Accept-Encoding:
13
- - gzip, deflate
14
- User-Agent:
15
- - Ruby
16
- response:
17
- status:
18
- code: 200
19
- message: OK
20
- headers:
21
- Content-Length:
22
- - '101'
23
- Content-Type:
24
- - application/json; charset=utf-8
25
- Server:
26
- - Microsoft-HTTPAPI/2.0
27
- Date:
28
- - Sun, 08 Sep 2013 02:41:33 GMT
29
- body:
30
- encoding: UTF-8
31
- string: '{"PosicaoLinhaResult":{"hr":"23:41","vs":[{"a":true,"p":"72420","px":-46.735629,"py":-23.64352625}]}}'
32
- http_version:
33
- recorded_at: Sun, 08 Sep 2013 02:41:33 GMT
34
- recorded_with: VCR 2.5.0
@@ -1,36 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://200.189.189.54/InternetServices/BuscaLinhasSIM?termosBusca=6450-10
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - '*/*; q=0.5, application/xml'
12
- Accept-Encoding:
13
- - gzip, deflate
14
- User-Agent:
15
- - Ruby
16
- response:
17
- status:
18
- code: 200
19
- message: OK
20
- headers:
21
- Content-Length:
22
- - '361'
23
- Content-Type:
24
- - application/json; charset=utf-8
25
- Server:
26
- - Microsoft-HTTPAPI/2.0
27
- Date:
28
- - Sat, 07 Sep 2013 04:49:02 GMT
29
- body:
30
- encoding: UTF-8
31
- string: '{"BuscaLinhasSIMResult":[{"Circular":false,"CodigoLinha":59,"DenominacaoTPTS":"TERM.
32
- BANDEIRA","DenominacaoTSTP":"TERM. CAPELINHA","Informacoes":null,"Letreiro":"6450","Sentido":1,"Tipo":10},{"Circular":false,"CodigoLinha":32827,"DenominacaoTPTS":"TERM.
33
- BANDEIRA","DenominacaoTSTP":"TERM. CAPELINHA","Informacoes":null,"Letreiro":"6450","Sentido":2,"Tipo":10}]}'
34
- http_version:
35
- recorded_at: Sat, 07 Sep 2013 04:49:04 GMT
36
- recorded_with: VCR 2.5.0
@@ -1,36 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://200.189.189.54/InternetServices/BuscaLinhasSIM?termosBusca=6450-10
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - '*/*; q=0.5, application/xml'
12
- Accept-Encoding:
13
- - gzip, deflate
14
- User-Agent:
15
- - Ruby
16
- response:
17
- status:
18
- code: 200
19
- message: OK
20
- headers:
21
- Content-Length:
22
- - '361'
23
- Content-Type:
24
- - application/json; charset=utf-8
25
- Server:
26
- - Microsoft-HTTPAPI/2.0
27
- Date:
28
- - Sat, 07 Sep 2013 04:49:02 GMT
29
- body:
30
- encoding: UTF-8
31
- string: '{"BuscaLinhasSIMResult":[{"Circular":false,"CodigoLinha":59,"DenominacaoTPTS":"TERM.
32
- BANDEIRA","DenominacaoTSTP":"TERM. CAPELINHA","Informacoes":null,"Letreiro":"6450","Sentido":1,"Tipo":10},{"Circular":false,"CodigoLinha":32827,"DenominacaoTPTS":"TERM.
33
- BANDEIRA","DenominacaoTSTP":"TERM. CAPELINHA","Informacoes":null,"Letreiro":"6450","Sentido":2,"Tipo":10}]}'
34
- http_version:
35
- recorded_at: Sat, 07 Sep 2013 04:49:04 GMT
36
- recorded_with: VCR 2.5.0
@@ -1,36 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://200.189.189.54/InternetServices/BuscaLinhasSIM?termosBusca=6450-10
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - '*/*; q=0.5, application/xml'
12
- Accept-Encoding:
13
- - gzip, deflate
14
- User-Agent:
15
- - Ruby
16
- response:
17
- status:
18
- code: 200
19
- message: OK
20
- headers:
21
- Content-Length:
22
- - '361'
23
- Content-Type:
24
- - application/json; charset=utf-8
25
- Server:
26
- - Microsoft-HTTPAPI/2.0
27
- Date:
28
- - Sat, 07 Sep 2013 04:49:02 GMT
29
- body:
30
- encoding: UTF-8
31
- string: '{"BuscaLinhasSIMResult":[{"Circular":false,"CodigoLinha":59,"DenominacaoTPTS":"TERM.
32
- BANDEIRA","DenominacaoTSTP":"TERM. CAPELINHA","Informacoes":null,"Letreiro":"6450","Sentido":1,"Tipo":10},{"Circular":false,"CodigoLinha":32827,"DenominacaoTPTS":"TERM.
33
- BANDEIRA","DenominacaoTSTP":"TERM. CAPELINHA","Informacoes":null,"Letreiro":"6450","Sentido":2,"Tipo":10}]}'
34
- http_version:
35
- recorded_at: Sat, 07 Sep 2013 04:49:03 GMT
36
- recorded_with: VCR 2.5.0
@@ -1,36 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://200.189.189.54/InternetServices/BuscaLinhasSIM?termosBusca=6450-10
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - '*/*; q=0.5, application/xml'
12
- Accept-Encoding:
13
- - gzip, deflate
14
- User-Agent:
15
- - Ruby
16
- response:
17
- status:
18
- code: 200
19
- message: OK
20
- headers:
21
- Content-Length:
22
- - '361'
23
- Content-Type:
24
- - application/json; charset=utf-8
25
- Server:
26
- - Microsoft-HTTPAPI/2.0
27
- Date:
28
- - Sat, 07 Sep 2013 23:22:55 GMT
29
- body:
30
- encoding: UTF-8
31
- string: '{"BuscaLinhasSIMResult":[{"Circular":false,"CodigoLinha":59,"DenominacaoTPTS":"TERM.
32
- BANDEIRA","DenominacaoTSTP":"TERM. CAPELINHA","Informacoes":null,"Letreiro":"6450","Sentido":1,"Tipo":10},{"Circular":false,"CodigoLinha":32827,"DenominacaoTPTS":"TERM.
33
- BANDEIRA","DenominacaoTSTP":"TERM. CAPELINHA","Informacoes":null,"Letreiro":"6450","Sentido":2,"Tipo":10}]}'
34
- http_version:
35
- recorded_at: Sat, 07 Sep 2013 23:22:54 GMT
36
- recorded_with: VCR 2.5.0
data/spec/crawler_spec.rb DELETED
@@ -1,20 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe SpBus::Crawler do
4
-
5
- describe "#fetch_routes", :vcr do
6
-
7
- before { subject.fetch_routes }
8
-
9
- it "returns all bus routes" do
10
- expect(subject.routes.size).to eql(1320)
11
- end
12
-
13
- it "returns creates a Route object for every found route" do
14
- subject.routes.each do |l|
15
- expect(l).to be_kind_of(SpBus::Route)
16
- end
17
- end
18
- end
19
- end
20
-
@@ -1,18 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe SpBus::Locations do
4
-
5
- describe "#fetch_locations", :vcr do
6
-
7
- subject { described_class.new("59") }
8
- before { subject.fetch_locations }
9
-
10
- it "retrieves all buses locations" do
11
- expect(subject.buses).to have(1).item
12
- expect(subject.buses.first).to be_kind_of(SpBus::Bus)
13
- expect(subject.buses.first.lat).to eql(-23.64352625)
14
- expect(subject.buses.first.long).to eql(-46.735629)
15
- end
16
- end
17
- end
18
-