webandy-ruby-clicky 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,6 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ lib/config.yml
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Andy Atkinson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,21 @@
1
+ = ruby-clicky
2
+
3
+ Ruby access to the Clicky web analytics tool. http://getclicky.com/
4
+ For usage see the test file.
5
+ More details are here: http://getclicky.com/forums/?id=2668
6
+
7
+
8
+ == Note on Patches/Pull Requests
9
+
10
+ * Fork the project.
11
+ * Make your feature addition or bug fix.
12
+ * Add tests for it. This is important so I don't break it in a
13
+ future version unintentionally.
14
+ * Commit, do not mess with rakefile, version, or history.
15
+ (if you want to have your own version, that is fine but
16
+ bump version in a commit by itself I can ignore when I pull)
17
+ * Send me a pull request. Bonus points for topic branches.
18
+
19
+ == Copyright
20
+
21
+ Copyright (c) 2009 Andy Atkinson. See LICENSE for details.
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "ruby-clicky"
8
+ gem.summary = %Q{clicky stats for ruby}
9
+ gem.description = %Q{log traffic to the clicky web analytics stat app}
10
+ gem.email = "andy@webandy.com"
11
+ gem.homepage = "http://github.com/webandy/ruby-clicky"
12
+ gem.authors = ["Andy Atkinson"]
13
+ gem.add_development_dependency "thoughtbot-shoulda"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
18
+ end
19
+
20
+ require 'rake/testtask'
21
+ Rake::TestTask.new(:test) do |test|
22
+ test.libs << 'lib' << 'test'
23
+ test.pattern = 'test/**/*_test.rb'
24
+ test.verbose = true
25
+ end
26
+
27
+ begin
28
+ require 'rcov/rcovtask'
29
+ Rcov::RcovTask.new do |test|
30
+ test.libs << 'test'
31
+ test.pattern = 'test/**/*_test.rb'
32
+ test.verbose = true
33
+ end
34
+ rescue LoadError
35
+ task :rcov do
36
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ end
38
+ end
39
+
40
+ task :test => :check_dependencies
41
+
42
+ task :default => :test
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ if File.exist?('VERSION')
47
+ version = File.read('VERSION')
48
+ else
49
+ version = ""
50
+ end
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "ruby-clicky #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.3
@@ -0,0 +1,6 @@
1
+ SITE_ID:
2
+ 364926
3
+ SITEKEY_ADMIN:
4
+ e59ff97941044f85df5297e1c302d260
5
+ DATABASE_SERVER:
6
+ db11
@@ -0,0 +1,98 @@
1
+ # RubyClicky A ruby library to access the GetClicky.com API
2
+ # Copyright (C) 2009 John Nagro
3
+ # Converted to ruby-clicky gem and modified by Andy Atkinson September 2009
4
+ #
5
+ # This program is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU General Public License
7
+ # as published by the Free Software Foundation; either version 2
8
+ # of the License, or (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
+
19
+ # Basically a straight port of GetClicky official PHP API function
20
+ # http://getclicky.com/clicky_log.phps
21
+
22
+ require 'uri'
23
+ require 'open-uri'
24
+ require 'yaml'
25
+
26
+ class GetClicky
27
+
28
+ begin
29
+ # place a clicky.yml file in the config directory of your Rails app
30
+ config = YAML::load_file("config/clicky.yml")
31
+ rescue
32
+ # sample config used by test
33
+ config = YAML::load_file("lib/clicky.sample.yml")
34
+ end
35
+ SITE_ID = config['SITE_ID']
36
+ SITEKEY_ADMIN = config['SITEKEY_ADMIN']
37
+ DATABASE_SERVER = config['DATABASE_SERVER']
38
+
39
+ VALID_TYPES = ["pageview", "download", "outbound", "click", "custom", "goal"]
40
+
41
+ def self.log(args)
42
+
43
+ type = args[:type]
44
+ type = "pageview" unless VALID_TYPES.include?(type)
45
+
46
+ base_uri = "http://static.getclicky.com/in.php?site_id=#{SITE_ID}&srv=#{DATABASE_SERVER}&sitekey_admin=#{SITEKEY_ADMIN}&type=#{type}"
47
+
48
+ # we need either a session_id or an ip_address...
49
+ if(args[:session_id].is_a?(Numeric))
50
+ base_uri += "&session_id=#{args[:session_id.to_i]}"
51
+ elsif( (args[:ip_address] =~ /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/) != nil )
52
+ base_uri += "&ip_address=#{args[:ip_address]}"
53
+ else
54
+ return false
55
+ end
56
+
57
+ # goals can come in as integer or array, for convenience
58
+ if(args[:goal].is_a?(Numeric))
59
+ base_uri += "&goal=#{args[:goal]}"
60
+ elsif(args[:goal].is_a?(Hash) && args[:goal][:id].is_a?(Numeric))
61
+ args[:goal].each do |key,value|
62
+ base_uri += "&goal[#{URI.escape(key)}]=#{URI.escape(value)}"
63
+ end
64
+ end
65
+
66
+ # custom data, must come in as array of key=>values
67
+ if(args[:custom].is_a?(Hash))
68
+ args[:custom].each do |key,value|
69
+ base_uri += "&custom[#{URI.escape(key)}]=#{URI.escape(value)}"
70
+ end
71
+ end
72
+
73
+ case args[:type]
74
+ when "outbound"
75
+ return false unless (args[:href] =~ /^(https?|telnet|ftp)/) != nil
76
+ else
77
+ # all other action types must start with either a / or a #
78
+ args[:href] = "/#{args[:href]}" if((args[:href] =~ /^(\/|\#)/) == nil)
79
+ end
80
+
81
+ base_uri += "&href=#{URI.escape(args[:href])}"
82
+
83
+ if(args[:title])
84
+ base_uri += "&title=#{URI.escape(args[:tite])}"
85
+ end
86
+
87
+ if(args[:ref])
88
+ base_uri += "&ref=#{URI.escape(args[:ref])}"
89
+ end
90
+
91
+ if(args[:ua])
92
+ base_uri += "&ua=#{URI.escape(args[:ua])}"
93
+ end
94
+
95
+ return open(base_uri) ? true : false
96
+ end
97
+
98
+ end
@@ -0,0 +1,55 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{ruby-clicky}
8
+ s.version = "0.1.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Andy Atkinson"]
12
+ s.date = %q{2009-09-06}
13
+ s.description = %q{log traffic to the clicky web analytics stat app}
14
+ s.email = %q{andy@webandy.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/clicky.sample.yml",
27
+ "lib/ruby-clicky.rb",
28
+ "ruby-clicky.gemspec",
29
+ "test/ruby-clicky_test.rb",
30
+ "test/test_helper.rb"
31
+ ]
32
+ s.has_rdoc = true
33
+ s.homepage = %q{http://github.com/webandy/ruby-clicky}
34
+ s.rdoc_options = ["--charset=UTF-8"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = %q{1.3.2}
37
+ s.summary = %q{clicky stats for ruby}
38
+ s.test_files = [
39
+ "test/ruby-clicky_test.rb",
40
+ "test/test_helper.rb"
41
+ ]
42
+
43
+ if s.respond_to? :specification_version then
44
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
+ s.specification_version = 3
46
+
47
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
48
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
49
+ else
50
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
51
+ end
52
+ else
53
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
54
+ end
55
+ end
@@ -0,0 +1,13 @@
1
+ require 'test_helper'
2
+
3
+ class RubyClickyTest < Test::Unit::TestCase
4
+ should "return true for a valid Clicky log invocation" do
5
+ assert GetClicky.log(:href => "http://www.google.com", :ip_address => "127.0.0.1")
6
+ end
7
+
8
+ should "raise ArgumentError if passing invalid parameters to method" do
9
+ assert_raises ArgumentError do
10
+ assert GetClicky.log
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'ruby-clicky'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webandy-ruby-clicky
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Andy Atkinson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-06 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: thoughtbot-shoulda
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: log traffic to the clicky web analytics stat app
26
+ email: andy@webandy.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.rdoc
34
+ files:
35
+ - .document
36
+ - .gitignore
37
+ - LICENSE
38
+ - README.rdoc
39
+ - Rakefile
40
+ - VERSION
41
+ - lib/clicky.sample.yml
42
+ - lib/ruby-clicky.rb
43
+ - ruby-clicky.gemspec
44
+ - test/ruby-clicky_test.rb
45
+ - test/test_helper.rb
46
+ has_rdoc: true
47
+ homepage: http://github.com/webandy/ruby-clicky
48
+ licenses:
49
+ post_install_message:
50
+ rdoc_options:
51
+ - --charset=UTF-8
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ version:
66
+ requirements: []
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 1.3.5
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: clicky stats for ruby
73
+ test_files:
74
+ - test/ruby-clicky_test.rb
75
+ - test/test_helper.rb