Skip to content

Commit

Permalink
Merge branch 'master' into integration
Browse files Browse the repository at this point in the history
* master: (26 commits)
  mbleigh#623 collation parameter is ignored if it generates an exception.
  Update release date for 3.5.0
  Update README.md
  Changing ActsAsTaggable to ActsAsTaggableOn
  version 3.5.0
  Add context constraint to find_related_* methods. Fixes mbleigh#628
  added rake rule and a config parameter to force binary collation (MySql)
  added migration and rake task
  mbleigh#623: added manual column alter suggestion to fix special characters in tags (MySql only)
  version bump
  Add context constraint to find_related_* methods. Fixes mbleigh#628
  Fixing typo in docs with strong typing
  Namespaced TagList usage in a customer parser
  version bump, test on ruby 2.2, remove rails edge from matrix.
  clears column cache on reset_column_information resolves mbleigh#621
  Use the new build env on Travis
  Update README.md
  sha_prefix should not be random
  Fix milestones link
  Meet interface expectation for active record.
  ...
  • Loading branch information
Mark Edmondson committed Jun 18, 2015
2 parents b1821da + 5fc7451 commit 129c8fd
Show file tree
Hide file tree
Showing 30 changed files with 215 additions and 98 deletions.
29 changes: 13 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
language: ruby

rvm:
- 1.9.3
- 2.1
- 2.2
- 2.0.0
- 2.1.1
- 1.9.3
- rbx-2
- ruby-head

env:
- DB=sqlite3
Expand All @@ -14,30 +16,25 @@ gemfile:
- gemfiles/activerecord_3.2.gemfile
- gemfiles/activerecord_4.0.gemfile
- gemfiles/activerecord_4.1.gemfile
- gemfiles/activerecord_edge.gemfile

cache: bundler
sudo: false

bundler_args: '--without local_development --jobs 3 --retry 3'

script: bundle exec rake
before_install: gem install bundler
bundler_args: '--without local_development'

matrix:
fast_finish: true
allow_failures:
- gemfile: gemfiles/activerecord_edge.gemfile
- rvm: rbx-2
- rvm: ruby-head
exclude:
- rvm: 2.2
gemfile: gemfiles/activerecord_3.2.gemfile
- rvm: 1.9.3
gemfile: gemfiles/activerecord_4.0.gemfile
- rvm: 1.9.3
gemfile: gemfiles/activerecord_4.1.gemfile
- rvm: 1.9.3
gemfile: gemfiles/activerecord_edge.gemfile
- rvm: rbx-2
gemfile: gemfiles/activerecord_3.2.gemfile
- rvm: ruby-head
gemfile: gemfiles/activerecord_3.2.gemfile
- rvm: ruby-head
gemfile: gemfiles/activerecord_4.0.gemfile
- rvm: ruby-head
gemfile: gemfiles/activerecord_4.1.gemfile

16 changes: 5 additions & 11 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
appraise "activerecord-3.2" do
gem "activerecord", "~> 3.2"
gem "activerecord", github: "rails/rails" , branch: '3-2-stable'
end

appraise "activerecord-4.0" do
gem "activerecord", "~> 4.0.0"
gem "activerecord", github: "rails/rails" , branch: '4-0-stable'
end

appraise "activerecord-4.1" do
gem "activerecord", "~> 4.1.0"
gem "activerecord", github: "rails/rails" , branch: '4-1-stable'
end

appraise "activerecord-4.2" do
gem "railties", ">= 4.2.0.beta1"
gem "activerecord", ">= 4.2.0.beta1"
gem "rack", ">= 1.6.0.beta"
end

appraise "activerecord-edge" do
gem "activerecord", github: "rails/rails"
gem 'arel', github: 'rails/arel'
gem "railties", github: "rails/rails" , branch: '4-2-stable'
gem "activerecord", github: "rails/rails" , branch: '4-2-stable'
end
27 changes: 21 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,32 @@ Each change should fall into categories that would affect whether the release is

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.

### Master [changes](https://github.com/mbleigh/acts-as-taggable-on/compare/v3.4.1...master)
### [3.5.0 / 2015-03-03](https://github.com/mbleigh/acts-as-taggable-on/compare/v3.4.4...v3.5.0)

* Breaking Changes
* Features
* Fixes
* Performance
* Misc
* [@rikettsie Fixed collation for MySql via rake rule or config parameter](https://github.com/mbleigh/acts-as-taggable-on/pull/634)

### [3.4.4 / 2015-02-11](https://github.com/mbleigh/acts-as-taggable-on/compare/v3.4.3...v3.4.4)

* Fixes
* [@d4rky-pl Add context constraint to find_related_* methods](https://github.com/mbleigh/acts-as-taggable-on/pull/629)


### [3.4.3 / 2014-09-26](https://github.com/mbleigh/acts-as-taggable-on/compare/v3.4.2...v3.4.3)

* Fixes
* [@warp clears column cache on reset_column_information resolves](https://github.com/mbleigh/acts-as-taggable-on/pull/621)

### [3.4.2 / 2014-09-26](https://github.com/mbleigh/acts-as-taggable-on/compare/v3.4.1...v3.4.2)

* Fixes
* [@stiff fixed tagged_with :any in postgresql](https://github.com/mbleigh/acts-as-taggable-on/pull/570)
* [@jerefrer fixed encoding in mysql](https://github.com/mbleigh/acts-as-taggable-on/pull/588)
* [@markedmondson Ensure taggings context aliases are maintained when joining multiple taggables](https://github.com/mbleigh/acts-as-taggable-on/pull/589)

### [3.4.1 / 2014-09-01](https://github.com/mbleigh/acts-as-taggable-on/compare/v3.4.0...v3.4.1)
* Fixes
* [@konukhov fix owned ordered taggable bug]((https://github.com/mbleigh/acts-as-taggable-on/pull/585)
* [@konukhov fix owned ordered taggable bug](https://github.com/mbleigh/acts-as-taggable-on/pull/585)

### [3.4.0 / 2014-08-29](https://github.com/mbleigh/acts-as-taggable-on/compare/v3.3.0...v3.4.0)

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ group :local_development do
gem 'appraisal'
gem 'rake'
gem 'byebug' , platform: :mri_21
end
end
44 changes: 38 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# ActsAsTaggableOn
[![Gem Version](https://badge.fury.io/rb/acts-as-taggable-on.svg)](http://badge.fury.io/rb/acts-as-taggable-on)
[![Build Status](https://secure.travis-ci.org/mbleigh/acts-as-taggable-on.png)](http://travis-ci.org/mbleigh/acts-as-taggable-on)
[![Code Climate](https://codeclimate.com/github/mbleigh/acts-as-taggable-on.png)](https://codeclimate.com/github/mbleigh/acts-as-taggable-on)
[![Inline docs](http://inch-ci.org/github/mbleigh/acts-as-taggable-on.png)](http://inch-ci.org/github/mbleigh/acts-as-taggable-on)
Expand All @@ -24,14 +25,14 @@ Versions 2.4.1 and up are compatible with Rails 4 too (thanks to arabonradar and

Versions >= 3.x are compatible with Ruby 1.9.3+ and Rails 3 and 4.

For an up-to-date roadmap, see https://github.com/mbleigh/acts-as-taggable-on/issues/milestones
For an up-to-date roadmap, see https://github.com/mbleigh/acts-as-taggable-on/milestones

## Installation

To use it, add it to your Gemfile:

```ruby
gem 'acts-as-taggable-on'
gem 'acts-as-taggable-on', '~> 3.4'
```

and bundle:
Expand All @@ -56,6 +57,22 @@ Review the generated migrations then migrate :
rake db:migrate
```

#### For MySql users
You can circumvent at any time the problem of special characters [issue 623](https://github.com/mbleigh/acts-as-taggable-on/issues/623) by setting in an initializer file:

```ruby
ActsAsTaggableOn.force_binary_collation = true
```

Or by running this rake task:

```shell
rake acts_as_taggable_on_engine:tag_names:collate_bin
```

See the Configuration section for more details, and a general note valid for older
version of the gem.

#### Upgrading

see [UPGRADING](UPGRADING.md)
Expand Down Expand Up @@ -179,7 +196,7 @@ ActsAsTaggableOn::Tag.most_used
ActsAsTaggableOn::Tag.least_used
```

You can also filter the results by passing the method a limit, however the default limit is 50.
You can also filter the results by passing the method a limit, however the default limit is 20.

```ruby
ActsAsTaggableOn::Tag.most_used(10)
Expand Down Expand Up @@ -261,7 +278,7 @@ If you want to change how tags are parsed, you can define a your own implementat
```ruby
class MyParser < ActsAsTaggableOn::GenericParser
def parse
TagList.new.tap do |tag_list|
ActsAsTaggableOn::TagList.new.tap do |tag_list|
tag_list.add @tag_list.split('|')
end
end
Expand All @@ -285,7 +302,7 @@ Now you can use this parser, passing it as parameter:
Or change it globally:

```ruby
ActsAsTaggable.default_parser = MyParser
ActsAsTaggableOn.default_parser = MyParser
@user = User.new(:name => "Bobby")
@user.tag_list = "east|south"
@user.tag_list # => ["east", "south"]
Expand Down Expand Up @@ -406,13 +423,28 @@ If you would like tags to be case-sensitive and not use LIKE queries for creatio
ActsAsTaggableOn.strict_case_match = true
```

If you would like to have an exact match covering special characters with MySql:

```ruby
ActsAsTaggableOn.force_binary_collation = true
```

If you want to change the default delimiter (it defaults to ','). You can also pass in an array of delimiters such as ([',', '|']):

```ruby
ActsAsTaggableOn.delimiter = ','
```

*NOTE: SQLite by default can't upcase or downcase multibyte characters, resulting in unwanted behavior. Load the SQLite ICU extension for proper handle of such characters. [See docs](http://www.sqlite.org/src/artifact?ci=trunk&filename=ext/icu/README.txt)*
*NOTE 1: SQLite by default can't upcase or downcase multibyte characters, resulting in unwanted behavior. Load the SQLite ICU extension for proper handle of such characters. [See docs](http://www.sqlite.org/src/artifact?ci=trunk&filename=ext/icu/README.txt)*

*NOTE 2: the option `force_binary_collation` is strongest than `strict_case_match` and when
set to true, the `strict_case_match` is ignored.
To roughly apply the `force_binary_collation` behaviour with a version of the gem <= 3.4.4, execute the following commands in the MySql console:*

```shell
USE my_wonderful_app_db;
ALTER TABLE tags MODIFY name VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin;
```

## Contributors

Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'rubygems'
require 'bundler/setup'

import "./lib/tasks/tags_collate_utf8.rake"

desc 'Default: run specs'
task default: :spec

Expand Down
9 changes: 2 additions & 7 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,5 @@ Re-run the migrations generator

rake acts_as_taggable_on_engine:install:migrations

It will create any new migrations and skip existing ones


##Breaking changes:

- ActsAsTaggableOn::Tag is not extend with ActsAsTaggableOn::Utils anymore.
Please use ActsAsTaggableOn::Utils instead
This will create any new migrations and skip existing ones
Version 3.5.0 has a migration for mysql adapter
9 changes: 9 additions & 0 deletions db/migrate/5_change_collation_for_tag_names.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This migration is added to circumvent issue #623 and have special characters
# work properly
class ChangeCollationForTagNames < ActiveRecord::Migration
def up
if ActsAsTaggableOn::Utils.using_mysql?
execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;")
end
end
end
3 changes: 2 additions & 1 deletion gemfiles/activerecord_3.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

source "https://rubygems.org"

gem "activerecord", "~> 3.2"
gem "activerecord", :github => "rails/rails", :branch => "3-2-stable"

group :local_development do
gem "guard"
gem "guard-rspec"
gem "appraisal"
gem "rake"
gem "byebug", :platform => :mri_21
end

gemspec :path => "../"
3 changes: 2 additions & 1 deletion gemfiles/activerecord_4.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

source "https://rubygems.org"

gem "activerecord", "~> 4.0.0"
gem "activerecord", :github => "rails/rails", :branch => "4-0-stable"

group :local_development do
gem "guard"
gem "guard-rspec"
gem "appraisal"
gem "rake"
gem "byebug", :platform => :mri_21
end

gemspec :path => "../"
3 changes: 2 additions & 1 deletion gemfiles/activerecord_4.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

source "https://rubygems.org"

gem "activerecord", "~> 4.1.0"
gem "activerecord", :github => "rails/rails", :branch => "4-1-stable"

group :local_development do
gem "guard"
gem "guard-rspec"
gem "appraisal"
gem "rake"
gem "byebug", :platform => :mri_21
end

gemspec :path => "../"
6 changes: 3 additions & 3 deletions gemfiles/activerecord_4.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

source "https://rubygems.org"

gem "railties", ">= 4.2.0.beta1"
gem "activerecord", ">= 4.2.0.beta1"
gem "rack", ">= 1.6.0.beta"
gem "railties", :github => "rails/rails", :branch => "4-2-stable"
gem "activerecord", :github => "rails/rails", :branch => "4-2-stable"

group :local_development do
gem "guard"
gem "guard-rspec"
gem "appraisal"
gem "rake"
gem "byebug", :platform => :mri_21
end

gemspec :path => "../"
15 changes: 0 additions & 15 deletions gemfiles/activerecord_edge.gemfile

This file was deleted.

35 changes: 35 additions & 0 deletions lib/acts-as-taggable-on.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ def initialize
@remove_unused_tags = false
@tags_counter = true
@default_parser = DefaultParser
@force_binary_collation = false
end

def strict_case_match=(force_cs)
if @force_binary_collation == false
@strict_case_match = force_cs
end
end

def delimiter=(string)
Expand All @@ -79,6 +86,34 @@ def delimiter=(string)
WARNING
@delimiter = string
end

def force_binary_collation=(force_bin)
if Utils.using_mysql?
if force_bin == true
Configuration.apply_binary_collation(true)
@force_binary_collation = true
@strict_case_match = true
else
Configuration.apply_binary_collation(false)
@force_binary_collation = false
end
end
end

def self.apply_binary_collation(bincoll)
if Utils.using_mysql?
coll = 'utf8_general_ci'
if bincoll == true
coll = 'utf8_bin'
end
begin
ActiveRecord::Migration.execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE #{coll};")
rescue Exception => e
puts "Trapping #{e.class}: collation parameter ignored while migrating for the first time."
end
end
end

end

setup
Expand Down
Loading

0 comments on commit 129c8fd

Please sign in to comment.