Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

wrote README, changed get_params to return hash directly

  • Loading branch information...
commit 8c266a6733e27036e4fb9748fa71e8a4a8d4e116 1 parent 1cd4f7d
@gamache gamache authored
Showing with 30 additions and 2 deletions.
  1. +27 −0 README
  2. +3 −2 lib/clicky-api.rb
View
27 README
@@ -1,5 +1,32 @@
Clicky-api is a Ruby Gem which interfaces with version 4 of the Clicky web
analytics API, documented at http://getclicky.com/help/api.
+Usage:
+
+ClickyAPI.set_params!(params={})
+
+ Sets the given parameters persistently, in a class variable (so the
+ settings are applied globally). Setting the Clicky site_id and sitekey
+ here is a good idea.
+
+ClickyAPI.get_params
+
+ Returns the current hash of persistent params set by #set_params!.
+ This hash may be manipulated directly, e.g. to delete keys; if you
+ need to alter it without affecting ClickyAPI everywhere, make a copy.
+
+ClickyAPI.load_config_file!(file=nil)
+
+ Loads the given YAML config file and passes its keys and values to
+ #set_params!. If no file is specified and you're using Rails,
+ #load_config_file! will use the contents of "config/clicky-api.yml".
+
+ClickyAPI.stats(params={})
+
+ Queries the Clicky server with the given params, merging them with
+ any parameters set with #set_params!. Returns a Ruby hash representation
+ of the response.
+
+
This gem was written by Pete Gamache with the gracious support of Where, Inc.
View
5 lib/clicky-api.rb
@@ -47,9 +47,10 @@ def self.set_params!(param_hash={})
end
## get_params returns the hash of params set by #set_params!
- ## using Hash#merge to prevent shared structure
+ ## it returns the hash directly, so make a copy if you want to avoid
+ ## affecting other nearby ClickyAPI calls.
def self.get_params
- {}.merge(@@set_params||{})
+ @@set_params
end
## the 'stats' method is used to obtain results. I wanted to call it
Please sign in to comment.
Something went wrong with that request. Please try again.