acts-as-taggable-on 3.0.0 → 3.0.1

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: 5b46e80f19a5c7de71ec448bd0700ef672ea9639
4
- data.tar.gz: d7c19bc3aec73a2b5d1ff08ad18cb9c85e61225c
3
+ metadata.gz: 293f131bdbea6f4836774fa5a51d51f54f4d03ef
4
+ data.tar.gz: fe26f8ea9c83126f6ce380ebc2bccce14ade746d
5
5
  SHA512:
6
- metadata.gz: 4ac4317c1fa00caa6f048d4958d830da83bae5a48d8fd2f4018918319069e9e0311b99318cfe337fcd8d23f9c37055484e1c40c1ab0ecda2c256d361315b0848
7
- data.tar.gz: 7e29cf71dfce65f2ac65d0a10972c6b26344398278c53b088b9069ec728955e697389f496b25a8f57fd521b6349aaa2ef827caab78bf8a00c7416c9be43c21e5
6
+ metadata.gz: 7a95962db54233536581ce55114d886fb907f90efc9743c67049f8284e2c0eac4f6d7dd19868689bc0721363fec7987dba927b8467f4aec8d1ec7bbd5a3b8482
7
+ data.tar.gz: f04b6dc48e1642c0bb0f6f3879913f5bd9fe7e9851842e5865d775994cd069c699e2ccbdeca393487b82485a5c195fd2125250062e684c12ff2c7241580900f2
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  rvm:
2
2
  - 1.9.3
3
3
  - 2.0.0
4
+ - 2.1.0
4
5
  env:
5
6
  - DB=sqlite3
6
7
  - DB=mysql
data/CHANGELOG.md CHANGED
@@ -4,12 +4,33 @@ Each change should fall into categories that would affect whether the release is
4
4
 
5
5
  As such, a _Feature_ would map to either major or minor. A _bug fix_ to a patch. And _misc_ is either minor or patch, the difference being kind of fuzzy for the purposes of history. Adding tests would be patch level.
6
6
 
7
- ### Master [changes](https://github.com/mbleigh/acts-as-taggable-on/compare/v3.0.0...master)
7
+ ### Master [changes](https://github.com/mbleigh/acts-as-taggable-on/compare/v3.0.1...master)
8
8
 
9
9
  * Breaking Changes
10
10
  * Features
11
11
  * Fixes
12
+ * [@rafael #406 Dirty attributes not correctly derived](https://github.com/mbleigh/acts-as-taggable-on/pull/406)
13
+ * [@bzbnhang #440 Did not respect strict_case_match](https://github.com/mbleigh/acts-as-taggable-on/pull/440)
14
+ * [@znz #456 Fix breaking encoding of tag](https://github.com/mbleigh/acts-as-taggable-on/pull/456)
12
15
  * Misc
16
+ * [@billychan #386 Add parse:true instructions to README](https://github.com/mbleigh/acts-as-taggable-on/pull/386)
17
+ * [@seuros #449 Improve README/UPGRADING/post install docs](https://github.com/mbleigh/acts-as-taggable-on/pull/449)
18
+ * [@seuros #452 Remove I18n deprecation warning in specs](https://github.com/mbleigh/acts-as-taggable-on/pull/452)
19
+ * [@seuros #453 Test against Ruby 2.1 on Travis CI](https://github.com/mbleigh/acts-as-taggable-on/pull/453)
20
+ * [@takashi #454 Clarify example in docs](https://github.com/mbleigh/acts-as-taggable-on/pull/454)
21
+
22
+ ### [3.0.1 / 2014-01-08](https://github.com/mbleigh/acts-as-taggable-on/compare/v3.0.0...v3.0.1)
23
+
24
+ * Fixes
25
+ * [@rafael #406 Dirty attributes not correctly derived](https://github.com/mbleigh/acts-as-taggable-on/pull/406)
26
+ * [@bzbnhang #440 Did not respect strict_case_match](https://github.com/mbleigh/acts-as-taggable-on/pull/440)
27
+ * [@znz #456 Fix breaking encoding of tag](https://github.com/mbleigh/acts-as-taggable-on/pull/456)
28
+ * Misc
29
+ * [@billychan #386 Add parse:true instructions to README](https://github.com/mbleigh/acts-as-taggable-on/pull/386)
30
+ * [@seuros #449 Improve README/UPGRADING/post install docs](https://github.com/mbleigh/acts-as-taggable-on/pull/449)
31
+ * [@seuros #452 Remove I18n deprecation warning in specs](https://github.com/mbleigh/acts-as-taggable-on/pull/452)
32
+ * [@seuros #453 Test against Ruby 2.1 on Travis CI](https://github.com/mbleigh/acts-as-taggable-on/pull/453)
33
+ * [@takashi #454 Clarify example in docs](https://github.com/mbleigh/acts-as-taggable-on/pull/454)
13
34
 
14
35
  ### [3.0.0 / 2014-01-01](https://github.com/mbleigh/acts-as-taggable-on/compare/v2.4.1...v3.0.0)
15
36
 
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,44 @@
1
+ # How to contribute:
2
+
3
+ ## Bug reports / Issues
4
+
5
+ * Is something broken or not working as expected? Check for an existing issue or [create a new one](https://github.com/mbleigh/acts-as-taggable-on/issues/new)
6
+ * IMPORTANT: Include the version of the gem, if you've install from git, what Ruby and Rails you are running, etc.
7
+
8
+ ## Code
9
+
10
+ 1. [Fork and clone the repo](https://help.github.com/articles/fork-a-repo)
11
+ 2. Install the gem dependencies: `bundle install`
12
+ 3. Make the changes you want and back them up with tests.
13
+ * [Run the tests](https://github.com/mbleigh/acts-as-taggable-on#testing) (`bundle exec rake spec`)
14
+ 4. Update the CHAGELOG.md file with your changes and give yourself credit
15
+ 5. Commit and create a pull request with details as to what has been changed and why
16
+ * Use well-described, small (atomic) commits.
17
+ * Include links to any relevant github issues.
18
+ * *Don't* change the VERSION file.
19
+ 6. Extra Credit: [Confirm it runs and tests pass on the rubies specified in the travis config](.travis.yml). I will otherwise confirm it runs on these.
20
+
21
+ How I handle pull requests:
22
+
23
+ * If the tests pass and the pull request looks good, I will merge it.
24
+ * If the pull request needs to be changed,
25
+ * you can change it by updating the branch you generated the pull request from
26
+ * either by adding more commits, or
27
+ * by force pushing to it
28
+ * I can make any changes myself and manually merge the code in.
29
+
30
+ ### Commit Messages
31
+
32
+ * [A Note About Git Commit Messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
33
+ * [http://stopwritingramblingcommitmessages.com/](http://stopwritingramblingcommitmessages.com/)
34
+ * [ThoughtBot style guide](https://github.com/thoughtbot/guides/tree/master/style#git)
35
+
36
+ ### About Pull Requests (PR's)
37
+
38
+ * [All Your Open Source Code Are Belong To Us](http://www.benjaminfleischer.com/2013/07/30/all-your-open-source-code-are-belong-to-us/)
39
+ * [Using Pull Requests](https://help.github.com/articles/using-pull-requests)
40
+ * [Github pull requests made easy](http://www.element84.com/github-pull-requests-made-easy.html)
41
+
42
+ ## Documentation
43
+
44
+ * Update the wiki
data/README.md CHANGED
@@ -21,7 +21,7 @@ Versions 2.x are compatible with Ruby 1.8.7+ and Rails 3.
21
21
 
22
22
  Versions 2.4.1 and up are compatible with Rails 4 too (thanks to arabonradar and cwoodcox).
23
23
 
24
- Versions 3.x (currently unreleased) are compatible with Ruby 1.9.3+ and Rails 3 and 4. There is a [release candidate you may try](http://rubygems.org/gems/acts_as_taggable_on).
24
+ Versions >= 3.x are compatible with Ruby 1.9.3+ and Rails 3 and 4.
25
25
 
26
26
  For an up-to-date roadmap, see https://github.com/mbleigh/acts-as-taggable-on/issues/milestones
27
27
 
@@ -35,48 +35,100 @@ gem 'acts-as-taggable-on'
35
35
 
36
36
  and bundle:
37
37
 
38
- ```ruby
38
+ ```shell
39
39
  bundle
40
40
  ```
41
41
 
42
42
  #### Post Installation
43
43
 
44
- ```shell
45
- # For the latest versions
46
- rake railties:install:migrations FROM=acts_as_taggable_on_engine db:migrate
44
+ Install migrations
47
45
 
48
- # For versions 2.4.1 and earlier
46
+ ```shell
47
+ # For the latest versions :
48
+ rake acts_as_taggable_on_engine:install:migrations
49
+ # For versions 2.4.1 and earlier :
49
50
  rails generate acts_as_taggable_on:migration
51
+ ```
52
+
53
+ Review the generated migrations then migrate :
54
+ ```shell
50
55
  rake db:migrate
51
56
  ```
52
57
 
53
58
  #### Upgrading
54
59
 
55
- see [UPGRADING](UPGRADING)
60
+ see [UPGRADING](UPGRADING.md)
56
61
 
57
62
  ## Usage
58
63
 
64
+ Setup
65
+
59
66
  ```ruby
60
67
  class User < ActiveRecord::Base
61
- # Alias for acts_as_taggable_on :tags
62
- acts_as_taggable
68
+ acts_as_taggable # Alias for acts_as_taggable_on :tags
63
69
  acts_as_taggable_on :skills, :interests
64
70
  end
65
71
 
66
72
  @user = User.new(:name => "Bobby")
67
- @user.tag_list = "awesome, slick, hefty" # this should be familiar
68
- @user.skill_list = "joking, clowning, boxing" # but you can do it for any context!
73
+ ```
74
+
75
+ Add and remove a single tag
76
+
77
+ ```ruby
78
+ @user.tag_list.add("awesomer") # add a single tag. alias for <<
79
+ @user.tag_list.remove("awesome") # remove a single tag
80
+ ```
81
+
82
+ Add and remove multiple tags in an array
83
+
84
+ ```ruby
85
+ @user.tag_list.add("awesomer", "slicker")
86
+ @user.tag_list.remove("awesome", "slick")
87
+ ```
88
+
89
+ You can also add and remove tags in format of String. This would
90
+ be convenient in some cases such as handling tag input param in a String.
91
+
92
+ Pay attention you need to add `parse: true` as option in this case.
93
+
94
+ You may also want to take a look at delimiter in the string. The default
95
+ is comma `,` so you don't need to do anything here. However, if you made
96
+ a change on delimiter setting, make sure the string will match. See
97
+ [configuration](#configuration) for more about delimiter.
98
+
99
+ ```ruby
100
+ @user.tag_list.add("awesomer, slicker", parse: true)
101
+ @user.tag_list.remove("awesome, slick", parse: true)
102
+ ```
103
+
104
+ You can also add and remove tags by direct assignment. Note this will
105
+ remove existing tags so use it with attention.
106
+
107
+ ```ruby
108
+ @user.tag_list = "awesome, slick, hefty"
109
+ @user.tags
110
+ # => [<Tag name:"awesome">,<Tag name:"slick">,<Tag name:"hefty">]
111
+ ```
112
+
113
+ With the defined context in model, you have multiple new methods at disposal
114
+ to manage and view the tags in the context. For example, with `:skill` context
115
+ these methods are added to the model: `skill_list`(and `skill_list.add`, `skill_list.remove`
116
+ `skill_list=`), `skills`(plural), skill_counts
117
+
118
+
119
+ ```ruby
120
+ @user.skill_list = "joking, clowning, boxing"
121
+
122
+ @user.skills
123
+ # => [<Tag name:"joking">,<Tag name:"clowning">,<Tag name:"boxing">]
69
124
 
70
- @user.tags # => [<Tag name:"awesome">,<Tag name:"slick">,<Tag name:"hefty">]
71
- @user.skills # => [<Tag name:"joking">,<Tag name:"clowning">,<Tag name:"boxing">]
72
- @user.skill_list # => ["joking","clowning","boxing"] as TagList
125
+ @user.skill_list.add("coding")
73
126
 
74
- @user.tag_list.remove("awesome") # remove a single tag
75
- @user.tag_list.remove("awesome, slick") # works with arrays too
76
- @user.tag_list.add("awesomer") # add a single tag. alias for <<
77
- @user.tag_list.add("awesomer, slicker") # also works with arrays
127
+ @user.skill_list
128
+ # => ["joking","clowning","boxing", "coding"]
78
129
 
79
- User.skill_counts # => [<Tag name="joking" count=2>,<Tag name="clowning" count=1>...]
130
+ User.skill_counts
131
+ # => [<Tag name="joking" count=2>,<Tag name="clowning" count=1>...]
80
132
  ```
81
133
 
82
134
  To preserve the order in which tags are created use `acts_as_ordered_taggable`:
@@ -128,7 +180,7 @@ User.tagged_with(['awesome, cool'], :on => :tags, :any => true).tagged_with(['sm
128
180
 
129
181
  You can also use `:wild => true` option along with `:any` or `:exclude` option. It will looking for `%awesome%` and `%cool%` in sql.
130
182
 
131
- __Tip:__ `User.tagged_with([])` or '' will return `[]`, but not all records.
183
+ __Tip:__ `User.tagged_with([])` or `User.tagged_with('')` will return `[]`, but not all records.
132
184
 
133
185
  ### Relationships
134
186
 
@@ -2,6 +2,6 @@ When upgrading
2
2
 
3
3
  Re-run the migrations generator
4
4
 
5
- rake railties:install:migrations FROM=acts_as_taggable_on_engine db:migrate
5
+ rake acts_as_taggable_on_engine:install:migrations
6
6
 
7
7
  It will create any new migrations and skip existing ones
@@ -18,8 +18,8 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- if File.exists?('UPGRADING')
22
- gem.post_install_message = File.read('UPGRADING')
21
+ if File.exists?('UPGRADING.md')
22
+ gem.post_install_message = File.read('UPGRADING.md')
23
23
  end
24
24
 
25
25
  gem.add_runtime_dependency 'rails', ['>= 3', '< 5']
@@ -307,7 +307,7 @@ module ActsAsTaggableOn::Taggable
307
307
  end
308
308
 
309
309
  def process_dirty_object(context,new_list)
310
- value = new_list.is_a?(Array) ? new_list.join(', ') : new_list
310
+ value = new_list.is_a?(Array) ? ActsAsTaggableOn::TagList.new(new_list) : new_list
311
311
  attrib = "#{context.to_s.singularize}_list"
312
312
 
313
313
  if changed_attributes.include?(attrib)
@@ -100,7 +100,11 @@ module ActsAsTaggableOn
100
100
  private
101
101
 
102
102
  def comparable_name(str)
103
- as_8bit_ascii(str).downcase
103
+ if ActsAsTaggableOn.strict_case_match
104
+ as_8bit_ascii(str)
105
+ else
106
+ as_8bit_ascii(str).downcase
107
+ end
104
108
  end
105
109
 
106
110
  def binary
@@ -109,7 +113,7 @@ module ActsAsTaggableOn
109
113
 
110
114
  def as_8bit_ascii(string)
111
115
  if defined?(Encoding)
112
- string.to_s.force_encoding('BINARY')
116
+ string.to_s.dup.force_encoding('BINARY')
113
117
  else
114
118
  string.to_s.mb_chars
115
119
  end
@@ -1,4 +1,4 @@
1
1
  module ActsAsTaggableOn
2
- VERSION = '3.0.0'
2
+ VERSION = '3.0.1'
3
3
  end
4
4
 
@@ -72,16 +72,30 @@ describe ActsAsTaggableOn::Tag do
72
72
  ActsAsTaggableOn::Tag.find_or_create_all_with_like_by_name("AWESOME").should == [@tag]
73
73
  end
74
74
 
75
+ it "should find by name case sensitive" do
76
+ ActsAsTaggableOn.strict_case_match = true
77
+ expect {
78
+ ActsAsTaggableOn::Tag.find_or_create_all_with_like_by_name("AWESOME")
79
+ }.to change(ActsAsTaggableOn::Tag, :count).by(1)
80
+ end
81
+
75
82
  it "should create by name" do
76
- lambda {
83
+ expect {
77
84
  ActsAsTaggableOn::Tag.find_or_create_all_with_like_by_name("epic")
78
- }.should change(ActsAsTaggableOn::Tag, :count).by(1)
85
+ }.to change(ActsAsTaggableOn::Tag, :count).by(1)
86
+ end
87
+
88
+ it "should find or create by name case sensitive" do
89
+ ActsAsTaggableOn.strict_case_match = true
90
+ expect {
91
+ ActsAsTaggableOn::Tag.find_or_create_all_with_like_by_name("AWESOME", 'awesome').map(&:name).should == ["AWESOME", "awesome"]
92
+ }.to change(ActsAsTaggableOn::Tag, :count).by(1)
79
93
  end
80
94
 
81
95
  it "should find or create by name" do
82
- lambda {
96
+ expect {
83
97
  ActsAsTaggableOn::Tag.find_or_create_all_with_like_by_name("awesome", "epic").map(&:name).should == ["awesome", "epic"]
84
- }.should change(ActsAsTaggableOn::Tag, :count).by(1)
98
+ }.to change(ActsAsTaggableOn::Tag, :count).by(1)
85
99
  end
86
100
 
87
101
  it "should return an empty array if no tags are specified" do
@@ -180,6 +194,13 @@ describe ActsAsTaggableOn::Tag do
180
194
  ActsAsTaggableOn::Tag.named('cool').should include(@tag)
181
195
  ActsAsTaggableOn::Tag.named('cool').should_not include(uppercase_tag)
182
196
  end
197
+
198
+ it "should not change enconding" do
199
+ name = "\u3042"
200
+ original_encoding = name.encoding
201
+ ActsAsTaggableOn::Tag.find_or_create_with_like_by_name(name)
202
+ name.encoding.should == original_encoding
203
+ end
183
204
  end
184
205
 
185
206
  describe "name uniqeness validation" do
@@ -562,6 +562,22 @@ describe "Taggable" do
562
562
  it 'does not show any changes to the taggable item' do
563
563
  @taggable.changes.should == {}
564
564
  end
565
+
566
+ context "and using a delimiter different from a ','" do
567
+ before do
568
+ @old_delimiter = ActsAsTaggableOn.delimiter
569
+ ActsAsTaggableOn.delimiter = ';'
570
+ end
571
+
572
+ after do
573
+ ActsAsTaggableOn.delimiter = @old_delimiter
574
+ end
575
+
576
+ it 'does not show any changes to the taggable item when using array assignments' do
577
+ @taggable.tag_list = ["awesome", "epic"]
578
+ @taggable.changes.should == {}
579
+ end
580
+ end
565
581
  end
566
582
  end
567
583
 
data/spec/spec_helper.rb CHANGED
@@ -3,6 +3,7 @@ $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
3
3
  require 'logger'
4
4
 
5
5
  require File.expand_path('../../lib/acts-as-taggable-on', __FILE__)
6
+ I18n.enforce_available_locales = true
6
7
  require 'ammeter/init'
7
8
 
8
9
  unless [].respond_to?(:freq)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts-as-taggable-on
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-01 00:00:00.000000000 Z
12
+ date: 2014-01-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -129,12 +129,13 @@ files:
129
129
  - .travis.yml
130
130
  - Appraisals
131
131
  - CHANGELOG.md
132
+ - CONTRIBUTING.md
132
133
  - Gemfile
133
134
  - Guardfile
134
135
  - LICENSE.md
135
136
  - README.md
136
137
  - Rakefile
137
- - UPGRADING
138
+ - UPGRADING.md
138
139
  - acts-as-taggable-on.gemspec
139
140
  - db/migrate/1_acts_as_taggable_on_migration.rb
140
141
  - db/migrate/2_add_missing_unique_indices.rb
@@ -185,7 +186,7 @@ post_install_message: |
185
186
 
186
187
  Re-run the migrations generator
187
188
 
188
- rake railties:install:migrations FROM=acts_as_taggable_on_engine db:migrate
189
+ rake acts_as_taggable_on_engine:install:migrations
189
190
 
190
191
  It will create any new migrations and skip existing ones
191
192
  rdoc_options: []