popular 0.0.1 → 0.1.0

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTFlYzUwZDA3NTAxOGFiNzcxZmE1YWIyOGJlYzMzODZiNzBlNTU1ZA==
4
+ MDk1NGEzNDZlYjNkZjEzMmFkZTQ1MjFhYmY3YzYxMTk2ZGY2YjdiOA==
5
5
  data.tar.gz: !binary |-
6
- OWZmNDFlMjhjNTJiMzczMWFjZTExZTNhZDIzZjZiNTA2N2ZiOGUwYg==
6
+ ODM2MjhhODY1NmJjZjZlMzQzYzljMTM3ZTFkZjExOTgzMDZmMmQxZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZmI5MGVhMDA1MmFhZmJlMjRiNDQxZjg2MGY2NTJlN2NjN2U0Nzg5NTEwODU4
10
- MDFmMjI0ZTExY2U1NDZkNDRjYTJiMGYxMDAyYjU1ODE5ZTllMTQyN2E3NjI3
11
- OWZmZDAwZTFjZjhiOWQwZWIzN2FlZDFlMjQxYTg1MzRiMmY1YWY=
9
+ ODY5YzY4YzYxNzU5NTc1MzVjNTMwMmE5YzBiOTgzNmQ4MjVjMzE5Y2ExMTIy
10
+ YmU3YTAxZWY4NmM4YjlmMTIxY2YyN2U2MjNlMjAxNmY3MzRiMDI5ZjVjODA0
11
+ YTEyM2EwYWI5NjcwMzhkNmZhZjE2MTU2NDlkNWM2ZTg4MTg5ODQ=
12
12
  data.tar.gz: !binary |-
13
- NDFlNzU4YjY2NmM4YjAwNDRjYjFjZjIyMWExYzI0NWU4YWNiNjljNTkyNTg1
14
- MWQ0MjEwYjRkZjFmNzJmOTNkYjBjNzQyOGEwNzBhMDI3ZDc2OWEwMzUzYjA2
15
- MDk0MjcxMzQ2N2U5MGJkYjMyMmIzNjgwYWM0ZTliYmQ4N2FjNjk=
13
+ MTcwYjYwMTU4Njk3YTY0YTE1M2JjNmIwMzIyN2QxYzFkZjU5NjQ2ODY1OTFl
14
+ ZmQxZjE3NjI5MjEwNzBlMzBiNTNkZjk2Mzk5NGU2NmRmMDljZmE4ZWYxNDdk
15
+ YWNlOWMwODg4ZTZjNTRmZWZlNWQ1ZjkwY2ZhYjI4OWI3ZTEyNWY=
@@ -0,0 +1,2 @@
1
+ bump:
2
+ tag: true
@@ -1,14 +1,12 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.0
3
+ - 2.1.0
4
4
  addons:
5
5
  code_climate:
6
- repo_token: 961309bcd7fffdccfec595d69b0d054b56308dcc414edad136f2c153bba245f4
6
+ repo_token: 4a0d77600a79523f404381dc1cc4bbfb7bf86f897d15b4aa80311db4aad20332
7
7
  deploy:
8
8
  provider: rubygems
9
- api_key:
10
- secure: lxiDHlutKFERFmsSzhqoGtVGRk06wQIv3Gp7GnvaYdbZzC2tH35tvW4RFxdSWPU8Fp02M8Qc89gV+T0IbAigFZEVp3F7IN4DM09oJWGJ4G1XKykYV0c5aFrEfcPVs4rzxletQanObqbVZqBj/+pCaGA1WvwqojL9Jg6a/w/LhyE=
11
- gem: friendly
12
9
  on:
13
10
  tags: true
14
- repo: thejchap/friendly
11
+ api_key:
12
+ secure: lxiDHlutKFERFmsSzhqoGtVGRk06wQIv3Gp7GnvaYdbZzC2tH35tvW4RFxdSWPU8Fp02M8Qc89gV+T0IbAigFZEVp3F7IN4DM09oJWGJ4G1XKykYV0c5aFrEfcPVs4rzxletQanObqbVZqBj/+pCaGA1WvwqojL9Jg6a/w/LhyE=
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Popular
2
+ [![Gem Version](https://badge.fury.io/rb/popular.png)](http://badge.fury.io/rb/popular)
2
3
  [![Build Status](https://travis-ci.org/thejchap/popular.svg?branch=master)](https://travis-ci.org/thejchap/popular)
4
+ [![Code Climate](https://codeclimate.com/github/thejchap/popular.png)](https://codeclimate.com/github/thejchap/popular)
5
+ [![Code Coverage](https://codeclimate.com/github/thejchap/popular/coverage.png)](https://codeclimate.com/github/thejchap/popular)
3
6
  [![Dependency Status](https://gemnasium.com/thejchap/popular.svg)](https://gemnasium.com/thejchap/popular)
4
7
 
5
8
  Popular is a friendship gem designed for Rails/ActiveRecord models.
@@ -15,14 +15,44 @@ module Popular
15
15
 
16
16
  # Adds a friend to an instance's friend's list
17
17
  #
18
- # @param [PopularModel] a popular_model that the instance is not already friends with
18
+ # @param [Object] new_friend a popular_model that the instance is not already friends with
19
+ #
20
+ # @example
21
+ # user = User.create name: "Justin"
22
+ # other_user = User.create name: "Jenny"
23
+ # user.befriend other_user
24
+ #
25
+ # user.friends_with? other_user #=> true
19
26
  def befriend new_friend
20
27
  friendships.create friend: new_friend
21
28
  end
22
29
 
30
+ # Adds a friend to an instance's friend's list
31
+ # Similar to .befriend, but will raise an error if the operation is not successful
32
+ #
33
+ # @param [Object] new_friend a popular_model that the instance is not already friends with
34
+ #
35
+ # @example
36
+ # user = User.create name: "Justin"
37
+ # other_user = User.create name: "Jenny"
38
+ # user.befriend! other_user
39
+ # user.reload
40
+ # user.friends_with? other_user # => true
41
+ def befriend! new_friend
42
+ friendships.create! friend: new_friend
43
+ end
44
+
23
45
  # Removes a friend from an instance's friend's list
24
46
  #
25
- # @param [PopularModel] a popular_model in this instance's friends list
47
+ # @param [Object] friend a popular_model in this instance's friends list
48
+ #
49
+ # @example
50
+ # user = User.create name: "Justin"
51
+ # other_user = User.create name: "Jenny"
52
+ # user.befriend other_user
53
+ # user.unfriend other_user
54
+ #
55
+ # user.friends_with? other_user # => false
26
56
  def unfriend friend
27
57
  friendships.where( friend: friend ).first.destroy
28
58
  end
@@ -30,8 +60,18 @@ module Popular
30
60
  # Helper method for finding whether or not the instance is friends with
31
61
  # another given popular_model
32
62
  #
33
- # @param [PopularModel] a popular_model
63
+ # @param [Object] popular_model
34
64
  # @return [Boolean] if the instance has popular_model as a friend
65
+ #
66
+ # @example
67
+ # user = User.create name: "Justin"
68
+ # other_user = User.create name: "Jenny"
69
+ #
70
+ # user.friends_with? other_user #=> false
71
+ #
72
+ # user.befriend other_user
73
+ #
74
+ # user.friends_with? other_user #=> true
35
75
  def friends_with? popular_model
36
76
  friendships.where( friend: popular_model ).any?
37
77
  end
@@ -1,3 +1,3 @@
1
1
  module Popular
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -26,4 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "yard", "~> 0.8"
27
27
  spec.add_development_dependency "redcarpet", "~> 3.1"
28
28
  spec.add_development_dependency "inch", "~> 0.3"
29
+ spec.add_development_dependency "gem-release", '~> 0.7.1'
29
30
  end
@@ -1,5 +1,13 @@
1
1
  shared_examples "a popular model" do
2
2
 
3
+ describe '.befriend!' do
4
+ it 'creates a one way friendship' do
5
+ popular_model.befriend! another_popular_model
6
+
7
+ expect( popular_model.friends ).to match_array [another_popular_model]
8
+ end
9
+ end
10
+
3
11
  describe '.befriend' do
4
12
  it 'creates a one way friendship' do
5
13
  popular_model.befriend another_popular_model
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: popular
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thejchap
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ~>
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0.3'
125
+ - !ruby/object:Gem::Dependency
126
+ name: gem-release
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: 0.7.1
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: 0.7.1
125
139
  description: Friendship gem for Rails/ActiveRecord. Popular saves time when developing
126
140
  social apps
127
141
  email:
@@ -130,6 +144,7 @@ executables: []
130
144
  extensions: []
131
145
  extra_rdoc_files: []
132
146
  files:
147
+ - .gemrelease
133
148
  - .gitignore
134
149
  - .rspec
135
150
  - .travis.yml