dribbble 1.0.1 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eebd1d875d2a246c82abe992c30399b86bc926fa
4
- data.tar.gz: 7702399ef09cb5399581a8311503d6a50909027f
3
+ metadata.gz: 6eff1aac4c30a7dec57c39acd452c29a3bdb9c49
4
+ data.tar.gz: 29797d5b150718aaa47e541d9704770d5150c9f7
5
5
  SHA512:
6
- metadata.gz: d53fa391316e9d29ccfb7c18c9cca8c9dc4cfccc7652c6e8e9c9daa6d64b17f812970dcd8403d38945b2b2838dff873b463aa7173db5f7f3f07d0648060bd1d8
7
- data.tar.gz: a678ba5dc4bb8e43e702602179c7abc7534d493295ac6536f9d31830b5bdf04c5a5b96468c037dbd2b5c5efe9badce3ad33feb475ac0d4eeed4c7ef21dae3088
6
+ metadata.gz: a7f958d7451b211dc2898b1b8e682941d35811a72f6f9b681c4d22942271eb9463a2fb9dbc5279f26c8012a8251135ecf6b3f9dbf2f68f31ddaeb5e437a8ee19
7
+ data.tar.gz: 74a7d86be3ad9b76bcf3b9a4f79f14311f8dd00c74dd7d1bed5e3b3ae6dd4ff93f7bf6dc3e75ab0d92ced017d9b8c96d7d3d1435a6237367272236f05f4fa0a9
@@ -1,8 +1,8 @@
1
1
  require 'dribbble/base'
2
+ require 'dribbble/shot'
2
3
  require 'dribbble/user'
3
4
  require 'dribbble/bucket'
4
5
  require 'dribbble/project'
5
- require 'dribbble/shot'
6
6
  require 'dribbble/team'
7
7
  require 'dribbble/errors'
8
8
 
data/lib/dribbble/user.rb CHANGED
@@ -4,17 +4,10 @@ module Dribbble
4
4
  class User < Dribbble::Base
5
5
  include Dribbble::Utils::Findable
6
6
 
7
- def buckets(attrs = {})
8
- Dribbble::Bucket.batch_new token, html_get("/users/#{id}/buckets", attrs)
9
- end
10
-
11
- def followers(attrs = {})
12
- Dribbble::User.batch_new token, html_get("/users/#{id}/followers", attrs)
13
- end
14
-
15
- def following(attrs = {})
16
- Dribbble::User.batch_new token, html_get("/users/#{id}/following", attrs), 'followee'
17
- end
7
+ has_many :buckets, :projects, :shots, :teams
8
+ has_many :likes, as: Dribbble::Shot, key: 'shot'
9
+ has_many :followers, as: Dribbble::User, key: 'follower'
10
+ has_many :following, as: Dribbble::User, key: 'followee'
18
11
 
19
12
  def following?(other_user_id = nil)
20
13
  if other_user_id
@@ -36,21 +29,5 @@ module Dribbble
36
29
  res = html_delete "/users/#{id}/follow"
37
30
  res.code == 204 ? true : false
38
31
  end
39
-
40
- def likes(attrs = {})
41
- Dribbble::Shot.batch_new token, html_get("/users/#{id}/likes", attrs), 'shot'
42
- end
43
-
44
- def projects(attrs = {})
45
- Dribbble::Project.batch_new token, html_get("/users/#{id}/projects", attrs)
46
- end
47
-
48
- def shots(attrs = {})
49
- Dribbble::Shot.batch_new token, html_get("/users/#{id}/shots", attrs)
50
- end
51
-
52
- def teams(attrs = {})
53
- Dribbble::Team.batch_new token, html_get("/users/#{id}/teams", attrs)
54
- end
55
32
  end
56
33
  end
@@ -4,7 +4,7 @@ module Dribbble
4
4
  module ClassMethods
5
5
  def has_many(*fields)
6
6
  if fields[1].is_a? Hash
7
- generate_methods fields[0], fields[1][:as]
7
+ generate_methods fields[0], fields[1][:as], fields[1][:key]
8
8
  else
9
9
  fields.each do |field|
10
10
  generate_methods field
@@ -12,13 +12,13 @@ module Dribbble
12
12
  end
13
13
  end
14
14
 
15
- def generate_methods(field, klass = nil)
15
+ def generate_methods(field, klass = nil, key = nil)
16
16
  singularized_field = field[0...-1]
17
17
 
18
18
  define_method field do |attrs = {}|
19
19
  klass ||= Object.const_get "Dribbble::#{__method__[0...-1].capitalize}"
20
20
  url = "/#{pluralized_class_name}/#{id}/#{field}"
21
- klass.batch_new token, html_get(url, attrs), nil, url
21
+ klass.batch_new token, html_get(url, attrs), key, url
22
22
  end
23
23
 
24
24
  define_method "find_#{singularized_field}" do |child_id|
@@ -1,4 +1,4 @@
1
1
  # Dribbble Version
2
2
  module Dribbble
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
@@ -37,6 +37,7 @@ describe Dribbble::User do
37
37
  it 'responds with users' do
38
38
  expect(subject.size).to eq 1
39
39
  expect(subject.first).to be_a Dribbble::User
40
+ expect(subject.first.location).to eq 'Salem, MA'
40
41
  end
41
42
  end
42
43
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dribbble
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Calyhre