rasp-yandex 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +29 -0
- data/LICENSE +21 -0
- data/README.md +63 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/rasp/yandex.rb +92 -0
- data/lib/rasp/yandex/version.rb +5 -0
- data/rasp-yandex.gemspec +40 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 38458e27fd5de45e53190cdfd734e3dcaf8382c7c03b5ab348d0c7c5495a6ceb
|
4
|
+
data.tar.gz: ed682e28c96e90b9c464d9efe607f517224c81d60cb1aac282ab99cfbd9755cf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e32b074fc2ea8cad03d0a98e925098459937059cafcf87aa959bba1bc526d9321831d44242a4279d2ddb65b0dcf3be5f1f20cd02c8ac8ea2a6618dc9e3298fca
|
7
|
+
data.tar.gz: 7bd9dfd1e8d62afcad95097a16a05db8da06b73763ab52282074dd3ba5f3facd47d245152c86d73feb017b2a21acf808f3fa39b8eff0530935185d26eeb1d2f9
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rasp-yandex (0.1.0)
|
5
|
+
faraday
|
6
|
+
faraday_middleware
|
7
|
+
json
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
faraday (0.15.2)
|
13
|
+
multipart-post (>= 1.2, < 3)
|
14
|
+
faraday_middleware (0.12.2)
|
15
|
+
faraday (>= 0.7.4, < 1.0)
|
16
|
+
json (2.1.0)
|
17
|
+
multipart-post (2.0.0)
|
18
|
+
rake (10.5.0)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
bundler (~> 1.16)
|
25
|
+
rake (~> 10.0)
|
26
|
+
rasp-yandex!
|
27
|
+
|
28
|
+
BUNDLED WITH
|
29
|
+
1.16.3
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Pavlov Yegor
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, 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,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Rasp::Yandex
|
2
|
+
|
3
|
+
It a simple gem for talking with [rasp.yandex API](https://tech.yandex.ru/rasp/).
|
4
|
+
Now supported only API version 3.0
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'rasp-yandex'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install rasp-yandex
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
Before usage this gem, read [documentation](https://tech.yandex.ru/rasp/doc/concepts/about-docpage/) for the [rasp.yandex.ru](https://rasp.yandex.ru/) and take apikey from yandex.
|
24
|
+
|
25
|
+
After:
|
26
|
+
|
27
|
+
1. Initialize client:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
Rasp::Yandex::Client.new("Your apikey")
|
31
|
+
```
|
32
|
+
2. Use!
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
client.timetable_between_stations("c146", "c213", "2018-08-01")
|
36
|
+
```
|
37
|
+
All methods correspond to functions from the documentation from API:
|
38
|
+
|
39
|
+
[all_stations](https://tech.yandex.ru/rasp/doc/reference/stations-list-docpage/)
|
40
|
+
|
41
|
+
[timetable_between_stations](https://tech.yandex.ru/rasp/doc/reference/schedule-point-point-docpage/) - if you want to get the schedule for a certain date, then specify it in the method, not in the default data, for example - client.timetable_between_stations ("c146", "c213", "2018-08-01"). If for all time - client.timetable_between_stations ("c146", "c213")
|
42
|
+
|
43
|
+
[timetable_at_station](https://tech.yandex.ru/rasp/doc/reference/schedule-on-station-docpage/) - In this method, the date is specified in the same way as in the previous method
|
44
|
+
|
45
|
+
[near_stations](https://tech.yandex.ru/rasp/doc/reference/query-nearest-station-docpage/)
|
46
|
+
|
47
|
+
[near_city](https://tech.yandex.ru/rasp/doc/reference/nearest-settlement-docpage/)
|
48
|
+
|
49
|
+
[stations_of_route](https://tech.yandex.ru/rasp/doc/reference/list-stations-route-docpage/)
|
50
|
+
|
51
|
+
[information_about_carrier](https://tech.yandex.ru/rasp/doc/reference/query-carrier-docpage/)
|
52
|
+
|
53
|
+
[copyright_yandex_rasp](https://tech.yandex.ru/rasp/doc/reference/query-copyright-docpage/)
|
54
|
+
|
55
|
+
## Development
|
56
|
+
|
57
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
58
|
+
|
59
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/pavlovegor/rasp-yandex.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rasp/yandex"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/rasp/yandex.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
require "rasp/yandex/version"
|
2
|
+
require "faraday"
|
3
|
+
require "faraday_middleware"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Rasp
|
7
|
+
module Yandex
|
8
|
+
class Client
|
9
|
+
|
10
|
+
URL = "https://api.rasp.yandex.net"
|
11
|
+
|
12
|
+
def initialize(api_key = nil, api_version = nil)
|
13
|
+
@api_key = api_key || ENV["RASP_YANDEX_API_KEY"]
|
14
|
+
@api_version = "3.0" || ENV["RASP_YANDEX_API_VERSION"]
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
def all_stations(default_params = nil)
|
19
|
+
conn = Faraday.new(url: URL) do |faraday|
|
20
|
+
faraday.request :url_encoded
|
21
|
+
faraday.response :json, content_type: /\bjson$/
|
22
|
+
faraday.adapter Faraday.default_adapter
|
23
|
+
end
|
24
|
+
conn.get "/v#{@api_version}/stations_list/?apikey=#{@api_key}", default_params
|
25
|
+
end
|
26
|
+
|
27
|
+
def timetable_between_stations(from, to, date = nil, default_params = nil)
|
28
|
+
conn = Faraday.new(url: URL) do |faraday|
|
29
|
+
faraday.request :url_encoded
|
30
|
+
faraday.response :json, content_type: /\bjson$/
|
31
|
+
faraday.adapter Faraday.default_adapter
|
32
|
+
end
|
33
|
+
conn.get "/v#{@api_version}/search/?apikey=#{@api_key}&from=#{from}&to=#{to}&date=#{date}", default_params
|
34
|
+
end
|
35
|
+
|
36
|
+
def timetable_at_station(station, date = nil, default_params = nil)
|
37
|
+
conn = Faraday.new(url: URL) do |faraday|
|
38
|
+
faraday.request :url_encoded
|
39
|
+
faraday.response :json, content_type: /\bjson$/
|
40
|
+
faraday.adapter Faraday.default_adapter
|
41
|
+
end
|
42
|
+
conn.get "/v#{@api_version}/schedule/?apikey=#{@api_key}&station=#{station}&date=#{date}", default_params
|
43
|
+
end
|
44
|
+
|
45
|
+
def near_stations(latitude, longitude, distance, default_params = nil)
|
46
|
+
conn = Faraday.new(url: URL) do |faraday|
|
47
|
+
faraday.request :url_encoded
|
48
|
+
faraday.response :json, content_type: /\bjson$/
|
49
|
+
faraday.adapter Faraday.default_adapter
|
50
|
+
end
|
51
|
+
conn.get "/v#{@api_version}/nearest_stations/?apikey=#{@api_key}&lat=#{latitude}&lng=#{longitude}&distance=#{distance}", default_params
|
52
|
+
end
|
53
|
+
|
54
|
+
def near_city(latitude, longitude, distance = nil, default_params = nil)
|
55
|
+
conn = Faraday.new(url: URL) do |faraday|
|
56
|
+
faraday.request :url_encoded
|
57
|
+
faraday.response :json, content_type: /\bjson$/
|
58
|
+
faraday.adapter Faraday.default_adapter
|
59
|
+
end
|
60
|
+
conn.get "/v#{@api_version}/nearest_settlement/?apikey=#{@api_key}&lat=#{latitude}&lng=#{longitude}&distance=#{distance}", default_params
|
61
|
+
end
|
62
|
+
|
63
|
+
def stations_of_route(uid, default_params = nil)
|
64
|
+
conn = Faraday.new(url: URL) do |faraday|
|
65
|
+
faraday.request :url_encoded
|
66
|
+
faraday.response :json, content_type: /\bjson$/
|
67
|
+
faraday.adapter Faraday.default_adapter
|
68
|
+
end
|
69
|
+
conn.get "/v#{@api_version}/thread/?apikey=#{@api_key}&uid=#{uid}", default_params
|
70
|
+
end
|
71
|
+
|
72
|
+
def information_about_carrier(code, default_params = nil)
|
73
|
+
conn = Faraday.new(url: URL) do |faraday|
|
74
|
+
faraday.request :url_encoded
|
75
|
+
faraday.response :json, content_type: /\bjson$/
|
76
|
+
faraday.adapter Faraday.default_adapter
|
77
|
+
end
|
78
|
+
conn.get "/v#{@api_version}/carrier/?apikey=#{@api_key}&code=#{code}", default_params
|
79
|
+
end
|
80
|
+
|
81
|
+
def copyright_yandex_rasp(format)
|
82
|
+
conn = Faraday.new(url: URL) do |faraday|
|
83
|
+
faraday.request :url_encoded
|
84
|
+
faraday.response :json, content_type: /\bjson$/
|
85
|
+
faraday.adapter Faraday.default_adapter
|
86
|
+
end
|
87
|
+
conn.get "v#{@api_key}/copyright/?apikey=#{@api_key}&format=#{format}"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
data/rasp-yandex.gemspec
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "rasp/yandex/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rasp-yandex"
|
8
|
+
spec.version = Rasp::Yandex::VERSION
|
9
|
+
spec.authors = ["Egor Pavlov"]
|
10
|
+
spec.email = ["pavlov_egor007@mail.ru"]
|
11
|
+
|
12
|
+
spec.summary = %q{Client library for rasp.yandex.ru API.}
|
13
|
+
spec.description = %q{Client library for rasp.yandex.ru API.}
|
14
|
+
spec.homepage = "https://github.com/pavlovegor/rasp-yandex"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
# "public gem pushes."
|
24
|
+
# end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
spec.required_ruby_version = '>= 2.5.1'
|
33
|
+
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
35
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
36
|
+
|
37
|
+
spec.add_dependency "faraday"
|
38
|
+
spec.add_dependency "faraday_middleware"
|
39
|
+
spec.add_dependency "json"
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rasp-yandex
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Egor Pavlov
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-08-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faraday
|
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
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: faraday_middleware
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Client library for rasp.yandex.ru API.
|
84
|
+
email:
|
85
|
+
- pavlov_egor007@mail.ru
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- Gemfile
|
92
|
+
- Gemfile.lock
|
93
|
+
- LICENSE
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/console
|
97
|
+
- bin/setup
|
98
|
+
- lib/rasp/yandex.rb
|
99
|
+
- lib/rasp/yandex/version.rb
|
100
|
+
- rasp-yandex.gemspec
|
101
|
+
homepage: https://github.com/pavlovegor/rasp-yandex
|
102
|
+
licenses:
|
103
|
+
- MIT
|
104
|
+
metadata: {}
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: 2.5.1
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.7.6
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: Client library for rasp.yandex.ru API.
|
125
|
+
test_files: []
|