japanese-train-access 0.1.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17220434709eea9ccafce3e94a2163d634c35de5
4
- data.tar.gz: bc9dcf4240849d0932daf901988343b32549d2eb
3
+ metadata.gz: e291f3acfe642a675ddeb5870171c11fce01f179
4
+ data.tar.gz: 3892b55c35a0259f899ba91ae5e71b5f714dfbb4
5
5
  SHA512:
6
- metadata.gz: 2a396ffe39eb7c6f8f4ef1ac9a52369bafb3b78f322e0f7ae838f9830046830550c668b0a046f547b8cb0c618a19c90fe058dbc56109aa55d1881ebfa69aa2f2
7
- data.tar.gz: 6de62a0e45740f79f48bf27ac9a4431aced4164f3b7ada54718211803168ec880a8eb84699eb13e2f7aa126d245da9f3c73c9cf88909f1f5c1db6deae26115c3
6
+ metadata.gz: 08d81370f702f88b97f084c6ec7ac2533711168b94c1d0772d8b73c8614271b814d7651c851c18b4d170115f6d5f9870565c72cdf8f15ba9d3ffd5deb2531d9a
7
+ data.tar.gz: b9ed7b8d4876e925599172e2b32dba82705e8adfb0671e85208a7e931ed531c0c7d36f40fc851a41b3d7aa53fd46a1b1659797ae17618276cb555e6b2a1554d1
Binary file
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'japanese/train/access'
4
+
5
+ JapaneseTrainAccess::CLI.start
Binary file
@@ -1,7 +1,7 @@
1
1
  module Japanese
2
2
  module Train
3
3
  module Access
4
- VERSION = "0.1.0"
4
+ VERSION = "1.0.0"
5
5
  end
6
6
  end
7
7
  end
@@ -2,36 +2,43 @@ require "japanese/train/access/version"
2
2
  require 'nokogiri'
3
3
  require 'open-uri'
4
4
  require 'pry'
5
+ require 'thor'
6
+ require "japanese/train/cli"
7
+
5
8
  module Japanese
6
9
  module Train
7
10
  module Access
8
- start = gets.strip
9
- finish = gets.strip
11
+ def self.route
12
+ puts "出発駅を入力してください"
13
+ start = STDIN.gets.strip
14
+ puts "終着駅を入力してください"
15
+ finish = STDIN.gets.strip
10
16
 
11
17
 
12
- url = "http://transit.yahoo.co.jp/search/result?flatlon=&from=#{start}&tlatlon=&to=#{finish}"
13
- url_escape = URI.escape(url)
14
- page = Nokogiri::HTML.parse(open(url_escape).read)
18
+ url = "http://transit.yahoo.co.jp/search/result?flatlon=&from=#{start}&tlatlon=&to=#{finish}"
19
+ url_escape = URI.escape(url)
20
+ page = Nokogiri::HTML.parse(open(url_escape).read)
15
21
 
16
22
 
17
23
 
18
- 3.times do |i|
19
- route = "ルート#{i+1}"
20
- route_box = page.css("#route0#{i+1}")
24
+ 3.times do |i|
25
+ route = "ルート#{i+1}"
26
+ route_box = page.css("#route0#{i+1}")
21
27
 
22
- puts route
23
- puts route_box.css('.routeSummary .time').text
24
- puts route_box.css('.fare span').text.match(/\d+/).to_s + '円'
25
- time = route_box.css('.routeDetail .station .time').map(&:text).map(&:strip)
26
- station = route_box.css('.station dl dt a').map(&:text)
27
- access = route_box.css('.access div').text.delete("[train]").strip.split
28
- #binding pry
29
- station.count.times do |i|
30
- puts time[i] + " " + station[i]
31
- puts access[i]
32
- next unless access
28
+ puts route
29
+ puts route_box.css('.routeSummary .time').text
30
+ puts route_box.css('.fare span').text.match(/\d+/).to_s + '円'
31
+ time = route_box.css('.routeDetail .station .time').map(&:text).map(&:strip)
32
+ station = route_box.css('.station dl dt a').map(&:text)
33
+ access = route_box.css('.access div').text.delete("[train]").strip.split
34
+ #binding pry
35
+ station.count.times do |i|
36
+ puts time[i] + " " + station[i]
37
+ puts access[i]
38
+ next unless access
39
+ end
40
+ end
33
41
  end
34
42
  end
35
- end
36
43
  end
37
44
  end
@@ -0,0 +1,11 @@
1
+ require 'japanese/train/access'
2
+ require 'thor'
3
+
4
+ module JapaneseTrainAccess
5
+ class CLI < Thor
6
+ desc "jta", "If you want to seach train access information in japan near by now time."
7
+ def jta
8
+ Japanese::Train::Access.route
9
+ end
10
+ end
11
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: japanese-train-access
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - haneru
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-19 00:00:00.000000000 Z
11
+ date: 2017-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -95,11 +95,15 @@ files:
95
95
  - LICENSE.txt
96
96
  - README.md
97
97
  - Rakefile
98
+ - bin/.japanese-train-access.swp
98
99
  - bin/console
100
+ - bin/japanese-train-access
99
101
  - bin/setup
100
102
  - japanese-train-access.gemspec
103
+ - lib/japanese/train/.cli.rb.swp
101
104
  - lib/japanese/train/access.rb
102
105
  - lib/japanese/train/access/version.rb
106
+ - lib/japanese/train/cli.rb
103
107
  homepage: https://github.com/haneru/japanese-train-access
104
108
  licenses:
105
109
  - MIT