getclicky 0.1.beta1 → 0.1.beta2
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.
- data/LICENSE +22 -0
- data/README.rdoc +4 -31
- data/lib/getclicky/client.rb +8 -7
- data/lib/getclicky/request.rb +15 -17
- data/lib/getclicky/response.rb +5 -12
- data/lib/getclicky/types.rb +1 -9
- data/lib/getclicky/version.rb +1 -8
- data/spec/getclicky/client_spec.rb +2 -2
- data/spec/getclicky/request_spec.rb +18 -3
- data/spec/getclicky_spec.rb +1 -1
- metadata +16 -15
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2011 Peterson Ferreira
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -26,32 +26,28 @@ Then you can simply instantiate a new Getclicky::Client object.
|
|
26
26
|
All types in API are methods here looks, you can find all types http://getclicky.com/help/api:
|
27
27
|
|
28
28
|
getClicky.pages()
|
29
|
-
|
30
29
|
getClicky.tweets()
|
31
|
-
|
32
30
|
getClicky.visitors()
|
33
31
|
|
34
32
|
In each method you can pass optional parameters as a hash looks:
|
35
33
|
|
36
34
|
getClicky.visitors(:date => "last-7-days", :daily => 1)
|
37
|
-
|
38
35
|
getClicky.item(:date => "last-7-days", :item => "google.com")
|
39
|
-
|
40
36
|
getClicky.visitors_list(:domain => "google.com")
|
41
37
|
|
42
38
|
By default getclicky API returns XML as data, but you can change adding :output in parameter like:
|
43
39
|
|
44
40
|
===== JSON
|
45
41
|
|
46
|
-
getClicky.visitors(:output =>
|
42
|
+
getClicky.visitors(:output => :json, :date => "last-7-days", :daily => 1)
|
47
43
|
|
48
44
|
===== CSV
|
49
45
|
|
50
|
-
getClicky.visitors(:output =>
|
46
|
+
getClicky.visitors(:output => :csv, :date => "last-7-days", :daily => 1)
|
51
47
|
|
52
48
|
===== PHP
|
53
49
|
|
54
|
-
getClicky.visitors(:output =>
|
50
|
+
getClicky.visitors(:output => :php, :date => "last-7-days", :daily => 1)
|
55
51
|
|
56
52
|
|
57
53
|
This library does't support multiple types yet.
|
@@ -63,27 +59,4 @@ This library does't support multiple types yet.
|
|
63
59
|
|
64
60
|
== Maintainer
|
65
61
|
|
66
|
-
* Peterson Ferreira (petersonferreiras@gmail.com)
|
67
|
-
|
68
|
-
== License
|
69
|
-
|
70
|
-
(The MIT License)
|
71
|
-
|
72
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
73
|
-
a copy of this software and associated documentation files (the
|
74
|
-
'Software'), to deal in the Software without restriction, including
|
75
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
76
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
77
|
-
permit persons to whom the Software is furnished to do so, subject to
|
78
|
-
the following conditions:
|
79
|
-
|
80
|
-
The above copyright notice and this permission notice shall be
|
81
|
-
included in all copies or substantial portions of the Software.
|
82
|
-
|
83
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
84
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
85
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
86
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
87
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
88
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
89
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
62
|
+
* Peterson Ferreira (petersonferreiras@gmail.com)
|
data/lib/getclicky/client.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
module Getclicky
|
2
|
-
class Client
|
3
|
-
# Dynamically defines the methods to be called
|
2
|
+
class Client
|
3
|
+
# Dynamically defines the methods to be called.
|
4
|
+
# This is a interface of library.
|
4
5
|
#
|
5
6
|
Getclicky::Types::ALL.each do |type|
|
6
|
-
class_eval <<-RUBY, __FILE__, __LINE__
|
7
|
-
def #{type.to_s.downcase}(params = {})
|
8
|
-
response = Getclicky::Request.
|
9
|
-
response.data
|
10
|
-
end
|
7
|
+
class_eval <<-RUBY, __FILE__, __LINE__
|
8
|
+
def #{type.to_s.downcase}(params = {}) # def pages(params = {})
|
9
|
+
response = Getclicky::Request.new(:#{type}, params).get # response = Getclicky::Request.new(:pages, params).get
|
10
|
+
response.data # response.data
|
11
|
+
end # end
|
11
12
|
RUBY
|
12
13
|
end
|
13
14
|
end
|
data/lib/getclicky/request.rb
CHANGED
@@ -1,21 +1,19 @@
|
|
1
|
-
# Getclicky API Analytics Ruby Client Library
|
2
|
-
#
|
3
|
-
# Allows access to the getclicky.com Analytics API using the ruby programming language.
|
4
|
-
#
|
5
|
-
# Copyright (c) 2011+ Peterson Ferreira
|
6
|
-
# See LICENSE for details
|
7
|
-
#
|
8
1
|
module Getclicky
|
9
|
-
|
2
|
+
class Request
|
10
3
|
include HTTParty
|
11
|
-
|
4
|
+
|
5
|
+
attr_accessor :type, :params
|
6
|
+
|
7
|
+
def initialize(type, params = {})
|
8
|
+
@type = type
|
9
|
+
@params = params
|
10
|
+
end
|
12
11
|
|
13
12
|
# Handle all HTTP::Get request, wrapping all the logic
|
14
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
#
|
14
|
+
def get
|
15
|
+
response = self.class.get(Getclicky.endpoint, :query => build_params(@type, @params))
|
16
|
+
|
19
17
|
case response.code
|
20
18
|
when "404"
|
21
19
|
raise Getclicky::NotFoundError
|
@@ -23,12 +21,12 @@ module Getclicky
|
|
23
21
|
Getclicky::Response.new(response)
|
24
22
|
end
|
25
23
|
end
|
26
|
-
|
27
|
-
# Build the hash of options for
|
24
|
+
|
25
|
+
# Build the hash of options for make resquest to API
|
28
26
|
#
|
29
27
|
def build_params(type, params = {})
|
30
28
|
query = { :site_id => Getclicky.site_id, :sitekey => Getclicky.sitekey, :type => type }
|
31
|
-
query.merge(params)
|
29
|
+
query.merge(params) if params
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
data/lib/getclicky/response.rb
CHANGED
@@ -1,20 +1,13 @@
|
|
1
|
-
# Getclicky API Analytics Ruby Client Library
|
2
|
-
#
|
3
|
-
# Allows access to the getclicky.com Analytics API using the ruby programming language.
|
4
|
-
#
|
5
|
-
# Copyright (c) 2011+ Peterson Ferreira
|
6
|
-
# See LICENSE for details
|
7
|
-
#
|
8
1
|
module Getclicky
|
9
2
|
class Response
|
10
|
-
attr_accessor :
|
3
|
+
attr_accessor :item
|
11
4
|
|
12
|
-
def
|
13
|
-
@
|
5
|
+
def initialize(item)
|
6
|
+
@item = item
|
14
7
|
end
|
15
|
-
|
8
|
+
|
16
9
|
def data
|
17
|
-
@
|
10
|
+
@item.body
|
18
11
|
end
|
19
12
|
end
|
20
13
|
end
|
data/lib/getclicky/types.rb
CHANGED
@@ -1,13 +1,5 @@
|
|
1
|
-
# Getclicky API Analytics Ruby Client Library
|
2
|
-
#
|
3
|
-
# Allows access to the getclicky.com Analytics API using the ruby programming language.
|
4
|
-
#
|
5
|
-
# Copyright (c) 2011+ Peterson Ferreira
|
6
|
-
# See LICENSE for details
|
7
|
-
#
|
8
1
|
module Getclicky
|
9
|
-
module Types
|
10
|
-
|
2
|
+
module Types
|
11
3
|
# Request types that the API accepts.
|
12
4
|
#
|
13
5
|
ALL = [
|
data/lib/getclicky/version.rb
CHANGED
@@ -1,15 +1,8 @@
|
|
1
|
-
# Getclicky API Analytics Ruby Client Library
|
2
|
-
#
|
3
|
-
# Allows access to the getclicky.com Analytics API using the ruby programming language.
|
4
|
-
#
|
5
|
-
# Copyright (c) 2011+ Peterson Ferreira
|
6
|
-
# See LICENSE for details
|
7
|
-
#
|
8
1
|
module Getclicky
|
9
2
|
module Version
|
10
3
|
MAJOR = 0
|
11
4
|
MINOR = 1
|
12
|
-
PATCH = "
|
5
|
+
PATCH = "beta2"
|
13
6
|
STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
14
7
|
end
|
15
8
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Getclicky::Client do
|
4
|
-
context "methods
|
4
|
+
context "should be create methods to make request to API" do
|
5
5
|
Getclicky::Types::ALL.each do |type|
|
6
6
|
class_eval <<-RUBY, __FILE__, __LINE__
|
7
7
|
it "should be implement #{type.to_s} method" do
|
8
8
|
subject.should respond_to(type)
|
9
9
|
end
|
10
10
|
RUBY
|
11
|
-
end
|
11
|
+
end
|
12
12
|
end
|
13
13
|
end
|
@@ -1,8 +1,23 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Getclicky::Request do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
|
5
|
+
subject {
|
6
|
+
Getclicky::Request.new(:pages, :limit => 10, :hourly => 1)
|
7
|
+
}
|
8
|
+
|
9
|
+
its(:type) { should eql (:pages) }
|
10
|
+
its(:params) { should eql ({:limit => 10, :hourly => 1})}
|
11
|
+
|
12
|
+
context "method build_params" do
|
13
|
+
it "should be set the right parameters" do
|
14
|
+
params = subject.build_params(:pages, :limit => 10, :hourly => 1)
|
15
|
+
params.should == { :site_id => Getclicky.site_id, :sitekey => Getclicky.sitekey, :type => :pages, :limit => 10, :hourly => 1}
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should be leave hash parameters blank" do
|
19
|
+
params = subject.build_params(:pages)
|
20
|
+
params.should == { :site_id => Getclicky.site_id, :sitekey => Getclicky.sitekey, :type => :pages}
|
21
|
+
end
|
7
22
|
end
|
8
23
|
end
|
data/spec/getclicky_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: getclicky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.beta2
|
5
5
|
prerelease: 4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
12
|
+
date: 2011-08-17 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &70272461720840 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70272461720840
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: httparty
|
27
|
-
requirement: &
|
27
|
+
requirement: &70272461720340 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.7.8
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70272461720340
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70272461719860 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '2.6'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70272461719860
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: test_notifier
|
49
|
-
requirement: &
|
49
|
+
requirement: &70272461719400 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0.3'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70272461719400
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: fakeweb
|
60
|
-
requirement: &
|
60
|
+
requirement: &70272461718940 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '1.3'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70272461718940
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: ruby-debug19
|
71
|
-
requirement: &
|
71
|
+
requirement: &70272461718480 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0.11'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70272461718480
|
80
80
|
description: Ruby Wrapper for GetClicky API Analytics
|
81
81
|
email:
|
82
82
|
- petersonferreiras@gmail.com
|
@@ -86,6 +86,7 @@ extra_rdoc_files: []
|
|
86
86
|
files:
|
87
87
|
- .gitignore
|
88
88
|
- Gemfile
|
89
|
+
- LICENSE
|
89
90
|
- README.rdoc
|
90
91
|
- Rakefile
|
91
92
|
- getclicky.gemspec
|
@@ -120,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
121
|
version: 1.3.1
|
121
122
|
requirements: []
|
122
123
|
rubyforge_project:
|
123
|
-
rubygems_version: 1.8.
|
124
|
+
rubygems_version: 1.8.8
|
124
125
|
signing_key:
|
125
126
|
specification_version: 3
|
126
127
|
summary: Ruby Wrapper for GetClicky API Analytics
|