impas-client 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -0
- data/impas-client.gemspec +3 -1
- data/lib/impas-client.rb +40 -2
- data/lib/impas-client/version.rb +3 -2
- metadata +20 -4
data/README.md
CHANGED
@@ -2,6 +2,20 @@
|
|
2
2
|
|
3
3
|
TODO: Write a gem description
|
4
4
|
|
5
|
+
## Synopsys
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
require 'impas-client'
|
9
|
+
client = Impas::Client.new({
|
10
|
+
api_url:"http://local.impas-hideack.sqale.jp/",
|
11
|
+
op_key:"4109b1be1e6a08b9f0b7ef2fa84c3e20"
|
12
|
+
})
|
13
|
+
|
14
|
+
client.add_group "foobar" # 集計グループ追加
|
15
|
+
client.groups # 登録中のグループ一覧取得
|
16
|
+
|
17
|
+
```
|
18
|
+
|
5
19
|
## Installation
|
6
20
|
|
7
21
|
Add this line to your application's Gemfile:
|
data/impas-client.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = ["hide.terai@gmail.com"]
|
7
7
|
gem.description = "impas client"
|
8
8
|
gem.summary = "impas client"
|
9
|
-
gem.homepage = ""
|
9
|
+
gem.homepage = "http://github.com/hideack/impas-client"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
12
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -14,4 +14,6 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.name = "impas-client"
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = Impas::Client::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency "faraday", "~>0.8.4"
|
17
19
|
end
|
data/lib/impas-client.rb
CHANGED
@@ -1,7 +1,45 @@
|
|
1
1
|
require "impas-client/version"
|
2
|
+
require 'faraday'
|
2
3
|
|
3
4
|
module Impas
|
4
|
-
|
5
|
-
|
5
|
+
class Client
|
6
|
+
attr_accessor :api_url, :op_key
|
7
|
+
|
8
|
+
def initialize(args)
|
9
|
+
@api_url = (args[:api_url].nil?) ? API_URL : args[:api_url]
|
10
|
+
@op_key = args[:op_key]
|
11
|
+
|
12
|
+
@@conn = Faraday.new(:url => @api_url) do |faraday|
|
13
|
+
faraday.request :url_encoded # form-encode POST params
|
14
|
+
faraday.response :logger # log requests to STDOUT
|
15
|
+
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_group(group_name)
|
20
|
+
entry_point = "/api/group/#{@op_key}"
|
21
|
+
|
22
|
+
@@conn.post do |req|
|
23
|
+
req.url entry_point
|
24
|
+
req.headers['Content-Type'] = 'application/json'
|
25
|
+
req.body = "{\"name\":\"#{group_name}\"}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def groups
|
30
|
+
entry_point = "/api/group/#{@op_key}"
|
31
|
+
@@conn.get entry_point
|
32
|
+
end
|
33
|
+
|
34
|
+
def add_url(grp_key, url)
|
35
|
+
entry_point = "/api/registration/#{grp_key}"
|
36
|
+
|
37
|
+
@@conn.post do |req|
|
38
|
+
req.url entry_point
|
39
|
+
req.headers['Content-Type'] = 'application/json'
|
40
|
+
req.body = "{\"url\":\"#{url}\"}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
6
44
|
end
|
7
45
|
end
|
data/lib/impas-client/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: impas-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
13
|
-
dependencies:
|
12
|
+
date: 2012-12-31 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: faraday
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.8.4
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.8.4
|
14
30
|
description: impas client
|
15
31
|
email:
|
16
32
|
- hide.terai@gmail.com
|
@@ -26,7 +42,7 @@ files:
|
|
26
42
|
- impas-client.gemspec
|
27
43
|
- lib/impas-client.rb
|
28
44
|
- lib/impas-client/version.rb
|
29
|
-
homepage:
|
45
|
+
homepage: http://github.com/hideack/impas-client
|
30
46
|
licenses: []
|
31
47
|
post_install_message:
|
32
48
|
rdoc_options: []
|