lpp 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -6
- data/lib/lpp.rb +7 -8
- data/lib/lpp/version.rb +1 -1
- data/test/test_lpp.rb +7 -0
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e3e79816f11fcccca2bfa8e88babe0a2d0f399e4
|
4
|
+
data.tar.gz: cdde89a53d064fa44f2b74d7db98fee0350d7e53
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 21a92fc1606f0f891e5dfc232bf218f35e4be2d9a0d39105970a97afc88c2b4d38c09cf7858a48d381ae789cf376aad89b8bd48d79ee07924dd7abfe519cb6ee
|
7
|
+
data.tar.gz: d5a89e785f549b1dadb29dcdc7560565f7164538decc1385494f964babc271a5ef088bc145502320204a24ef93e3863f1e8b2d5d2a1bfc825a50b062c8a5796a
|
data/lib/lpp.rb
CHANGED
@@ -4,19 +4,18 @@ require "lpp/version"
|
|
4
4
|
require 'net/http'
|
5
5
|
require 'nokogiri'
|
6
6
|
require 'open-uri'
|
7
|
-
require 'pry'
|
8
7
|
|
9
8
|
module Lpp
|
10
9
|
REGEX = /NAPOVED PRIHODOV ZA (.+?) \((.+?)\)(.+?)(?:NAPOVED PRIHODOV ZA (.+?) \((.+?)\)(.+?))?Napovedi/m
|
11
10
|
|
12
11
|
def self.arrivals(station)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
'
|
17
|
-
'
|
18
|
-
|
19
|
-
|
12
|
+
http = Net::HTTP.new('wbus.talktrack.com')
|
13
|
+
data = "__EVENTTARGET=&__EVENTARGUMENT=&tb_postaja=#{station}&b_send=Prika%C5%BEi"
|
14
|
+
headers = {
|
15
|
+
'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko)',
|
16
|
+
'Content-Type' => 'application/x-www-form-urlencoded'
|
17
|
+
}
|
18
|
+
res = http.post('/wap.aspx', data, headers)
|
20
19
|
text = Nokogiri::HTML(res.body).text
|
21
20
|
|
22
21
|
raise 'Station not found' if /Postaje s tem imenom nismo našli/.match(text)
|
data/lib/lpp/version.rb
CHANGED
data/test/test_lpp.rb
CHANGED
@@ -5,6 +5,13 @@ require 'lpp'
|
|
5
5
|
require 'test_helper'
|
6
6
|
|
7
7
|
class LppTest < Test::Unit::TestCase
|
8
|
+
def test_requesting
|
9
|
+
WebMock.allow_net_connect!
|
10
|
+
arrivals = Lpp.arrivals('bavarski')
|
11
|
+
assert_equal (arrivals['600011'] != nil), true
|
12
|
+
WebMock.disable_net_connect!
|
13
|
+
end
|
14
|
+
|
8
15
|
def test_parsing
|
9
16
|
response = File.read(File.join(File.dirname(__FILE__), 'response.html'))
|
10
17
|
stub_request(:any, /wbus.talktrack.com\/.*/).
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lpp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jure Triglav
|
@@ -28,42 +28,42 @@ dependencies:
|
|
28
28
|
name: pry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: webmock
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
@@ -110,12 +110,12 @@ require_paths:
|
|
110
110
|
- lib
|
111
111
|
required_ruby_version: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
|
-
- -
|
113
|
+
- - '>='
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
117
|
requirements:
|
118
|
-
- -
|
118
|
+
- - '>='
|
119
119
|
- !ruby/object:Gem::Version
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|