gtfs-data_exchange 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.
- data/.gitignore +1 -0
- data/.rspec +3 -0
- data/README.md +6 -5
- data/gtfs-data_exchange.gemspec +3 -2
- data/lib/gtfs/data_exchange/api.rb +6 -8
- data/lib/gtfs/data_exchange/version.rb +2 -2
- data/spec/gtfs/data_exchange/api_spec.rb +47 -0
- data/spec/spec_helper.rb +94 -0
- metadata +27 -6
data/.gitignore
CHANGED
data/.rspec
ADDED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# GTFS::DataExchange
|
2
2
|
|
3
|
-
A ruby wrapper for the [gtfs-data-exchange.com api](http://www.gtfs-data-exchange.com/api). List all agencies, or find a specific agency by its
|
3
|
+
A ruby wrapper for the [gtfs-data-exchange.com](http://www.gtfs-data-exchange.com) [api](http://www.gtfs-data-exchange.com/api). List all agencies, or find a specific agency by its data exchange identifier.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -36,7 +36,7 @@ agencies = GTFS::DataExchange::API.agencies(:format => "csv")
|
|
36
36
|
|
37
37
|
### Agency
|
38
38
|
|
39
|
-
Find an agency by its
|
39
|
+
Find an agency by its data exchange identifier.
|
40
40
|
|
41
41
|
```` rb
|
42
42
|
agency = GTFS::DataExchange::API.agency(:dataexchange_id => "shore-line-east")
|
@@ -48,6 +48,7 @@ By default, this will return a Ruby `Hash` object.
|
|
48
48
|
|
49
49
|
1. Fork it ( https://github.com/databyday/gtfs-data_exchange/fork )
|
50
50
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
51
|
-
3.
|
52
|
-
4.
|
53
|
-
5.
|
51
|
+
3. Test your changes (optional, but encouraged `rspec spec/`)
|
52
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
53
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
54
|
+
6. Create a new Pull Request
|
data/gtfs-data_exchange.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = GTFS::DataExchange::VERSION
|
9
9
|
spec.authors = ["MJ Rossetti (@s2t2)"]
|
10
10
|
spec.email = ["s2t2mail@gmail.com"]
|
11
|
-
spec.summary = %q{A ruby wrapper for the
|
12
|
-
spec.description = %q{A ruby wrapper for the
|
11
|
+
spec.summary = %q{A ruby wrapper for the gtfs-data-exchange.com api (http://www.gtfs-data-exchange.com/api).}
|
12
|
+
spec.description = %q{A ruby wrapper for the gtfs-data-exchange.com api (http://www.gtfs-data-exchange.com/api). List all agencies, or find a specific agency by its data exchange identifier.}
|
13
13
|
spec.homepage = "https://github.com/databyday/gtfs-data-exchange-api-ruby"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -21,5 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
spec.add_development_dependency "pry", "~> 0.10"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
24
25
|
spec.add_dependency "httparty", "~> 0.13"
|
25
26
|
end
|
@@ -1,23 +1,21 @@
|
|
1
1
|
require "httparty"
|
2
2
|
|
3
|
-
# Top-level namespace referencing the
|
3
|
+
# Top-level namespace referencing the General Transit Feed Specification (https://developers.google.com/transit/gtfs/).
|
4
4
|
module GTFS
|
5
5
|
|
6
|
-
# Namespace referencing the
|
7
|
-
# a third-party site "designed to help developers and transit agencies efficiently share and retrieve GTFS data."
|
6
|
+
# Namespace referencing the data exchange (http://www.gtfs-data-exchange.com/), a third-party site "designed to help developers and transit agencies efficiently share and retrieve GTFS data."
|
8
7
|
module DataExchange
|
9
8
|
|
10
9
|
# Contains all data exchange api methods and exceptions.
|
11
10
|
class API
|
12
11
|
|
13
|
-
# The base url for api endpoints.
|
14
|
-
# This page also acts as the primary source for api reference documentation.
|
12
|
+
# The base url for api endpoints. This page also acts as the primary source for api reference documentation.
|
15
13
|
BASE_URL = "http://www.gtfs-data-exchange.com/api"
|
16
14
|
|
17
15
|
# List all agencies.
|
18
16
|
# @param [Hash] options the request options.
|
19
17
|
# @option options [String] :format ('json') the requested data format.
|
20
|
-
# @raise [UnsupportedRequestFormat] if the
|
18
|
+
# @raise [UnsupportedRequestFormat] if the requested data format is not supported by the service.
|
21
19
|
# @raise [ResponseCodeError, ResponseDataError] for unexpected responses.
|
22
20
|
# @return [Array, String] the agencies data in the requested format.
|
23
21
|
def self.agencies(options = {})
|
@@ -39,9 +37,9 @@ module GTFS
|
|
39
37
|
end
|
40
38
|
end
|
41
39
|
|
42
|
-
# Find an agency by its
|
40
|
+
# Find an agency by its data exchange identifier.
|
43
41
|
# @param [Hash] options the request options.
|
44
|
-
# @option options [String] :dataexchange_id ('shore-line-east') the requested
|
42
|
+
# @option options [String] :dataexchange_id ('shore-line-east') the requested agency identifier.
|
45
43
|
# @raise [UnrecognizedDataExchangeId] if the requested agency identifier is unrecognized by the service.
|
46
44
|
# @raise [ResponseCodeError, ResponseDataError, ResponseAgencyError] for unexpected responses.
|
47
45
|
# @return [Hash] the agency data.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module GTFS
|
2
2
|
module DataExchange
|
3
3
|
|
4
|
-
# The current gem version. Reference the
|
5
|
-
VERSION = "0.0.
|
4
|
+
# The current gem version. Reference the releases list (https://github.com/databyday/gtfs-data-exchange-api-ruby/releases) for previous releases.
|
5
|
+
VERSION = "0.0.3"
|
6
6
|
end
|
7
7
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
module GTFS
|
5
|
+
module DataExchange
|
6
|
+
describe API do
|
7
|
+
|
8
|
+
# Agencies
|
9
|
+
|
10
|
+
it 'lists all agencies' do
|
11
|
+
agencies = GTFS::DataExchange::API.agencies
|
12
|
+
expect(agencies).to be_kind_of(Array)
|
13
|
+
expect(agencies.first).to be_kind_of(Hash)
|
14
|
+
expect(agencies.first["dataexchange_id"]).to be_kind_of(String)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'lists all agencies in CSV format' do
|
18
|
+
agencies = GTFS::DataExchange::API.agencies(:format => "csv")
|
19
|
+
expect(agencies).to be_kind_of(String)
|
20
|
+
csv_result = CSV.parse(agencies, :headers => true)
|
21
|
+
expect(csv_result.headers).to include("dataexchange_id")
|
22
|
+
expect(csv_result.first).to be_kind_of(CSV::Row)
|
23
|
+
expect(csv_result.first.to_hash["dataexchange_id"]).to be_kind_of(String)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'explains why it is unable to return agencies data in an unsupported format' do
|
27
|
+
unsupported_format = "sql"
|
28
|
+
expect{ GTFS::DataExchange::API.agencies(:format => unsupported_format) }.to raise_error
|
29
|
+
end
|
30
|
+
|
31
|
+
# Agency
|
32
|
+
|
33
|
+
it 'finds a specific agency by its data exchange identifier' do
|
34
|
+
specified_identifier = "metro-north-railroad"
|
35
|
+
agency = GTFS::DataExchange::API.agency(:dataexchange_id => specified_identifier)
|
36
|
+
expect(agency).to be_kind_of(Hash)
|
37
|
+
expect(agency["dataexchange_id"]).to eql(specified_identifier)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'explains why it is unable to find an unrecognized agency' do
|
41
|
+
unrecognized_identifier = "my-railroad"
|
42
|
+
expect{ GTFS::DataExchange::API.agency(:dataexchange_id => unrecognized_identifier) }.to raise_error
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# http://stackoverflow.com/questions/4398262/setup-rspec-to-test-a-gem-not-rails
|
2
|
+
require 'bundler/setup'
|
3
|
+
Bundler.setup
|
4
|
+
require 'gtfs/data_exchange'
|
5
|
+
|
6
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
7
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
8
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
9
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
10
|
+
#
|
11
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
12
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
13
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
14
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
15
|
+
# a separate helper file that requires the additional dependencies and performs
|
16
|
+
# the additional setup, and require it from the spec files that actually need it.
|
17
|
+
#
|
18
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
19
|
+
# users commonly want.
|
20
|
+
#
|
21
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
22
|
+
RSpec.configure do |config|
|
23
|
+
# rspec-expectations config goes here. You can use an alternate
|
24
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
25
|
+
# assertions if you prefer.
|
26
|
+
config.expect_with :rspec do |expectations|
|
27
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
28
|
+
# and `failure_message` of custom matchers include text for helper methods
|
29
|
+
# defined using `chain`, e.g.:
|
30
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
31
|
+
# # => "be bigger than 2 and smaller than 4"
|
32
|
+
# ...rather than:
|
33
|
+
# # => "be bigger than 2"
|
34
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
35
|
+
end
|
36
|
+
|
37
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
38
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
39
|
+
config.mock_with :rspec do |mocks|
|
40
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
41
|
+
# a real object. This is generally recommended, and will default to
|
42
|
+
# `true` in RSpec 4.
|
43
|
+
mocks.verify_partial_doubles = true
|
44
|
+
end
|
45
|
+
|
46
|
+
# The settings below are suggested to provide a good initial experience
|
47
|
+
# with RSpec, but feel free to customize to your heart's content.
|
48
|
+
=begin
|
49
|
+
# These two settings work together to allow you to limit a spec run
|
50
|
+
# to individual examples or groups you care about by tagging them with
|
51
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
52
|
+
# get run.
|
53
|
+
config.filter_run :focus
|
54
|
+
config.run_all_when_everything_filtered = true
|
55
|
+
|
56
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
57
|
+
# For more details, see:
|
58
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
59
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
60
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
61
|
+
config.disable_monkey_patching!
|
62
|
+
|
63
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
64
|
+
# be too noisy due to issues in dependencies.
|
65
|
+
config.warnings = true
|
66
|
+
|
67
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
68
|
+
# file, and it's useful to allow more verbose output when running an
|
69
|
+
# individual spec file.
|
70
|
+
if config.files_to_run.one?
|
71
|
+
# Use the documentation formatter for detailed output,
|
72
|
+
# unless a formatter has already been configured
|
73
|
+
# (e.g. via a command-line flag).
|
74
|
+
config.default_formatter = 'doc'
|
75
|
+
end
|
76
|
+
|
77
|
+
# Print the 10 slowest examples and example groups at the
|
78
|
+
# end of the spec run, to help surface which specs are running
|
79
|
+
# particularly slow.
|
80
|
+
config.profile_examples = 10
|
81
|
+
|
82
|
+
# Run specs in random order to surface order dependencies. If you find an
|
83
|
+
# order dependency and want to debug it, you can fix the order by providing
|
84
|
+
# the seed, which is printed after each run.
|
85
|
+
# --seed 1234
|
86
|
+
config.order = :random
|
87
|
+
|
88
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
89
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
90
|
+
# test failures related to randomization by passing the same `--seed` value
|
91
|
+
# as the one that triggered the failure.
|
92
|
+
Kernel.srand config.seed
|
93
|
+
=end
|
94
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gtfs-data_exchange
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
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: 2014-11-
|
12
|
+
date: 2014-11-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0.10'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.1'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '3.1'
|
62
78
|
- !ruby/object:Gem::Dependency
|
63
79
|
name: httparty
|
64
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,8 +91,8 @@ dependencies:
|
|
75
91
|
- - ~>
|
76
92
|
- !ruby/object:Gem::Version
|
77
93
|
version: '0.13'
|
78
|
-
description: A ruby wrapper for the
|
79
|
-
List all agencies, or find a specific agency by its
|
94
|
+
description: A ruby wrapper for the gtfs-data-exchange.com api (http://www.gtfs-data-exchange.com/api).
|
95
|
+
List all agencies, or find a specific agency by its data exchange identifier.
|
80
96
|
email:
|
81
97
|
- s2t2mail@gmail.com
|
82
98
|
executables: []
|
@@ -84,6 +100,7 @@ extensions: []
|
|
84
100
|
extra_rdoc_files: []
|
85
101
|
files:
|
86
102
|
- .gitignore
|
103
|
+
- .rspec
|
87
104
|
- Gemfile
|
88
105
|
- LICENSE.txt
|
89
106
|
- README.md
|
@@ -93,6 +110,8 @@ files:
|
|
93
110
|
- lib/gtfs/data_exchange.rb
|
94
111
|
- lib/gtfs/data_exchange/api.rb
|
95
112
|
- lib/gtfs/data_exchange/version.rb
|
113
|
+
- spec/gtfs/data_exchange/api_spec.rb
|
114
|
+
- spec/spec_helper.rb
|
96
115
|
homepage: https://github.com/databyday/gtfs-data-exchange-api-ruby
|
97
116
|
licenses:
|
98
117
|
- MIT
|
@@ -117,6 +136,8 @@ rubyforge_project:
|
|
117
136
|
rubygems_version: 1.8.23
|
118
137
|
signing_key:
|
119
138
|
specification_version: 3
|
120
|
-
summary: A ruby wrapper for the
|
121
|
-
test_files:
|
139
|
+
summary: A ruby wrapper for the gtfs-data-exchange.com api (http://www.gtfs-data-exchange.com/api).
|
140
|
+
test_files:
|
141
|
+
- spec/gtfs/data_exchange/api_spec.rb
|
142
|
+
- spec/spec_helper.rb
|
122
143
|
has_rdoc:
|