Class: Freckle
- Inherits:
-
Object
- Object
- Freckle
- Defined in:
- lib/freckle.rb
Defined Under Namespace
Classes: Base, Entry, Project, User
Class Method Summary collapse
Instance Method Summary collapse
-
#entries(options = {}) ⇒ Object
people: comma separated user ids projects: comma separated project ids tags: comma separated tag ids from: entries from this date to: entries to this date billable: true only shows billable entries; false only shows unbillable entries.
-
#initialize(options = {}) ⇒ Freckle
constructor
A new instance of Freckle.
- #projects(options = {}) ⇒ Object
-
#users(options = {}) ⇒ Object
Query Methods.
Constructor Details
#initialize(options = {}) ⇒ Freckle
Returns a new instance of Freckle.
9 10 11 12 13 14 15 16 |
# File 'lib/freckle.rb', line 9 def initialize( = {}) @account = .delete(:account) @token = .delete(:token) @logger = .delete(:logger) || Logger.new(STDOUT) RestClient.log = @logger @connection = RestClient::Resource.new( "http://#{@account}.letsfreckle.com/api", :headers => {"X-FreckleToken" => @token} ) end |
Class Method Details
.connection ⇒ Object
21 22 23 24 |
# File 'lib/freckle.rb', line 21 def self.connection return @connection if @connection raise RuntimeError, "Freckle.establish_connection with :account and :token first" end |
.establish_connection(options) ⇒ Object
18 19 20 |
# File 'lib/freckle.rb', line 18 def self.establish_connection() @connection = new() end |
Instance Method Details
#entries(options = {}) ⇒ Object
people: comma separated user ids projects: comma separated project ids tags: comma separated tag ids from: entries from this date to: entries to this date billable: true only shows billable entries; false only shows unbillable entries
46 47 48 49 50 51 |
# File 'lib/freckle.rb', line 46 def entries( = {}) .keys.each { |k| ["search[#{k}]"] = Array(.delete(k)).flatten.join(',') } Array(JSON.parse(@connection['/entries.json'].get(:params => ))).flatten.map do |entry| Entry.new(entry['entry'], self) end end |