jp_stations 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/.circleci/config.yml +30 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +16 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +51 -0
- data/LICENSE.txt +21 -0
- data/README.md +54 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/jp_station.yml +26379 -0
- data/jp_stations.gemspec +31 -0
- data/lib/jp_stations/version.rb +3 -0
- data/lib/jp_stations.rb +41 -0
- metadata +104 -0
data/jp_stations.gemspec
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
require 'jp_stations/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'jp_stations'
|
|
7
|
+
spec.version = JpStations::VERSION
|
|
8
|
+
spec.authors = ['hatsu38']
|
|
9
|
+
spec.email = ['hajiwata0308@gmail.com']
|
|
10
|
+
|
|
11
|
+
spec.summary = ' Provide All Station Data in Japan. '
|
|
12
|
+
spec.description = ' Provide All Station Data in Japan. '
|
|
13
|
+
spec.homepage = 'https://github.com/hatsu38/jp_stations'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
|
|
16
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
17
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
|
18
|
+
|
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
21
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
23
|
+
end
|
|
24
|
+
spec.bindir = 'exe'
|
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
26
|
+
spec.require_paths = ['lib']
|
|
27
|
+
|
|
28
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
|
29
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
31
|
+
end
|
data/lib/jp_stations.rb
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'jp_stations/version'
|
|
2
|
+
require 'yaml'
|
|
3
|
+
|
|
4
|
+
module JpStations
|
|
5
|
+
class List
|
|
6
|
+
JP_STATION_FILE_PATH = '../jp_station.yml'.freeze
|
|
7
|
+
|
|
8
|
+
attr_accessor :kanji, :kana
|
|
9
|
+
|
|
10
|
+
def self.data
|
|
11
|
+
filepath = File.join(File.dirname(__FILE__), JP_STATION_FILE_PATH)
|
|
12
|
+
YAML.load_file(filepath)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.all
|
|
16
|
+
data.map { |value| build(value) }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.build(obj_station)
|
|
20
|
+
station = new
|
|
21
|
+
|
|
22
|
+
station.kanji = obj_station[:kanji]
|
|
23
|
+
station.kana = obj_station[:kana]
|
|
24
|
+
|
|
25
|
+
station
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.find(word)
|
|
29
|
+
return if word.nil?
|
|
30
|
+
|
|
31
|
+
obj_station = search(word)
|
|
32
|
+
obj_station.map { |station| build(station) }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.search(word)
|
|
36
|
+
data.select do |station|
|
|
37
|
+
station[:kana].include?(word) || station[:kanji].include?(word)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: jp_stations
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- hatsu38
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-12-07 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: '2.0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '2.0'
|
|
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: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
description: " Provide All Station Data in Japan. "
|
|
56
|
+
email:
|
|
57
|
+
- hajiwata0308@gmail.com
|
|
58
|
+
executables: []
|
|
59
|
+
extensions: []
|
|
60
|
+
extra_rdoc_files: []
|
|
61
|
+
files:
|
|
62
|
+
- ".circleci/config.yml"
|
|
63
|
+
- ".gitignore"
|
|
64
|
+
- ".rspec"
|
|
65
|
+
- ".rubocop.yml"
|
|
66
|
+
- ".travis.yml"
|
|
67
|
+
- CODE_OF_CONDUCT.md
|
|
68
|
+
- Gemfile
|
|
69
|
+
- Gemfile.lock
|
|
70
|
+
- LICENSE.txt
|
|
71
|
+
- README.md
|
|
72
|
+
- Rakefile
|
|
73
|
+
- bin/console
|
|
74
|
+
- bin/setup
|
|
75
|
+
- jp_station.yml
|
|
76
|
+
- jp_stations.gemspec
|
|
77
|
+
- lib/jp_stations.rb
|
|
78
|
+
- lib/jp_stations/version.rb
|
|
79
|
+
homepage: https://github.com/hatsu38/jp_stations
|
|
80
|
+
licenses:
|
|
81
|
+
- MIT
|
|
82
|
+
metadata:
|
|
83
|
+
homepage_uri: https://github.com/hatsu38/jp_stations
|
|
84
|
+
source_code_uri: https://github.com/hatsu38/jp_stations
|
|
85
|
+
post_install_message:
|
|
86
|
+
rdoc_options: []
|
|
87
|
+
require_paths:
|
|
88
|
+
- lib
|
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
|
+
requirements:
|
|
91
|
+
- - ">="
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: '0'
|
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
|
+
requirements:
|
|
96
|
+
- - ">="
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
version: '0'
|
|
99
|
+
requirements: []
|
|
100
|
+
rubygems_version: 3.0.6
|
|
101
|
+
signing_key:
|
|
102
|
+
specification_version: 4
|
|
103
|
+
summary: Provide All Station Data in Japan.
|
|
104
|
+
test_files: []
|