osrm_text_instructions 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 +9 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +51 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/i18n/en.yml +99 -0
- data/lib/osrm_text_instructions/compiler.rb +155 -0
- data/lib/osrm_text_instructions/utils.rb +25 -0
- data/lib/osrm_text_instructions/version.rb +3 -0
- data/lib/osrm_text_instructions.rb +16 -0
- data/osrm_text_instructions.gemspec +24 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d887dde853324fc44802ae648b09b74488276ac4
|
4
|
+
data.tar.gz: 5561d37272acde6c1c691bdfb09950841895bcfc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c8a0a4d5b0a9ac6b1ebed2d292de475da5fa91efa8e55e437bb0d64b7bd79ab697c328feb3dc968fbd468084c07cabc6fd6b8c7888421d9247beb129b08a3a12
|
7
|
+
data.tar.gz: f5d6c3b4314c1888805d68fcab3d18e6ab18928c6efe155fd752013be67ad8d8aec0db98e8185a445d264b264867b4db4caabfb26a509f915951a677729d4ebf
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at felipe@zavan.me. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Felipe Zavan
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# OSRMTextInstructions
|
2
|
+
|
3
|
+
OSRMTextInstructions is a gem to transform OSRM steps into text instructions.
|
4
|
+
|
5
|
+
This is an almost verbatim port of [osrm-text-instructions.js](https://github.com/Project-OSRM/osrm-text-instructions).
|
6
|
+
|
7
|
+
Only version 5 of the API and the english locale is supported for now.
|
8
|
+
This is not stable yes and we still don't have any tests. Use at your own risk.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'osrm_text_instructions'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install osrm_text_instructions
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
# make your request against the API
|
30
|
+
|
31
|
+
legs.each do |leg|
|
32
|
+
leg.steps.each do |step|
|
33
|
+
instruction = OSRMTextInstructions.compile(step)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
## Development
|
39
|
+
|
40
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
41
|
+
|
42
|
+
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).
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/zavan/osrm_text_instructions. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
47
|
+
|
48
|
+
|
49
|
+
## License
|
50
|
+
|
51
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'osrm_text_instructions'
|
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
|
data/bin/setup
ADDED
data/i18n/en.yml
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
---
|
2
|
+
v5:
|
3
|
+
templates:
|
4
|
+
destination: " towards {destination}"
|
5
|
+
arrive:
|
6
|
+
defaultInstruction: You have arrived at your destination #{nth}
|
7
|
+
left: You have arrived at your destination #{nth}, on the left
|
8
|
+
right: You have arrived at your destination #{nth}, on the right
|
9
|
+
sharp left: You have arrived at your destination #{nth}, on the left
|
10
|
+
sharp right: You have arrived at your destination #{nth}, on the right
|
11
|
+
slight right: You have arrived at your destination #{nth}, on the right
|
12
|
+
slight left: You have arrived at your destination #{nth}, on the left
|
13
|
+
straight: You have arrived at your destination #{nth}, straight ahead
|
14
|
+
continue:
|
15
|
+
defaultInstruction: Continue {modifier}[ onto {way_name}]
|
16
|
+
slight left: Continue slightly left[ onto {way_name}]
|
17
|
+
slight right: Continue slightly right[ onto {way_name}]
|
18
|
+
depart:
|
19
|
+
defaultInstruction: Head {modifier}[ on {way_name}]
|
20
|
+
end of road:
|
21
|
+
defaultInstruction: Turn {modifier}[ onto {way_name}] at the end of the road
|
22
|
+
straight: Continue straight[ onto {way_name}]
|
23
|
+
uturn: Make a U-turn[ onto {way_name}] at the end of the road
|
24
|
+
ferry:
|
25
|
+
defaultInstruction: Take the ferry[ - {way_name}]
|
26
|
+
fork:
|
27
|
+
defaultInstruction: Keep {modifier} at the fork[ onto {way_name}]
|
28
|
+
slight left: Keep left at the fork[ onto {way_name}]
|
29
|
+
slight right: Keep right at the fork[ onto {way_name}]
|
30
|
+
sharp left: Take a sharp left at the fork[ onto {way_name}]
|
31
|
+
sharp right: Take a sharp right at the fork[ onto {way_name}]
|
32
|
+
uturn: Make a U-turn [ onto {way_name}]
|
33
|
+
merge:
|
34
|
+
defaultInstruction: Merge {modifier}[ onto {way_name}]
|
35
|
+
slight left: Merge slightly left[ onto {way_name}]
|
36
|
+
slight right: Merge slightly right[ onto {way_name}]
|
37
|
+
sharp left: Merge sharply left[ onto {way_name}]
|
38
|
+
sharp right: Merge sharply right[ onto {way_name}]
|
39
|
+
new name:
|
40
|
+
defaultInstruction: Continue {modifier}[ onto {way_name}]
|
41
|
+
sharp left: Take a sharp left[ onto {way_name}]
|
42
|
+
sharp right: Take a sharp right[ onto {way_name}]
|
43
|
+
slight left: Continue slightly left[ onto {way_name}]
|
44
|
+
slight right: Continue slightly right[ onto {way_name}]
|
45
|
+
uturn: Make a U-turn[ onto {way_name}]
|
46
|
+
notification:
|
47
|
+
defaultInstruction: Continue {modifier}[ onto {way_name}]
|
48
|
+
off ramp:
|
49
|
+
defaultInstruction: Take the ramp[ onto {way_name}]
|
50
|
+
left: Take the ramp on the left[ onto {way_name}]
|
51
|
+
right: Take the ramp on the right[ onto {way_name}]
|
52
|
+
sharp left: Take the ramp on the left[ onto {way_name}]
|
53
|
+
sharp right: Take the ramp on the right[ onto {way_name}]
|
54
|
+
slight left: Take the ramp on the left[ onto {way_name}]
|
55
|
+
slight right: Take the ramp on the right[ onto {way_name}]
|
56
|
+
on ramp:
|
57
|
+
defaultInstruction: Take the ramp[ onto {way_name}]
|
58
|
+
left: Take the ramp on the left[ onto {way_name}]
|
59
|
+
right: Take the ramp on the right[ onto {way_name}]
|
60
|
+
sharp left: Take the ramp on the left[ onto {way_name}]
|
61
|
+
sharp right: Take the ramp on the right[ onto {way_name}]
|
62
|
+
slight left: Take the ramp on the left[ onto {way_name}]
|
63
|
+
slight right: Take the ramp on the right[ onto {way_name}]
|
64
|
+
pushing bike:
|
65
|
+
defaultInstruction: Get off the bike and push[ onto {way_name}]
|
66
|
+
rotary:
|
67
|
+
defaultInstruction: Enter {rotary_name}
|
68
|
+
roundabout:
|
69
|
+
defaultInstruction: Enter the roundabout
|
70
|
+
roundabout turn:
|
71
|
+
defaultInstruction: At the roundabout make a {modifier}[ onto {way_name}]
|
72
|
+
left: At the roundabout turn left[ onto {way_name}]
|
73
|
+
right: At the roundabout turn right[ onto {way_name}]
|
74
|
+
straight: At the roundabout continue straight
|
75
|
+
train:
|
76
|
+
defaultInstruction: Take the train[ - {way_name}]
|
77
|
+
turn:
|
78
|
+
defaultInstruction: Make a {modifier}[ onto {way_name}]
|
79
|
+
left: Turn left[ onto {way_name}]
|
80
|
+
right: Turn right[ onto {way_name}]
|
81
|
+
straight: Go straight[ onto {way_name}]
|
82
|
+
use lane:
|
83
|
+
defaultInstruction: Continue straight[ onto {way_name}]
|
84
|
+
left: "{laneInstruction} to turn left[ onto {way_name}]"
|
85
|
+
right: "{laneInstruction} to turn right[ onto {way_name}]"
|
86
|
+
sharp left: "{laneInstruction} to make a sharp left[ onto {way_name}]"
|
87
|
+
sharp right: "{laneInstruction} to make a sharp right[ onto {way_name}]"
|
88
|
+
slight left: "{laneInstruction} to make a slight left[ onto {way_name}]"
|
89
|
+
slight right: "{laneInstruction} to make a slight right[ onto {way_name}]"
|
90
|
+
uturn: "{laneInstruction} to make a U-turn[ onto {way_name}]"
|
91
|
+
laneTypes:
|
92
|
+
xo: Keep right
|
93
|
+
ox: Keep left
|
94
|
+
oox: Keep left
|
95
|
+
xoo: Keep right
|
96
|
+
xxo: Keep right
|
97
|
+
oxx: Keep left
|
98
|
+
xox: Use the middle lane
|
99
|
+
oxo: Use the left or right lane
|
@@ -0,0 +1,155 @@
|
|
1
|
+
module OSRMTextInstructions
|
2
|
+
class Compiler
|
3
|
+
attr_accessor :instructions, :version
|
4
|
+
|
5
|
+
def initialize(instructions, version)
|
6
|
+
@instructions = instructions
|
7
|
+
@version = version
|
8
|
+
end
|
9
|
+
|
10
|
+
def compile(step)
|
11
|
+
unless instructions[version]
|
12
|
+
raise "Version #{version} not found for locale #{locale}"
|
13
|
+
end
|
14
|
+
|
15
|
+
raise 'No step maneuver provided' unless step['maneuver']
|
16
|
+
|
17
|
+
type = step['maneuver']['type']
|
18
|
+
modifier = step['maneuver']['modifier']
|
19
|
+
|
20
|
+
raise 'Missing step maneuver type' unless type
|
21
|
+
|
22
|
+
if type != 'depart' && type != 'arrive' && !modifier
|
23
|
+
raise 'Missing step maneuver modifier'
|
24
|
+
end
|
25
|
+
|
26
|
+
unless instructions[version][type]
|
27
|
+
# osrm specification assumes turn types can be added without
|
28
|
+
# major voersion changes and unknown types are treated
|
29
|
+
# as type `turn` by clients
|
30
|
+
type = 'turn'
|
31
|
+
end
|
32
|
+
|
33
|
+
# First check if the modifier for this maneuver has a special instruction
|
34
|
+
# If not, use the `defaultInstruction`
|
35
|
+
instruction =
|
36
|
+
if instructions[version][type][modifier]
|
37
|
+
instructions[version][type][modifier]
|
38
|
+
else
|
39
|
+
instructions[version][type]['defaultInstruction']
|
40
|
+
end
|
41
|
+
|
42
|
+
# Special cases, code here should be kept to a minimum
|
43
|
+
# If possible, change the instruction in `i18n/{locale}.yml`
|
44
|
+
# This switch statement is for specical cases that occur at runtime
|
45
|
+
case type
|
46
|
+
when 'arrive'
|
47
|
+
nth_waypoint = ''
|
48
|
+
instruction = instruction.gsub('{nth}', nth_waypoint).gsub(' ', ' ')
|
49
|
+
when 'depart'
|
50
|
+
# Always use cardinal direction for departure.
|
51
|
+
instruction = instruction.gsub('{modifier}', get_direction_from_degree(step['maneuver']['bearing_after'])[0])
|
52
|
+
when 'notification'
|
53
|
+
# TODO
|
54
|
+
when 'roundabout', 'rotary'
|
55
|
+
instruction = instruction.gsub('{rotary_name}', step['rotary_name'] || 'the rotary')
|
56
|
+
if step['name'] && step['maneuver']['exit']
|
57
|
+
instruction += " and take the #{step['maneuver']['exit']} exit onto {way_name}"
|
58
|
+
elsif step['maneuver']['exit']
|
59
|
+
instruction += " and take the #{step['maneuver']['exit']} exit"
|
60
|
+
elsif step['name']
|
61
|
+
instruction += ' and exit onto {way_name}'
|
62
|
+
end
|
63
|
+
when 'use lane'
|
64
|
+
lane_diagram = useLane(step)
|
65
|
+
lane_instruction = instructions[version][type]['laneTypes'][lane_diagram]
|
66
|
+
|
67
|
+
if lane_instruction
|
68
|
+
instruction = instruction.gsub('{laneInstruction}', lane_instruction)
|
69
|
+
else
|
70
|
+
# If the lane combination is not found, default to continue
|
71
|
+
instruction = instructions[version][type]['defaultInstruction']
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Handle instructions with destinations and names
|
76
|
+
if step['destinations'] && step['destinations'] != ''
|
77
|
+
# only use the first destination for text instruction
|
78
|
+
d = step['destinations'].split(',')[0]
|
79
|
+
t = instructions[version]['templates']['destination']
|
80
|
+
|
81
|
+
instruction = instruction
|
82
|
+
.gsub(/\[.+\]/, t.gsub('{destination}', d))
|
83
|
+
elsif step['name'] && step['name'] != ''
|
84
|
+
# if no destination found, try name
|
85
|
+
instruction = instruction
|
86
|
+
.gsub('[', '')
|
87
|
+
.gsub(']', '')
|
88
|
+
.gsub('{way_name}', step['name'])
|
89
|
+
else
|
90
|
+
# do not use name information if not included in step
|
91
|
+
instruction = instruction.gsub(/\[.+\]/, '')
|
92
|
+
end
|
93
|
+
|
94
|
+
# Cleaning for all instructions
|
95
|
+
# If a modifier is not provided, calculate direction given bearing
|
96
|
+
instruction = instruction
|
97
|
+
.gsub('{modifier}', modifier || get_direction_from_degree(step['maneuver']['bearing_after'])[0])
|
98
|
+
.strip
|
99
|
+
|
100
|
+
instruction
|
101
|
+
end
|
102
|
+
|
103
|
+
def get_direction_from_degree(degree)
|
104
|
+
OSRMTextInstructions::Utils.get_direction_from_degree(degree)
|
105
|
+
end
|
106
|
+
|
107
|
+
def use_lane(step)
|
108
|
+
raise 'No lanes hash' if !step['intersections'] || !step['intersections'][0]['lanes']
|
109
|
+
|
110
|
+
# Reduce any lane combination down to a string representing the lane config
|
111
|
+
#
|
112
|
+
# If the valid lanes look like:
|
113
|
+
# "lanes": [
|
114
|
+
# {
|
115
|
+
# "valid": true
|
116
|
+
# },
|
117
|
+
# {
|
118
|
+
# "valid": true
|
119
|
+
# },
|
120
|
+
# {
|
121
|
+
# "valid": true
|
122
|
+
# },
|
123
|
+
# {
|
124
|
+
# "valid": false
|
125
|
+
# },
|
126
|
+
# {
|
127
|
+
# "valid": false
|
128
|
+
# },
|
129
|
+
# {
|
130
|
+
# "valid": true
|
131
|
+
# }
|
132
|
+
# ]
|
133
|
+
#
|
134
|
+
# This would map to `oxo`
|
135
|
+
# And the instruction would `Keep left or right...`
|
136
|
+
|
137
|
+
diagram = []
|
138
|
+
current_lane_type = nil
|
139
|
+
|
140
|
+
step['intersections'][0]['lanes'].each do |lane|
|
141
|
+
if current_lane_type.nil? || current_lane_type != lane['valid']
|
142
|
+
if lane['valid']
|
143
|
+
diagram.push('o')
|
144
|
+
else
|
145
|
+
diagram.push('x')
|
146
|
+
end
|
147
|
+
|
148
|
+
current_lane_type = lane['valid']
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
diagram.join('')
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module OSRMTextInstructions
|
2
|
+
module Utils
|
3
|
+
def self.get_direction_from_degree(degree)
|
4
|
+
if degree >= 340 || degree <= 20
|
5
|
+
['north', 'N']
|
6
|
+
elsif degree > 20 && degree < 70
|
7
|
+
['northeast', 'NE']
|
8
|
+
elsif degree >= 70 && degree < 110
|
9
|
+
['east', 'E']
|
10
|
+
elsif degree >= 110 && degree <= 160
|
11
|
+
['southeast', 'SE']
|
12
|
+
elsif degree > 160 && degree <= 200
|
13
|
+
['south', 'S']
|
14
|
+
elsif degree > 200 && degree < 250
|
15
|
+
['southwest', 'SW']
|
16
|
+
elsif degree >= 250 && degree <= 290
|
17
|
+
['west', 'W']
|
18
|
+
elsif degree > 290 && degree < 340
|
19
|
+
['northwest', 'NW']
|
20
|
+
else
|
21
|
+
raise "Degree #{degree} invalid"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'osrm_text_instructions/version'
|
3
|
+
require 'osrm_text_instructions/utils'
|
4
|
+
require 'osrm_text_instructions/compiler'
|
5
|
+
|
6
|
+
module OSRMTextInstructions
|
7
|
+
def self.compile(step, locale: 'en', version: 'v5')
|
8
|
+
Compiler.new(load_instruction_yaml(locale), version).compile(step)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.load_instruction_yaml(locale)
|
12
|
+
YAML.load_file(File.expand_path("#{__dir__}/../i18n/#{locale}.yml"))
|
13
|
+
rescue Errno::ENOENT => e
|
14
|
+
raise "Locale #{locale} not available"
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'osrm_text_instructions/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'osrm_text_instructions'
|
8
|
+
spec.version = OSRMTextInstructions::VERSION
|
9
|
+
spec.authors = ['Felipe Zavan']
|
10
|
+
spec.email = ['felipe@zavan.me']
|
11
|
+
|
12
|
+
spec.summary = %q{A gem to transform OSRM steps into text instructions.}
|
13
|
+
spec.homepage = 'https://github.com/zavan/osrm_text_instructions'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = 'exe'
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: osrm_text_instructions
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Felipe Zavan
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-04 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.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
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: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- felipe@zavan.me
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- CODE_OF_CONDUCT.md
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- i18n/en.yml
|
72
|
+
- lib/osrm_text_instructions.rb
|
73
|
+
- lib/osrm_text_instructions/compiler.rb
|
74
|
+
- lib/osrm_text_instructions/utils.rb
|
75
|
+
- lib/osrm_text_instructions/version.rb
|
76
|
+
- osrm_text_instructions.gemspec
|
77
|
+
homepage: https://github.com/zavan/osrm_text_instructions
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.5.1
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: A gem to transform OSRM steps into text instructions.
|
101
|
+
test_files: []
|