ruby-timecamp 0.0.0 → 0.0.2
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.
- checksums.yaml +4 -4
- data/.gitignore +11 -0
- data/.rspec +1 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/lib/ruby-timecamp.rb +2 -7
- data/lib/ruby-timecamp/request.rb +38 -0
- data/lib/ruby-timecamp/resource.rb +24 -0
- data/lib/ruby-timecamp/resource_collection.rb +27 -0
- data/lib/ruby-timecamp/resources/entry.rb +95 -0
- data/lib/ruby-timecamp/resources/entry_collection.rb +17 -0
- data/lib/ruby-timecamp/resources/task.rb +66 -0
- data/lib/ruby-timecamp/resources/task_collection.rb +18 -0
- data/lib/ruby-timecamp/resources/timer.rb +56 -0
- data/lib/ruby-timecamp/resources/user.rb +31 -0
- data/lib/ruby-timecamp/resources/user_collection.rb +11 -0
- data/lib/ruby-timecamp/response.rb +13 -0
- data/lib/ruby-timecamp/version.rb +5 -0
- data/ruby-timecamp.gemspec +31 -0
- metadata +129 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d715911317abcd5c5f92c9587aacbaacb8e58386
|
4
|
+
data.tar.gz: ccab181173f93b9b7f96f954d9cd56944338af02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ca1bbb904db4ec4d42c8113d9959c57d78422a26679fbef07f4a478d0dcd5e63ea8ecdea9fb7bf2f0b16cc07a0bc62a5dd58445ea21e475174f65b78305c33f
|
7
|
+
data.tar.gz: 3745004a613f39bd04ac7fe6101c1d8fac20e508b2fe0a432fdae564bd9c83434b7c63de9787be351085a8074cc3584f6158409977331cf610eed039948a3c33
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Trevor Mast
|
4
|
+
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
14
|
+
all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Ruby::Timecamp
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ruby/timecamp`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'ruby-timecamp'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install ruby-timecamp
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ruby-timecamp. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/lib/ruby-timecamp.rb
CHANGED
@@ -1,10 +1,5 @@
|
|
1
1
|
# require everything in lib
|
2
|
-
Dir["./lib/*.rb"].each {|file| require file }
|
3
|
-
Dir["./lib/resources/*.rb"].each {|file| require file }
|
2
|
+
Dir["./lib/ruby-timecamp/*.rb"].each {|file| require file }
|
3
|
+
Dir["./lib/ruby-timecamp/resources/*.rb"].each {|file| require file }
|
4
4
|
require 'active_support/all'
|
5
5
|
require 'rest-client'
|
6
|
-
require 'pry'
|
7
|
-
# dont require these for testing
|
8
|
-
unless (ENV['TIMECAMP_ENV'] == 'test')
|
9
|
-
require 'httplog'
|
10
|
-
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module TimeCamp
|
2
|
+
class Request
|
3
|
+
BASE_URL = 'https://www.timecamp.com/third_party/api/'
|
4
|
+
API_TOKEN = ENV['TIMECAMP_API_TOKEN']
|
5
|
+
|
6
|
+
# RESTful METHODS
|
7
|
+
def self.get(resource, opts={}, data={})
|
8
|
+
# return instance of response
|
9
|
+
return request(:get, resource, opts, data)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.post(resource, opts={}, data={})
|
13
|
+
# return instance of response
|
14
|
+
return request(:post, resource, opts, data)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.put(resource, opts={}, data={})
|
18
|
+
# return instance of response
|
19
|
+
return request(:put, resource, opts, data)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.delete(resource, opts={}, data={})
|
23
|
+
# return instance of response
|
24
|
+
return request(:delete, resource, opts, data)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def self.url(resource, opts)
|
29
|
+
return BASE_URL + "#{ resource }/format/json/api_token/#{ API_TOKEN }/" + opts.to_a.flatten.join('/')
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.request(action, resource, opts, data={})
|
33
|
+
# response = RestClient.send(action.to_sym, url(resource, opts), data)
|
34
|
+
response = RestClient::Request.execute(method: action.to_sym, url: url(resource, opts), payload: data)
|
35
|
+
return TimeCamp::Response.new(response).to_h
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module TimeCamp
|
2
|
+
class Resource
|
3
|
+
|
4
|
+
def initialize(response)
|
5
|
+
load_attributes(response.with_indifferent_access)
|
6
|
+
end
|
7
|
+
|
8
|
+
#################
|
9
|
+
# CLASS METHODS #
|
10
|
+
#################
|
11
|
+
|
12
|
+
def self.resource_name
|
13
|
+
return self.to_s.demodulize.pluralize.downcase
|
14
|
+
end
|
15
|
+
|
16
|
+
####################
|
17
|
+
# INSTANCE METHODS #
|
18
|
+
####################
|
19
|
+
|
20
|
+
def attributes
|
21
|
+
return Hash[instance_variables.map { |name| [name, instance_variable_get(name)] } ]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module TimeCamp
|
2
|
+
class ResourceCollection
|
3
|
+
def initialize(response)
|
4
|
+
@resources = []
|
5
|
+
end
|
6
|
+
|
7
|
+
def size
|
8
|
+
return @resources.size
|
9
|
+
end
|
10
|
+
|
11
|
+
def [](index)
|
12
|
+
return @resources[index]
|
13
|
+
end
|
14
|
+
|
15
|
+
def each(&block)
|
16
|
+
return @resources.each(&block)
|
17
|
+
end
|
18
|
+
|
19
|
+
def map(&block)
|
20
|
+
return @resources.map(&block)
|
21
|
+
end
|
22
|
+
|
23
|
+
def select(&block)
|
24
|
+
return @resources.select(&block)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module TimeCamp
|
2
|
+
class Entry < TimeCamp::Resource
|
3
|
+
attr_reader :id, :duration, :user_id, :description, :last_modify,
|
4
|
+
:billable, :task_id, :date, :start_time, :start_time_hour, :end_time, :end_time_hour, :name, :addons_external_id,
|
5
|
+
:invoice_id, :started_at, :entry_id, :note, :time_span
|
6
|
+
|
7
|
+
#################
|
8
|
+
# CLASS METHODS #
|
9
|
+
#################
|
10
|
+
|
11
|
+
# Example GET response
|
12
|
+
# [
|
13
|
+
# {
|
14
|
+
# "id":"3621",
|
15
|
+
# "duration":"3600", // in seconds
|
16
|
+
# "user_id":"123",
|
17
|
+
# "description":"",
|
18
|
+
# "last_modify":"2014-03-19 14:34:50",
|
19
|
+
# "billable":1,
|
20
|
+
# "task_id":"3132",
|
21
|
+
# "date":"2013-03-30",
|
22
|
+
# "start_time":"12:20:00", // this value may be null if user did not specify time frame
|
23
|
+
# "name":"Task name",
|
24
|
+
# "addons_external_id":"123241", // for integrations with Trello, Pivotal Tracker, etc., "0" if no integration
|
25
|
+
# "billable":0/1,
|
26
|
+
# "invoiceId":0/invoiceId
|
27
|
+
# }
|
28
|
+
# ]
|
29
|
+
# required :from, :to
|
30
|
+
# optional :task_ids, :with_subtasks, :user_ids
|
31
|
+
def self.get(opts={})
|
32
|
+
response = TimeCamp::Request.get(resource_name, opts)
|
33
|
+
return EntryCollection.parse(response)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.timers(opts={})
|
37
|
+
response = TimeCamp::Request.get('timer_running', opts)
|
38
|
+
return EntryCollection.parse(response)
|
39
|
+
end
|
40
|
+
|
41
|
+
# required :date(%Y-%m-%d), :duration(in seconds)
|
42
|
+
# optional :note, :start_time(13:30:00), :end_time, :billable, :task_id
|
43
|
+
def self.create(opts={})
|
44
|
+
data_keys = [:date, :duration, :note, :start_time, :end_time, :billable, :task_id]
|
45
|
+
data, opts = opts.partition{ |k, v| data_keys.include?(k) }.map(&:to_h)
|
46
|
+
response = TimeCamp::Request.post(resource_name, opts, data)
|
47
|
+
return EntryCollection.parse(response)
|
48
|
+
end
|
49
|
+
|
50
|
+
# required :id
|
51
|
+
# optional :duration, :note, :start_time, :end_time, :billable, :invoiceId, :task_id, :updateActivities
|
52
|
+
def self.update(opts={})
|
53
|
+
data_keys = [:id, :duration, :note, :start_time, :end_time, :billable, :invoiceId, :task_id, :updateActivities]
|
54
|
+
data, opts = opts.partition{ |k, v| data_keys.include?(k) }.map(&:to_h)
|
55
|
+
response = TimeCamp::Request.put(resource_name, opts, data)
|
56
|
+
return EntryCollection.parse(response)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.delete(opts={})
|
60
|
+
data_keys = [:id, :entry_id]
|
61
|
+
data, opts = opts.partition{ |k, v| data_keys.include?(k) }.map(&:to_h)
|
62
|
+
response = TimeCamp::Request.delete(resource_name, opts, data)
|
63
|
+
return EntryCollection.parse(response)
|
64
|
+
end
|
65
|
+
|
66
|
+
####################
|
67
|
+
# INSTANCE METHODS #
|
68
|
+
####################
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def load_attributes(response)
|
73
|
+
@id = response[:id]
|
74
|
+
@duration = response[:duration]
|
75
|
+
@user_id = response[:user_id]
|
76
|
+
@description = response[:description]
|
77
|
+
@last_modify = response[:last_modify]
|
78
|
+
@billable = response[:billable]
|
79
|
+
@task_id = response[:task_id]
|
80
|
+
@date = response[:date]
|
81
|
+
@start_time = response[:start_time]
|
82
|
+
@start_time_hour = response[:start_time_hour]
|
83
|
+
@end_time = response[:end_time]
|
84
|
+
@end_time_hour = response[:end_time_hour]
|
85
|
+
@name = response[:name]
|
86
|
+
@addons_external_id = response[:addons_external_id]
|
87
|
+
@invoice_id = response[:invoice_id]
|
88
|
+
@started_at = response[:started_at]
|
89
|
+
@entry_id = response[:entry_id]
|
90
|
+
@note = response[:note]
|
91
|
+
@time_span = response[:time_span]
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module TimeCamp
|
2
|
+
class EntryCollection < ResourceCollection
|
3
|
+
def initialize(response)
|
4
|
+
@resources = response.map{|entry| Entry.new(entry) }
|
5
|
+
end
|
6
|
+
|
7
|
+
def find(entry_id)
|
8
|
+
return @resources.select{ |entry| entry.id == entry_id }.try(:first)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.parse(response)
|
12
|
+
return EntryCollection.new([]) if response.blank?
|
13
|
+
return response.is_a?(Array) ? EntryCollection.new(response) : Entry.new(response)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module TimeCamp
|
2
|
+
class Task < TimeCamp::Resource
|
3
|
+
attr_reader :task_id, :parent_id, :assigned_by, :name, :external_task_id,
|
4
|
+
:external_parent_id, :level, :archived, :color, :tags, :budgeted,
|
5
|
+
:budget_unit, :root_group_id, :billable, :note, :public_hash, :users,
|
6
|
+
:user_access_type
|
7
|
+
|
8
|
+
#################
|
9
|
+
# CLASS METHODS #
|
10
|
+
#################
|
11
|
+
|
12
|
+
# optional :task_id
|
13
|
+
def self.get(opts={})
|
14
|
+
response = TimeCamp::Request.get(resource_name, opts)
|
15
|
+
return TaskCollection.parse(response)
|
16
|
+
end
|
17
|
+
|
18
|
+
# required :name
|
19
|
+
# optional :tags, :parent_id, :external_task_id, :external_parent_id,
|
20
|
+
# :budgeted, :note, :archived, :billable, :budget_unit,
|
21
|
+
# :user_ids (comma separated), :role
|
22
|
+
def self.create(opts={})
|
23
|
+
data_keys = [:name, :tags, :parent_id, :external_task_id, :external_parent_id, :budgeted, :note, :archived, :billable, :budget_unit, :user_ids, :role]
|
24
|
+
data, opts = opts.partition{ |k, v| data_keys.include?(k) }.map(&:to_h)
|
25
|
+
response = TimeCamp::Request.post(resource_name, opts, data)
|
26
|
+
return TaskCollection.parse(response)
|
27
|
+
end
|
28
|
+
|
29
|
+
# required :task_id
|
30
|
+
# optional :name, :tags, :parent_id, :external_task_id,
|
31
|
+
# :external_parent_id, :budgeted, :note, :archived,
|
32
|
+
# :billable, :budget_unit, :user_ids (comma separated), :role
|
33
|
+
def self.update(opts={})
|
34
|
+
data_keys = [:task_id, :name, :tags, :parent_id, :external_task_id, :external_parent_id, :budgeted, :note, :archived, :billable, :budget_unit, :user_ids, :role]
|
35
|
+
data, opts = opts.partition{ |k, v| data_keys.include?(k) }.map(&:to_h)
|
36
|
+
response = TimeCamp::Request.put(resource_name, opts, data)
|
37
|
+
return TaskCollection.parse(response)
|
38
|
+
end
|
39
|
+
|
40
|
+
####################
|
41
|
+
# INSTANCE METHODS #
|
42
|
+
####################
|
43
|
+
|
44
|
+
private
|
45
|
+
def load_attributes(response)
|
46
|
+
@task_id = response[:task_id]
|
47
|
+
@parent_id = response[:parent_id]
|
48
|
+
@assigned_by = response[:assigned_by]
|
49
|
+
@name = response[:name]
|
50
|
+
@external_task_id = response[:external_task_id]
|
51
|
+
@external_parent_id = response[:external_parent_id]
|
52
|
+
@level = response[:level]
|
53
|
+
@archived = response[:archived]
|
54
|
+
@color = response[:color]
|
55
|
+
@tags = response[:tags]
|
56
|
+
@budgeted = response[:budgeted]
|
57
|
+
@budget_unit = response[:budget_unit]
|
58
|
+
@root_group_id = response[:root_group_id]
|
59
|
+
@billable = response[:billable]
|
60
|
+
@note = response[:note]
|
61
|
+
@public_hash = response[:public_hash]
|
62
|
+
@users = response[:users]
|
63
|
+
@user_access_type = response[:user_access_type]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module TimeCamp
|
2
|
+
class TaskCollection < TimeCamp::ResourceCollection
|
3
|
+
def initialize(response)
|
4
|
+
filtered_response = response.map{|k, v| v }
|
5
|
+
@resources = filtered_response.map{|task| Task.new(task) }
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.parse(response)
|
9
|
+
return TimeCamp::TaskCollection.collection?(response) ? TaskCollection.new(response) : Task.new(response)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.collection?(response)
|
13
|
+
# return true if the response is an array
|
14
|
+
# or if all of the keys are strings of digits only
|
15
|
+
return response.is_a?(Array) || response.keys.all?{ |key| key.scan(/\D/).blank? }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module TimeCamp
|
2
|
+
class Timer < TimeCamp::Resource
|
3
|
+
attr_reader :new_timer_id, :entry_id, :isTimerRunning, :elapsed, :timer_id,
|
4
|
+
:start_time, :task_id, :name, :external_task_id, :entry_time
|
5
|
+
|
6
|
+
#################
|
7
|
+
# CLASS METHODS #
|
8
|
+
#################
|
9
|
+
|
10
|
+
# override because the path for this resource is not plural for some reason
|
11
|
+
def self.resource_name
|
12
|
+
return 'timer'
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.get
|
16
|
+
response = TimeCamp::Request.post(resource_name, {}, { action: 'status' })
|
17
|
+
return Timer.new(response)
|
18
|
+
end
|
19
|
+
|
20
|
+
# optional :task_id, :entry_id, :started_at
|
21
|
+
def self.start(opts={})
|
22
|
+
data_keys = [:task_id, :entry_id, :started_at]
|
23
|
+
data, opts = opts.partition{ |k, v| data_keys.include?(k) }.map(&:to_h)
|
24
|
+
data.merge!(action: 'start')
|
25
|
+
response = TimeCamp::Request.post(resource_name, opts, data)
|
26
|
+
return Timer.new(response)
|
27
|
+
end
|
28
|
+
|
29
|
+
# required :timer_id, :stopped_at
|
30
|
+
def self.stop(opts={})
|
31
|
+
data_keys = [:timer_id, :stopped_at]
|
32
|
+
data, opts = opts.partition{ |k, v| data_keys.include?(k) }.map(&:to_h)
|
33
|
+
data.merge!(action: 'stop')
|
34
|
+
response = TimeCamp::Request.post(resource_name, opts, data)
|
35
|
+
return Timer.new(response)
|
36
|
+
end
|
37
|
+
|
38
|
+
####################
|
39
|
+
# INSTANCE METHODS #
|
40
|
+
####################
|
41
|
+
|
42
|
+
private
|
43
|
+
def load_attributes(response)
|
44
|
+
@new_timer_id = response[:new_timer_id]
|
45
|
+
@entry_id = response[:entry_id]
|
46
|
+
@is_timer_running = response[:isTimerRunning]
|
47
|
+
@elapsed = response[:elapsed]
|
48
|
+
@timer_id = response[:timer_id]
|
49
|
+
@start_time = response[:start_time]
|
50
|
+
@task_id = response[:task_id]
|
51
|
+
@name =response[:name]
|
52
|
+
@external_task_id = response[:external_task_id]
|
53
|
+
@entry_time = response[:entry_time]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module TimeCamp
|
2
|
+
class User < TimeCamp::Resource
|
3
|
+
attr_reader :user_id, :email, :login_count, :display_name,
|
4
|
+
:synch_time, :login_time, :group_id
|
5
|
+
|
6
|
+
#################
|
7
|
+
# CLASS METHODS #
|
8
|
+
#################
|
9
|
+
|
10
|
+
def self.get
|
11
|
+
response = TimeCamp::Request.get(resource_name)
|
12
|
+
return UserCollection.parse(response)
|
13
|
+
end
|
14
|
+
|
15
|
+
####################
|
16
|
+
# INSTANCE METHODS #
|
17
|
+
####################
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def load_attributes(response)
|
22
|
+
@user_id = response[:user_id]
|
23
|
+
@email = response[:email]
|
24
|
+
@login_count = response[:login_count]
|
25
|
+
@display_name = response[:display_name]
|
26
|
+
@synch_time = response[:synch_time]
|
27
|
+
@login_time = response[:login_time]
|
28
|
+
@group_id = response[:group_id]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module TimeCamp
|
2
|
+
class UserCollection < TimeCamp::ResourceCollection
|
3
|
+
def initialize(response)
|
4
|
+
@resources = response.map{|user| User.new(user) }
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.parse(response)
|
8
|
+
return (response.length > 1) ? UserCollection.new(response) : User.new(response[0])
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ruby-timecamp/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ruby-timecamp"
|
8
|
+
spec.version = Ruby::Timecamp::VERSION
|
9
|
+
spec.authors = ["Trevor Mast\n"]
|
10
|
+
spec.email = ["trevormast@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A simple wrapper for the Timecamp API}
|
13
|
+
spec.homepage = "https://github.com/trevormast/ruby-timecamp"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_runtime_dependency "rest-client", "~> 2.0.0"
|
24
|
+
spec.add_runtime_dependency "activesupport", "~> 4.2.7.1"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
+
spec.add_development_dependency "vcr", "~> 3.0.3"
|
30
|
+
spec.add_development_dependency "webmock", "~> 3.1.0"
|
31
|
+
end
|
metadata
CHANGED
@@ -1,22 +1,143 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-timecamp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Trevor Mast
|
7
|
+
- 'Trevor Mast
|
8
|
+
|
9
|
+
'
|
8
10
|
autorequire:
|
9
|
-
bindir:
|
11
|
+
bindir: exe
|
10
12
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
12
|
-
dependencies:
|
13
|
-
|
14
|
-
|
13
|
+
date: 2018-01-15 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rest-client
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 2.0.0
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: activesupport
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 4.2.7.1
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 4.2.7.1
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: bundler
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.13'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '1.13'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rake
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '10.0'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '10.0'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: rspec
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '3.0'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '3.0'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: vcr
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 3.0.3
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - "~>"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 3.0.3
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: webmock
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - "~>"
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 3.1.0
|
106
|
+
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - "~>"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 3.1.0
|
113
|
+
description:
|
114
|
+
email:
|
115
|
+
- trevormast@gmail.com
|
15
116
|
executables: []
|
16
117
|
extensions: []
|
17
118
|
extra_rdoc_files: []
|
18
119
|
files:
|
120
|
+
- ".gitignore"
|
121
|
+
- ".rspec"
|
122
|
+
- Gemfile
|
123
|
+
- Gemfile.lock
|
124
|
+
- LICENSE.txt
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
19
127
|
- lib/ruby-timecamp.rb
|
128
|
+
- lib/ruby-timecamp/request.rb
|
129
|
+
- lib/ruby-timecamp/resource.rb
|
130
|
+
- lib/ruby-timecamp/resource_collection.rb
|
131
|
+
- lib/ruby-timecamp/resources/entry.rb
|
132
|
+
- lib/ruby-timecamp/resources/entry_collection.rb
|
133
|
+
- lib/ruby-timecamp/resources/task.rb
|
134
|
+
- lib/ruby-timecamp/resources/task_collection.rb
|
135
|
+
- lib/ruby-timecamp/resources/timer.rb
|
136
|
+
- lib/ruby-timecamp/resources/user.rb
|
137
|
+
- lib/ruby-timecamp/resources/user_collection.rb
|
138
|
+
- lib/ruby-timecamp/response.rb
|
139
|
+
- lib/ruby-timecamp/version.rb
|
140
|
+
- ruby-timecamp.gemspec
|
20
141
|
homepage: https://github.com/trevormast/ruby-timecamp
|
21
142
|
licenses:
|
22
143
|
- MIT
|
@@ -40,5 +161,5 @@ rubyforge_project:
|
|
40
161
|
rubygems_version: 2.6.8
|
41
162
|
signing_key:
|
42
163
|
specification_version: 4
|
43
|
-
summary:
|
164
|
+
summary: A simple wrapper for the Timecamp API
|
44
165
|
test_files: []
|