freckle 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/freckle.rb +11 -0
  2. data/test/freckle_test.rb +14 -0
  3. metadata +4 -4
data/lib/freckle.rb CHANGED
@@ -30,6 +30,9 @@ class Freckle
30
30
  User.new(user['user'], self)
31
31
  end
32
32
  end
33
+ def user_by_login(login)
34
+ self.users.detect{ |u| u.login == login }
35
+ end
33
36
 
34
37
  def projects(options = {})
35
38
  Array(JSON.parse(@connection['/projects.json'].get)).flatten.map do |project|
@@ -82,6 +85,14 @@ class Freckle
82
85
  def self.all(options = {})
83
86
  super(:users, options)
84
87
  end
88
+ def self.by_login(login)
89
+ Freckle.connection.user_by_login(login)
90
+ end
91
+ def entries(options = {})
92
+ people = (options.delete(:people) || [])
93
+ people.push(self.id) unless people.include?(self.id)
94
+ @connection.entries(options.merge(:people => people))
95
+ end
85
96
  end
86
97
 
87
98
  class Project < Base
data/test/freckle_test.rb CHANGED
@@ -27,6 +27,13 @@ class FreckleTest < Test::Unit::TestCase
27
27
  assert !@connection.entries.empty?
28
28
  end
29
29
 
30
+ def test_user_by_login
31
+ assert_equal nil, @connection.user_by_login('nonexistentuser')
32
+
33
+ user = @connection.users.first
34
+ assert_equal user, @connection.user_by_login(user.login)
35
+ end
36
+
30
37
  ### Models
31
38
 
32
39
  def test_users_return_user_model
@@ -53,6 +60,13 @@ class FreckleTest < Test::Unit::TestCase
53
60
 
54
61
  ### Associations
55
62
 
63
+ def test_user_model_can_query_for_its_entries
64
+ assert user = @connection.users.first
65
+ user.entries.each do |entry|
66
+ assert_equal user, entry.user
67
+ end
68
+ end
69
+
56
70
  def test_project_model_can_query_for_its_entries
57
71
  assert project = @connection.projects.first
58
72
  project.entries.each do |entry|
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freckle
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Todd
@@ -88,7 +88,7 @@ files:
88
88
  - test/freckle_test.rb
89
89
  - test/test_helper.rb
90
90
  has_rdoc: true
91
- homepage: http://github.com/reddavis/freckly
91
+ homepage: http://github.com/mtodd/freckle
92
92
  licenses: []
93
93
 
94
94
  post_install_message: