machiawase 0.4.0 → 0.5.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: 5daaa6bc7d71d7b055b35b590e4b9590a58aa05e
4
- data.tar.gz: 6e8e8e6494da115a06435ae08f86451365ca7db6
3
+ metadata.gz: a59e3325556437023b8d609451fffc6c4ef30805
4
+ data.tar.gz: f7553855c8764924347e525b7a5df87a958b6dca
5
5
  SHA512:
6
- metadata.gz: 8699b0fb6002770b15c6161601672c7b8fc54839d0a6784aa136c293c4d7cefa4ef8164a4d9add0f8b6d4efc89b6d61d2e7943370b4ee0bc23dbc4af00340a12
7
- data.tar.gz: bf2a7bf5184f4c914bff6fc51c0387596e493d08a02308917f684b664f7944c372cb88e60d1d7f197461c27edf9a45ca996ad42301f7875ebb8b3fbb3edb33b6
6
+ metadata.gz: 72e490d88ae4e99129426f33bf8c140864409b1637d1998fafe442ab9fe46c33fbbb9b204131206660bb9ab1648ac12406721d8b52efdf3444418e7a11728759
7
+ data.tar.gz: cb6f8069c9b808f2b80e83f829cf96ed62473358e4dcfce78d77c19887d27ee518c7eea454d980c75f067d99185b3b13257268b55ab39b6cf47b8b3b8a2cbf98
data/README.md CHANGED
@@ -17,6 +17,7 @@ Or install it yourself as:
17
17
  $ gem install machiawase
18
18
 
19
19
  ## Usage
20
+ ### As a Command
20
21
 
21
22
  $ machiawase PLACE_A PLACE_B
22
23
 
@@ -28,6 +29,10 @@ or
28
29
 
29
30
  $ machiawase 横浜 東京 川崎
30
31
 
32
+ ### As a Library
33
+
34
+ see <http://rubydoc.info/gems/machiawase>
35
+
31
36
  ## Contributing
32
37
 
33
38
  1. Fork it
@@ -2,5 +2,40 @@
2
2
  # -*- coding: utf-8 -*-
3
3
  require 'rubygems'
4
4
  require 'machiawase'
5
+ require 'optparse'
6
+ require 'ostruct'
7
+
8
+ options = OpenStruct.new
9
+ options.show_all = false
10
+
11
+ opt_parser = OptionParser.new do |opts|
12
+ opts.banner = 'Usage: machiawase PLACE1 PLACE2 ... [options]'
13
+
14
+ opts.separator ""
15
+ opts.separator "Specific options:"
16
+
17
+ opts.on('-a', '--all', 'Show all informations of the result with JSON format') {
18
+ options.show_all = true
19
+ }
20
+
21
+ opts.separator ""
22
+ opts.separator "Common options:"
23
+
24
+ # No argument, shows at tail. This will print an options summary.
25
+ opts.on_tail("-h", "--help", "Show this message") do
26
+ puts opts
27
+ exit
28
+ end
29
+
30
+ # Another typical switch to print the version.
31
+ opts.on_tail("-v", "--version", "Show version") do
32
+ puts Machiawase::VERSION
33
+ exit
34
+ end
35
+ end
36
+
37
+ places = opt_parser.parse(ARGV)
38
+ result = Machiawase.where(*places)
39
+ puts options.show_all ? result.to_json : result.address
40
+
5
41
 
6
- puts Machiawase.where(*ARGV).address
@@ -12,13 +12,7 @@ module Machiawase
12
12
 
13
13
  # @param argv [Array<Place>] the array of places.
14
14
  # @return [Place] the place to rendezvous.
15
- def self.where(*argv)
16
- require 'optparse'
17
- opt = OptionParser.new do |opt|
18
- opt.version = VERSION
19
- end
20
- addresses = opt.parse(argv)
21
-
15
+ def self.where(*addresses)
22
16
  places = Array.new
23
17
  addresses.each do |address|
24
18
  g = Place.geocode(address)
@@ -1,3 +1,3 @@
1
1
  module Machiawase
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: machiawase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - zakuni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-03 00:00:00.000000000 Z
11
+ date: 2013-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -89,14 +89,12 @@ executables:
89
89
  extensions: []
90
90
  extra_rdoc_files: []
91
91
  files:
92
- - .autotest
93
92
  - .gitignore
94
93
  - Gemfile
95
94
  - Guardfile
96
95
  - LICENSE
97
96
  - README.md
98
97
  - Rakefile
99
- - autotest/discover.rb
100
98
  - bin/machiawase
101
99
  - lib/machiawase.rb
102
100
  - lib/machiawase/place.rb
data/.autotest DELETED
@@ -1,9 +0,0 @@
1
- Autotest.add_hook(:initialize) {|at|
2
- at.add_exception %r{^\.git} # ignore Version Control System
3
- at.add_exception %r{^./tmp} # ignore temp files, lest autotest will run again, and again...
4
- # at.clear_mappings #take out the default (test/test*rb)
5
- at.add_mapping(%r{^lib/.*\.rb$}) {|f, _|
6
- Dir['spec/**/*_spec.rb']
7
- }
8
- nil
9
- }
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # -*- coding: utf-8 -*-
3
- Autotest.add_discovery { "rspec2" }