wienerlinien 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6912071ac1d3bdb91bde0f695017dfe20e85ebd3
4
+ data.tar.gz: a9b30bd374e611e1a767b7276c9b77735710190f
5
+ SHA512:
6
+ metadata.gz: 89b5f9a2f3e0512d13fc0c73d6d9970228008cefae25b1c193ea06530e4551670a663075e7a9124089bd4192a2bcc5cfbe1c5b060296cf672420fba922c38d30
7
+ data.tar.gz: 8c043b09c88b670acfa419f4162a6fa6bf7f8012b972d9cd72bb75f401e75eba7695430a5cdc35bd31fa511de1216659d67fb1263ec84b9c872782ec9dda83e4
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
19
+ .env
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "https://rubygems.org"
2
+
3
+ group :development do
4
+ gem 'pry'
5
+ gem 'pry-debugger'
6
+ gem 'dotenv'
7
+ end
8
+
9
+ group :test, :development do
10
+ gem 'reek'
11
+ gem 'rubocop'
12
+ end
13
+
14
+
15
+ gemspec
@@ -0,0 +1,68 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ wienerlinien (0.0.1)
5
+ faraday
6
+ faraday_middleware
7
+ recursive-open-struct
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ ast (1.1.0)
13
+ backports (3.3.3)
14
+ coderay (1.0.9)
15
+ columnize (0.3.6)
16
+ debugger (1.6.1)
17
+ columnize (>= 0.3.1)
18
+ debugger-linecache (~> 1.2.0)
19
+ debugger-ruby_core_source (~> 1.2.3)
20
+ debugger-linecache (1.2.0)
21
+ debugger-ruby_core_source (1.2.3)
22
+ dotenv (0.9.0)
23
+ faraday (0.8.8)
24
+ multipart-post (~> 1.2.0)
25
+ faraday_middleware (0.9.0)
26
+ faraday (>= 0.7.4, < 0.9)
27
+ method_source (0.8.2)
28
+ multipart-post (1.2.0)
29
+ parser (2.0.0.pre6)
30
+ ast (~> 1.1)
31
+ slop (~> 3.4, >= 3.4.5)
32
+ powerpack (0.0.7)
33
+ pry (0.9.12.2)
34
+ coderay (~> 1.0.5)
35
+ method_source (~> 0.8)
36
+ slop (~> 3.4)
37
+ pry-debugger (0.2.2)
38
+ debugger (~> 1.3)
39
+ pry (~> 0.9.10)
40
+ rainbow (1.1.4)
41
+ recursive-open-struct (0.4.4)
42
+ reek (1.3.3)
43
+ ruby2ruby (~> 2.0.2)
44
+ ruby_parser (~> 3.1, >= 3.1.1)
45
+ sexp_processor
46
+ rubocop (0.12.0)
47
+ backports (~> 3.3.3)
48
+ parser (~> 2.0.0.pre6)
49
+ powerpack (~> 0.0.3)
50
+ rainbow (>= 1.1.4)
51
+ ruby2ruby (2.0.6)
52
+ ruby_parser (~> 3.1)
53
+ sexp_processor (~> 4.0)
54
+ ruby_parser (3.2.2)
55
+ sexp_processor (~> 4.1)
56
+ sexp_processor (4.3.0)
57
+ slop (3.4.6)
58
+
59
+ PLATFORMS
60
+ ruby
61
+
62
+ DEPENDENCIES
63
+ dotenv
64
+ pry
65
+ pry-debugger
66
+ reek
67
+ rubocop
68
+ wienerlinien!
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Andreas Tiefenthaler
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,4 @@
1
+ wiener_linien
2
+ =============
3
+
4
+ Wrapper for the Wiener Linien "Echtzeitdaten"
@@ -0,0 +1,11 @@
1
+ require 'reek/rake/task'
2
+ require 'rubocop/rake_task'
3
+
4
+ require 'bundler/gem_tasks'
5
+
6
+ Reek::Rake::Task.new do |t|
7
+ t.fail_on_error = false
8
+ end
9
+
10
+
11
+ Rubocop::RakeTask.new
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'bundler/setup'
4
+ Bundler.require
5
+
6
+ require 'pry'
7
+ # require 'pry-debugger'
8
+
9
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib','wienerlinien'))
10
+ require 'dotenv'
11
+ Dotenv.load
12
+ sender = ENV['sender']
13
+
14
+ include Wienerlinien
15
+
16
+ @client = Client.new(sender)
17
+ Pry::CLI.parse_options
@@ -0,0 +1,43 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+ require 'wienerlinien/version'
4
+ require_relative 'wienerlinien/errors'
5
+ require_relative 'wienerlinien/monitors'
6
+ require_relative 'wienerlinien/news_list'
7
+ require_relative 'wienerlinien/traffic_info'
8
+ require_relative 'wienerlinien/traffic_info_list'
9
+
10
+
11
+ module Wienerlinien
12
+ class Client
13
+ def initialize(sender, params = {})
14
+ @params = params.merge( {sender: sender})
15
+ @connection = Faraday.new(:url => 'http://www.wienerlinien.at') do |faraday|
16
+ faraday.response :json, :content_type => /\bjson$/
17
+ faraday.request :json
18
+ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
19
+ end
20
+ end
21
+
22
+ def monitors(params={})
23
+ monitors = Monitors.new(@connection)
24
+ monitors.get(@params.merge(params))
25
+ end
26
+
27
+ def traffic_info_list(params={})
28
+ traffic_info_list = TrafficInfoList.new(@connection)
29
+ traffic_info_list.get(@params.merge(params))
30
+ end
31
+
32
+ def traffic_info(params={})
33
+ traffic_info = TrafficInfo.new(@connection)
34
+ traffic_info.get(@params.merge(params))
35
+ end
36
+
37
+ def news_list(params= {})
38
+ news_list = NewsList.new(@connection)
39
+ news_list.get(@params.merge(params))
40
+ end
41
+
42
+ end # Client
43
+ end # Winerlinien
@@ -0,0 +1,3 @@
1
+ module Wienerlinien
2
+ class ParamNotGivenError < StandardError; end
3
+ end
@@ -0,0 +1,33 @@
1
+ require 'recursive-open-struct'
2
+ module Wienerlinien
3
+ class Monitors
4
+
5
+ def initialize(connection)
6
+ @connection = connection
7
+ end
8
+
9
+ def get(params)
10
+ if params[:rbl]
11
+ response = perform_get(params)
12
+ else
13
+ raise ParamNotGivenError.new("Please provide a RBL number.")
14
+ end
15
+
16
+ RecursiveOpenStruct.new(response.body['data'], :recurse_over_arrays => true)
17
+ end
18
+
19
+ def perform_get(params={})
20
+ response = @connection.get do |req|
21
+ req.params = params
22
+ req.url '/ogd_realtime/monitor'
23
+ req.headers['Content-Type'] = 'application/json'
24
+ end
25
+
26
+ unless response.success?
27
+ errors = JSON.parse(response.body)
28
+ end
29
+
30
+ response
31
+ end
32
+ end # Monitor
33
+ end # Wienerlinien
@@ -0,0 +1,26 @@
1
+ module Wienerlinien
2
+ class NewsList
3
+ def initialize(connection)
4
+ @connection = connection
5
+ end
6
+
7
+ def get(params)
8
+ response = perform_get(params)
9
+ RecursiveOpenStruct.new(response.body['data'], :recurse_over_arrays => true)
10
+ end
11
+
12
+ def perform_get(params={})
13
+ response = @connection.get do |req|
14
+ req.params = params
15
+ req.url '/ogd_realtime/newsList'
16
+ req.headers['Content-Type'] = 'application/json'
17
+ end
18
+
19
+ unless response.success?
20
+ errors = JSON.parse(response.body)
21
+ end
22
+
23
+ response
24
+ end
25
+ end # NewsList
26
+ end # Wienerlinien
@@ -0,0 +1,30 @@
1
+ module Wienerlinien
2
+ class TrafficInfo
3
+ def initialize(connection)
4
+ @connection = connection
5
+ end
6
+
7
+ def get(params)
8
+ response = perform_get(params)
9
+ RecursiveOpenStruct.new(response.body['data'], :recurse_over_arrays => true)
10
+ end
11
+
12
+ def perform_get(params={})
13
+ if params[:name]
14
+ response = @connection.get do |req|
15
+ req.params = params
16
+ req.url '/ogd_realtime/trafficInfo'
17
+ req.headers['Content-Type'] = 'application/json'
18
+ end
19
+ else
20
+ raise ParamNotGivenError.new("Please provide one or multiple name=")
21
+ end
22
+
23
+ unless response.success?
24
+ errors = JSON.parse(response.body)
25
+ end
26
+ p response.body
27
+ response
28
+ end
29
+ end # TrafficInfo
30
+ end # Wienerlinien
@@ -0,0 +1,26 @@
1
+ module Wienerlinien
2
+ class TrafficInfoList
3
+ def initialize(connection)
4
+ @connection = connection
5
+ end
6
+
7
+ def get(params)
8
+ response = perform_get(params)
9
+ RecursiveOpenStruct.new(response.body['data'], :recurse_over_arrays => true)
10
+ end
11
+
12
+ def perform_get(params={})
13
+ response = @connection.get do |req|
14
+ req.params = params
15
+ req.url '/ogd_realtime/trafficInfoList'
16
+ req.headers['Content-Type'] = 'application/json'
17
+ end
18
+
19
+ unless response.success?
20
+ errors = JSON.parse(response.body)
21
+ end
22
+
23
+ response
24
+ end
25
+ end # TrafficInfoList
26
+ end # Wienerlinien
@@ -0,0 +1,3 @@
1
+ module Wienerlinien
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,17 @@
1
+ require File.expand_path('../lib/wienerlinien/version', __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = 'Andreas Tiefenthaler'
5
+ gem.email = %w(at@an-ti.eu)
6
+ gem.description = %q{Wrapper for the Wiener Linien}
7
+ gem.summary = %q{Wrapper for the Wiener Linien}
8
+ gem.homepage = 'https://github.com/pxlpnk/wiener_linien'
9
+ gem.files = `git ls-files`.split($\)
10
+ gem.name = 'wienerlinien'
11
+ gem.require_paths = ['lib']
12
+ gem.version = Wienerlinien::VERSION
13
+
14
+ gem.add_dependency 'faraday'
15
+ gem.add_dependency 'faraday_middleware'
16
+ gem.add_dependency 'recursive-open-struct'
17
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wienerlinien
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andreas Tiefenthaler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
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
+ - !ruby/object:Gem::Dependency
42
+ name: recursive-open-struct
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Wrapper for the Wiener Linien
56
+ email:
57
+ - at@an-ti.eu
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - LICENSE
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - lib/wienerlinien.rb
70
+ - lib/wienerlinien/errors.rb
71
+ - lib/wienerlinien/monitors.rb
72
+ - lib/wienerlinien/news_list.rb
73
+ - lib/wienerlinien/traffic_info.rb
74
+ - lib/wienerlinien/traffic_info_list.rb
75
+ - lib/wienerlinien/version.rb
76
+ - wienerlinien.gemspec
77
+ homepage: https://github.com/pxlpnk/wiener_linien
78
+ licenses: []
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.0.3
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Wrapper for the Wiener Linien
100
+ test_files: []
101
+ has_rdoc: