impas-client 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,18 +1,8 @@
1
1
  *.swp
2
- *.gem
3
- *.rbc
4
- .bundle
5
- .config
6
- .yardoc
7
- Gemfile.lock
8
- InstalledFiles
9
- _yardoc
10
- coverage
11
- doc/
12
- lib/bundler/man
13
- pkg
14
- rdoc
15
- spec/reports
16
- test/tmp
17
- test/version_tmp
18
- tmp
2
+ .DS_Store
3
+ log/**/*
4
+ tmp/**/*
5
+ bin/*
6
+ vendor/gems/*
7
+ !vendor/gems/cache/
8
+ .sass-cache/*
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source 'https://rubygems.org'
2
+ gem 'webmock'
2
3
 
3
4
  # Specify your gem's dependencies in impas-client.gemspec
4
5
  gemspec
@@ -0,0 +1,36 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ impas-client (0.0.7)
5
+ faraday (~> 0.8.4)
6
+ json (~> 1.7.3)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.3.2)
12
+ crack (0.3.2)
13
+ diff-lcs (1.1.3)
14
+ faraday (0.8.4)
15
+ multipart-post (~> 1.1)
16
+ json (1.7.6)
17
+ multipart-post (1.1.5)
18
+ rspec (2.12.0)
19
+ rspec-core (~> 2.12.0)
20
+ rspec-expectations (~> 2.12.0)
21
+ rspec-mocks (~> 2.12.0)
22
+ rspec-core (2.12.2)
23
+ rspec-expectations (2.12.1)
24
+ diff-lcs (~> 1.1.3)
25
+ rspec-mocks (2.12.1)
26
+ webmock (1.9.0)
27
+ addressable (>= 2.2.7)
28
+ crack (>= 0.1.7)
29
+
30
+ PLATFORMS
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ impas-client!
35
+ rspec
36
+ webmock
data/README.md CHANGED
@@ -22,18 +22,27 @@ Or install it yourself as:
22
22
  require 'impas-client'
23
23
 
24
24
  client = Impas::Client.new({
25
- api_url:"http://impas.****.jp/",
25
+ #api_url:"http://impas.****.jp/", # デフォルトは http://impas-hideack.sqale.jp
26
26
  op_key:"*****"
27
27
  })
28
28
 
29
29
  client.add_group "sample_group1" # 集計グループ追加
30
+
30
31
  client.groups # 登録中のグループ一覧取得
32
+ => [{"name"=>"sample_group1", "key"=>"*****"}]
31
33
 
32
34
  client.add_url( # URLを集計対象へ追加
33
- "051fc80bff3afd1db52bfc3dae8f6329",
35
+ "*****",
34
36
  "http://www.youtube.com/watch?v=2HQkugdXyHY"
35
37
  )
36
38
 
39
+ client.ranking "*****", "tw" # Twitterツイート数ランキング取得
40
+ client.ranking "*****", "fb" # facebookいいね数ランキング取得
41
+ client.ranking "*****", "hatena" # はてなブックマーク数ランキング取得
42
+
43
+
44
+ # client.delete_group("*****") #集計グループの削除
45
+
37
46
  ```
38
47
 
39
48
  ## Contributing
data/Rakefile CHANGED
@@ -1,2 +1,10 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+
4
+ require 'rspec/core'
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.pattern = FileList['spec/**/*_spec.rb']
8
+ end
9
+
10
+ task :default => :spec
@@ -15,6 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Impas::Client::VERSION
17
17
 
18
+ gem.add_development_dependency 'rspec'
18
19
  gem.add_dependency "faraday", "~>0.8.4"
19
20
  gem.add_dependency "json", "~>1.7.3"
20
21
  end
@@ -62,13 +62,19 @@ module Impas
62
62
  desc["description"]["groups"]
63
63
  end
64
64
 
65
- def add_url(grp_key, url)
65
+ def add_url(grp_key, url, user = nil)
66
66
  entry_point = "/api/registration/#{grp_key}"
67
67
 
68
68
  res = @@conn.post do |req|
69
69
  req.url entry_point
70
70
  req.headers['Content-Type'] = 'application/json'
71
- req.body = "{\"url\":\"#{url}\"}"
71
+
72
+ if user.nil?
73
+ req.body = "{\"url\":\"#{url}\"}"
74
+ else
75
+ req.body = "{\"url\":\"#{url}\", \"user\":\"#{user}\"}"
76
+ end
77
+
72
78
  end
73
79
 
74
80
  if res.status == 200
@@ -1,6 +1,6 @@
1
1
  module Impas
2
2
  class Client
3
- VERSION = "0.0.7"
3
+ VERSION = "0.0.8"
4
4
  API_URL = "http://impas-hideack.sqale.jp/"
5
5
  end
6
6
  end
@@ -0,0 +1,68 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+ require 'webmock/rspec'
4
+
5
+ WebMock.allow_net_connect!
6
+ REGISTRATION_API_URL = /http:\/\/impas-hideack.sqale.jp\/api\/registration\/[a-z0-9\/]*/
7
+ RANKING_API_URL = /http:\/\/impas-hideack.sqale.jp\/api\/ranking\/[a-z0-9\/]*/
8
+
9
+ describe Impas::Client do
10
+ before do
11
+ stub_request(:post, REGISTRATION_API_URL).to_return({:body => ADD_URL_SUCCESS_RESPONSE, :status => 200})
12
+ stub_request(:get, RANKING_API_URL).to_return({:body => RANKING_URL_SUCCESS_RESPONSE, :status => 200})
13
+ @client = Impas::Client.new()
14
+ end
15
+
16
+ describe 'URL registration API' do
17
+ subject{ @client.add_url("4862f27c8b8a483f8bc74e5b8ed22211", "http://remp.jp") }
18
+ it { should == true}
19
+ end
20
+
21
+ describe 'Ranking API' do
22
+ subject{ @client.ranking("4862f27c8b8a483f8bc74e5b8ed22211", "tw").count() }
23
+ it { should == 3}
24
+ end
25
+ end
26
+
27
+ # --- Response samples ---
28
+ ADD_URL_SUCCESS_RESPONSE = <<-EOF
29
+ {
30
+ "result":"ok",
31
+ "explain":"",
32
+ "description":{}
33
+ }
34
+ EOF
35
+
36
+ RANKING_URL_SUCCESS_RESPONSE = <<-EOF
37
+ {
38
+
39
+ "result": "ok",
40
+ "explain": "",
41
+ "description": {
42
+ "ranking": [
43
+ {
44
+ "callcount": 3,
45
+ "fb": 0,
46
+ "hatena": 110,
47
+ "tw": 5019,
48
+ "url": "http://www.youtube.com/watch?v=UGP_hoQpLZQ"
49
+ },
50
+ {
51
+ "callcount": 1,
52
+ "fb": 5222,
53
+ "hatena": 18,
54
+ "tw": 1885,
55
+ "url": "http://www.youtube.com/watch?v=iyw6-KVmgow"
56
+ },
57
+ {
58
+ "callcount": 1,
59
+ "fb": 0,
60
+ "hatena": 4,
61
+ "tw": 525,
62
+ "url": "http://www.youtube.com/watch?v=r9pqRJgc5Wg"
63
+ }
64
+ ]
65
+ }
66
+ }
67
+ EOF
68
+
@@ -0,0 +1,6 @@
1
+ require 'impas-client'
2
+ require 'rspec'
3
+
4
+ RSpec.configure do |config|
5
+ end
6
+
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.7
4
+ version: 0.0.8
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: 2013-01-12 00:00:00.000000000 Z
12
+ date: 2013-03-23 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: faraday
16
32
  requirement: !ruby/object:Gem::Requirement
@@ -52,12 +68,15 @@ extra_rdoc_files: []
52
68
  files:
53
69
  - .gitignore
54
70
  - Gemfile
71
+ - Gemfile.lock
55
72
  - LICENSE
56
73
  - README.md
57
74
  - Rakefile
58
75
  - impas-client.gemspec
59
76
  - lib/impas-client.rb
60
77
  - lib/impas-client/version.rb
78
+ - spec/client_spec.rb
79
+ - spec/spec_helper.rb
61
80
  homepage: http://github.com/hideack/impas-client
62
81
  licenses: []
63
82
  post_install_message:
@@ -82,4 +101,6 @@ rubygems_version: 1.8.19
82
101
  signing_key:
83
102
  specification_version: 3
84
103
  summary: Impas API client
85
- test_files: []
104
+ test_files:
105
+ - spec/client_spec.rb
106
+ - spec/spec_helper.rb