docodoco_jp 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c46a71ef87c49fdf19d8c7f61f4faefb92b58c98
4
- data.tar.gz: 5eb81b51e8b6b3a56038afdd9039429daa09f8fe
3
+ metadata.gz: 82afce23e76299aab716e43af06229c7f29512b3
4
+ data.tar.gz: cc614ab43b7ab0e8889c105faf1f89724fd325d1
5
5
  SHA512:
6
- metadata.gz: 8028d83db86d072f6745b77b6465883e11ccfc4c76bd2249871ab5472eb44360fdd6eb57f9629421e5245f4a80163d8640a6261d6a89788740220bf589f80b99
7
- data.tar.gz: b447edd31b665545a3b768b0462698f4008bc5b8cdd8df5c9ca5938b55d8009dfd058c08bba31cb8f5a64b54a6d02d14b7e45cac9a204ba288ca5df324c2e844
6
+ metadata.gz: 518ed2cbce62a0e64ca0648b12b653fe8e334dc358a053ed5dcea032338c9a91c6524834387d23c637d26a0c9e8211095c8a0ccfa1f6d9d6e93715ffd5f58897
7
+ data.tar.gz: 5ef463b8285f573f9bd7349a1d67f65b4ab3ec3520831a8b280290c1f1fb60f3a1799641b7dddda9919b7fb0d9f4fc43d2ab301607155acb5387fddd1f0f22d7
data/README.md CHANGED
@@ -20,6 +20,17 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
+ #### * command line
24
+
25
+ Usage:
26
+ docodoco_jp config --key1=KEY1 --key2=KEY2 # Setup the API key to cli use
27
+ docodoco_jp config_check # Check configred API key
28
+ docodoco_jp help [TASK] # Describe available tasks or one specific task
29
+ docodoco_jp search [IP_ADDRESS] # Search target IP_ADDRESS infomation
30
+ docodoco_jp show_key # Show configred API key
31
+
32
+ #### * ruby script
33
+
23
34
  options = {
24
35
  ssl: false, # => default: true
25
36
  faraday_log: true, # => default: false
data/bin/docodoco_jp ADDED
@@ -0,0 +1,46 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ #
4
+ # docodoco_jp
5
+ # ----
6
+ #
7
+ # docodoco_jp - http://www.docodoco.jp api client.
8
+ #
9
+ # Usage:
10
+ # docodoco_jp config --key1=KEY1 --key2=KEY2 # Setup the API key to cli use
11
+ # docodoco_jp config_check # Check configred API key
12
+ # docodoco_jp help [TASK] # Describe available tasks or one specific task
13
+ # docodoco_jp search [IP_ADDRESS] # Search target IP_ADDRESS infomation
14
+ # docodoco_jp show_key # Show configred API key
15
+ #
16
+ #
17
+ # The MIT License (MIT)
18
+ #
19
+ # Copyright (c) 2015 Hiroshi IKEGAMI
20
+ #
21
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
22
+ # of this software and associated documentation files (the "Software"), to deal
23
+ # in the Software without restriction, including without limitation the rights
24
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25
+ # copies of the Software, and to permit persons to whom the Software is
26
+ # furnished to do so, subject to the following conditions:
27
+ #
28
+ # The above copyright notice and this permission notice shall be included in
29
+ # all copies or substantial portions of the Software.
30
+ #
31
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
37
+ # THE SOFTWARE.
38
+ #
39
+
40
+
41
+ require "docodoco_jp/cli"
42
+
43
+ DocodocoJp::CLI.start(ARGV)
44
+
45
+ __END__
46
+
data/docodoco_jp.gemspec CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Hiroshi IKEGAMI"]
10
10
  spec.email = ["hiroshi.ikegami@magicdrive.jp"]
11
11
 
12
- spec.summary = %q{Docodoco JP API Client.}
13
- spec.description = %q{Docodoco JP API Client.}
12
+ spec.summary = %q{Location service www.docodoco.jp API Client.}
13
+ spec.description = %q{Location service www.docodoco.jp API Client.}
14
14
  spec.homepage = "https://github.com/magicdrive/ruby-docodoco_jp"
15
15
  spec.license = "MIT"
16
16
 
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
+ spec.add_dependency "thor", "~> 0.0"
30
31
  spec.add_dependency "faraday", "~> 0.9"
31
32
  spec.add_dependency "hashie", "~> 3.0"
32
33
 
@@ -0,0 +1,73 @@
1
+ # coding: utf-8
2
+
3
+ require 'fileutils'
4
+ require 'thor'
5
+ require 'yaml'
6
+ require 'json'
7
+ require 'docodoco_jp'
8
+
9
+ class DocodocoJp
10
+ class CLI < Thor
11
+ desc "search [IP_ADDRESS]", "Search target IP_ADDRESS infomation"
12
+ def search(ipaddr)
13
+ $stdout.puts JSON.pretty_generate(client.search(ipaddr))
14
+ end
15
+
16
+ desc "config", "Setup the API key to cli use"
17
+ option :key1, required: true, type: :string
18
+ option :key2, required: true, type: :string
19
+ def config
20
+ buf = {"apikey1" => options[:key1], "apikey2" => options[:key2]}.to_yaml
21
+ FileUtils.mkdir_p(File.expand_path("~/.docodoco_jp/"))
22
+ File.open(File.expand_path("~/.docodoco_jp/apikey.yml"), "w") { |f| f.print(buf) }
23
+ $stdout.puts "config ok."
24
+ self.invoke(:show_keys, [], {})
25
+ end
26
+
27
+ desc "show_key", "Show configred API key"
28
+ def show_key
29
+ key1, key2 = get_apikeys()
30
+ $stdout.puts JSON.pretty_generate({apikey1: key1, apikey2: key2})
31
+ end
32
+
33
+ desc "config_check", "Check configred API key"
34
+ def config_check
35
+ result, json = client.check_user()
36
+ $stdout.puts JSON.pretty_generate(json)
37
+ end
38
+
39
+ private
40
+ def client
41
+ return @instance ||= DocodocoJp.new(*get_apikeys())
42
+ end
43
+
44
+ def get_apikeys
45
+ if File.exist?(File.expand_path("~/.docodoco_jp/apikey.yml"))
46
+ docodoco_jp_conf = YAML.load_file(File.expand_path("~/.docodoco_jp/apikey.yml", File.dirname(__FILE__)))
47
+ key1 = docodoco_jp_conf["apikey1"]
48
+ key2 = docodoco_jp_conf["apikey2"]
49
+ return key1, key2
50
+ else
51
+ print_setup_help
52
+ end
53
+ end
54
+
55
+ def print_setup_help
56
+ $stderr.puts <<-HELP
57
+ API key not found..
58
+
59
+ Gets the API key in the following URL,
60
+ please execute `docodoco_jp config --key1=KEY1 --key2=KEY2` or edit ~/.docodoco_jp/apikey.yml
61
+
62
+ `http://www.docodoco.jp`
63
+ `https://admin.docodoco.jp/signup/`
64
+
65
+ HELP
66
+ exit 1
67
+ end
68
+
69
+ end
70
+ end
71
+
72
+ __END__
73
+
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
2
 
3
3
  class DocodocoJp
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docodoco_jp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi IKEGAMI
@@ -10,6 +10,20 @@ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2015-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: faraday
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,7 +108,7 @@ dependencies:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
110
  version: '10.0'
97
- description: Docodoco JP API Client.
111
+ description: Location service www.docodoco.jp API Client.
98
112
  email:
99
113
  - hiroshi.ikegami@magicdrive.jp
100
114
  executables: []
@@ -109,11 +123,13 @@ files:
109
123
  - README.md
110
124
  - Rakefile
111
125
  - bin/console
126
+ - bin/docodoco_jp
112
127
  - bin/setup
113
128
  - docodoco_jp.gemspec
114
129
  - fixtures/sample_api_key.yml
115
130
  - lib/docodoco_jp.rb
116
131
  - lib/docodoco_jp/api_key_invalid.rb
132
+ - lib/docodoco_jp/cli.rb
117
133
  - lib/docodoco_jp/ipv4_validation_error.rb
118
134
  - lib/docodoco_jp/version.rb
119
135
  homepage: https://github.com/magicdrive/ruby-docodoco_jp
@@ -140,5 +156,6 @@ rubyforge_project:
140
156
  rubygems_version: 2.4.5
141
157
  signing_key:
142
158
  specification_version: 4
143
- summary: Docodoco JP API Client.
159
+ summary: Location service www.docodoco.jp API Client.
144
160
  test_files: []
161
+ has_rdoc: