army-negative 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg
5
+ rdoc
6
+ dummy/log
@@ -1,3 +1,12 @@
1
+ = 2.0.0, release 2011-09-12
2
+
3
+ * Reverted code so that the <tt>2.x</tt> series supports rails <tt>2.3.x</tt> apps.
4
+ * Added a cucumber-based test suite.
5
+
6
+ The intent is that newer versions, specifically the <tt>3.x</tt> versions, will
7
+ support the <tt>3.x</tt> versions of rails while any rails <tt>2.3.x</tt> users
8
+ can always use the latest <tt>2.x</tt> version of this gem.
9
+
1
10
  = 1.0.0, release 2011-03-11
2
11
 
3
12
  * Initial Release
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ # encoding: utf-8
2
+ source :rubygems
3
+ gemspec
@@ -1,17 +1,48 @@
1
- = army-negative: negative one's for true!
1
+ = Army::Negative -- Negative ones for true!
2
2
 
3
3
  This gem is a simple ActiveRecord MySQL (+ARMy+) connection adapter
4
4
  monkey-patch. Put it in your +Gemfile+ and all your +true+ are belong to us! Or,
5
5
  rather, they'll suddenly become very negative, negative one specifically.
6
6
 
7
+ See the *Usage* section below for information on how to use this gem with rails
8
+ <tt>2.3.x</tt>.
9
+
10
+ == Versioning
11
+
12
+ As of version <tt>2.0</tt>, a new versioning system has been employed. All
13
+ <tt>2.x</tt> versions of this gem support rails versions <tt>2.3.x</tt>.
14
+
15
+ Versions <tt>3.x</tt> of the gem will support rails versions <tt>3.x</tt>.
16
+
17
+ == Usage
18
+
19
+ In order to use this gem in your rails <tt>2.3.x</tt> app, first modify your
20
+ <tt>config/environment.rb</tt> and add the following within the configuration
21
+ block:
22
+
23
+ Rails::Initializer.run do |config|
24
+ # ...
25
+ config.gem "army-negative", :version => "~> 2.0"
26
+ # ...
27
+ end
28
+
29
+ You can then run <tt>rake gems:install</tt> in order to install the gem.
30
+
31
+ Finally, create a new _initializer_ file in <tt>config/initializers</tt> such as
32
+ the following:
33
+
34
+ # config/initializers/army-negative.rb
35
+ require 'army-negative'
36
+ Army::Negative.activate!
37
+
7
38
  == What This Does
8
39
 
9
- This makes ActiveRecord store the value -1 into your +TINYINT+ +boolean+ columns
10
- whenever they're set to +true+. It also makes ActiveRecord recognize -1 as true
11
- when a +boolean+ field is queried.
40
+ This makes ActiveRecord store the value <tt>-1</tt> into your +TINYINT+
41
+ +boolean+ columns whenever they're set to +true+. It also makes ActiveRecord
42
+ recognize <tt>-1</tt> as +true+ when a +boolean+ field is queried.
12
43
 
13
- *NOTE:* positive one and all other values that were interpreted as +true+ by the
14
- MySQL connection adapter will still be recognized as +true+ too.
44
+ <b>NOTE:</b> positive one and all other values that were interpreted as +true+
45
+ by the MySQL connection adapter will still be recognized as +true+ too.
15
46
 
16
47
  == Why
17
48
 
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+ require 'rubygems'
3
+
4
+ begin
5
+ require 'bundler/setup'
6
+ rescue LoadError
7
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
8
+ end
9
+ require 'bundler/gem_tasks'
10
+
11
+ begin
12
+ require 'rdoc/task'
13
+ rescue LoadError
14
+ require 'rdoc/rdoc'
15
+ require 'rake/rdoctask'
16
+ RDoc::Task = Rake::RDocTask
17
+ end
18
+
19
+ RDoc::Task.new(:rdoc) do |rdoc|
20
+ rdoc.rdoc_dir = "rdoc"
21
+ rdoc.title = "Army::Negative"
22
+ rdoc.options << "--line-numbers"
23
+ rdoc.rdoc_files.include("README.rdoc", "LICENSE", "CHANGELOG.rdoc", "lib/**/*.rb")
24
+ end
25
+
26
+ require 'cucumber'
27
+ require 'cucumber/rake/task'
28
+ Cucumber::Rake::Task.new(:features) do |t|
29
+ t.cucumber_opts = "features --format pretty"
30
+ end
31
+
32
+ task :default => :features
33
+
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+ $LOAD_PATH.push File.expand_path("../lib", __FILE__)
3
+ require 'army-negative/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "army-negative"
7
+ s.version = Army::Negative::Version::STRING
8
+ s.authors = ["Kendall Gifford"]
9
+ s.email = ["zettabyte@gmail.com"]
10
+ s.license = "MIT"
11
+ s.homepage = "http://github.com/zettabyte/army-negative"
12
+ s.summary = "Monkey-patches ActiveRecord's MySQL (ARMy) connection adapter to store boolean trues as negative ones"
13
+ s.description = <<-DESCRIPTION.strip.gsub(/^\s+/, "")
14
+ When this gem is loaded and activated inside your rails app, your MySQL
15
+ connection adapter for ActiveRecord will be monkey-patched. The patch simply
16
+ tweaks it to store all boolean "true" values as negative one instead of
17
+ positive one inside your TINYINT columns. It also patches it to recognize
18
+ and interpret negative one as "true". Positive one will still be recognized
19
+ as true as well.
20
+
21
+ Used for special cases, such as developing rails apps that must, for
22
+ example, work with existing databases that use such a convention.
23
+
24
+ Use versions ~> 2.0 for rails 2.x apps. and versions > 2 for rails 3 apps.
25
+ DESCRIPTION
26
+
27
+ s.files = `git ls-files`.split("\n")
28
+ s.test_files = `git ls-files -- {features,dummy}/*`.split("\n")
29
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
30
+ s.require_paths = ["lib"]
31
+
32
+ s.add_dependency "rails", "~> 2.3.0"
33
+ s.add_dependency "mysql", "~> 2.8.1"
34
+
35
+ if s.respond_to?(:add_development_dependency)
36
+ s.add_development_dependency "bundler", "~> 1.0.18"
37
+ s.add_development_dependency "cucumber", "~> 1.0.3"
38
+ s.add_development_dependency "rspec", "~> 2.6.0"
39
+ end
40
+
41
+ if s.respond_to?(:extra_rdoc_files)
42
+ s.extra_rdoc_files = ["README.rdoc", "LICENSE", "CHANGELOG.rdoc"]
43
+ end
44
+ end
45
+
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+ require(File.join(File.dirname(__FILE__), 'config', 'boot'))
3
+
4
+ require 'rake'
5
+ require 'rake/testtask'
6
+ require 'rake/rdoctask'
7
+
8
+ require 'tasks/rails'
@@ -0,0 +1,3 @@
1
+ # encoding: utf-8
2
+ class User < ActiveRecord::Base
3
+ end
@@ -0,0 +1,112 @@
1
+ # encoding: utf-8
2
+ RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
3
+
4
+ module Rails
5
+ class << self
6
+ def boot!
7
+ unless booted?
8
+ preinitialize
9
+ pick_boot.run
10
+ end
11
+ end
12
+
13
+ def booted?
14
+ defined? Rails::Initializer
15
+ end
16
+
17
+ def pick_boot
18
+ (vendor_rails? ? VendorBoot : GemBoot).new
19
+ end
20
+
21
+ def vendor_rails?
22
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
23
+ end
24
+
25
+ def preinitialize
26
+ load(preinitializer_path) if File.exist?(preinitializer_path)
27
+ end
28
+
29
+ def preinitializer_path
30
+ "#{RAILS_ROOT}/config/preinitializer.rb"
31
+ end
32
+ end
33
+
34
+ class Boot
35
+ def run
36
+ load_initializer
37
+ Rails::Initializer.run(:set_load_path)
38
+ end
39
+ end
40
+
41
+ class VendorBoot < Boot
42
+ def load_initializer
43
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
44
+ Rails::Initializer.run(:install_gem_spec_stubs)
45
+ Rails::GemDependency.add_frozen_gem_path
46
+ end
47
+ end
48
+
49
+ class GemBoot < Boot
50
+ def load_initializer
51
+ self.class.load_rubygems
52
+ load_rails_gem
53
+ require 'initializer'
54
+ end
55
+
56
+ def load_rails_gem
57
+ if version = self.class.gem_version
58
+ gem 'rails', version
59
+ else
60
+ gem 'rails'
61
+ end
62
+ rescue Gem::LoadError => load_error
63
+ if load_error.message =~ /Could not find RubyGem rails/
64
+ STDERR.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
65
+ exit 1
66
+ else
67
+ raise
68
+ end
69
+ end
70
+
71
+ class << self
72
+ def rubygems_version
73
+ Gem::RubyGemsVersion rescue nil
74
+ end
75
+
76
+ def gem_version
77
+ if defined? RAILS_GEM_VERSION
78
+ RAILS_GEM_VERSION
79
+ elsif ENV.include?('RAILS_GEM_VERSION')
80
+ ENV['RAILS_GEM_VERSION']
81
+ else
82
+ parse_gem_version(read_environment_rb)
83
+ end
84
+ end
85
+
86
+ def load_rubygems
87
+ min_version = '1.3.2'
88
+ require 'rubygems'
89
+ unless rubygems_version >= min_version
90
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
91
+ exit 1
92
+ end
93
+
94
+ rescue LoadError
95
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
96
+ exit 1
97
+ end
98
+
99
+ def parse_gem_version(text)
100
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
101
+ end
102
+
103
+ private
104
+ def read_environment_rb
105
+ File.read("#{RAILS_ROOT}/config/environment.rb")
106
+ end
107
+ end
108
+ end
109
+ end
110
+
111
+ # All that for this:
112
+ Rails.boot!
@@ -0,0 +1,48 @@
1
+ # MySQL. Versions 4.1 and 5.0 are recommended.
2
+ #
3
+ # Install the MySQL driver:
4
+ # gem install mysql
5
+ # On Mac OS X:
6
+ # sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
7
+ # On Mac OS X Leopard:
8
+ # sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
9
+ # This sets the ARCHFLAGS environment variable to your native architecture
10
+ # On Windows:
11
+ # gem install mysql
12
+ # Choose the win32 build.
13
+ # Install MySQL and put its /bin directory on your path.
14
+ #
15
+ # And be sure to use new-style password hashing:
16
+ # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
17
+ development:
18
+ adapter: mysql
19
+ encoding: utf8
20
+ reconnect: false
21
+ database: dummy_development
22
+ pool: 5
23
+ username: root
24
+ password:
25
+ socket: /var/run/mysqld/mysqld.sock
26
+
27
+ # Warning: The database defined as "test" will be erased and
28
+ # re-generated from your development database when you run "rake".
29
+ # Do not set this db to the same as development or production.
30
+ test:
31
+ adapter: mysql
32
+ encoding: utf8
33
+ reconnect: false
34
+ database: dummy_test
35
+ pool: 5
36
+ username: root
37
+ password:
38
+ socket: /var/run/mysqld/mysqld.sock
39
+
40
+ production:
41
+ adapter: mysql
42
+ encoding: utf8
43
+ reconnect: false
44
+ database: dummy_production
45
+ pool: 5
46
+ username: root
47
+ password:
48
+ socket: /var/run/mysqld/mysqld.sock
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ # Specifies gem version of Rails to use when vendor/rails is not present
4
+ RAILS_GEM_VERSION = '2.3.14' unless defined? RAILS_GEM_VERSION
5
+
6
+ # Bootstrap the Rails environment, frameworks, and default configuration
7
+ require File.join(File.dirname(__FILE__), 'boot')
8
+
9
+ Rails::Initializer.run do |config|
10
+ end
@@ -0,0 +1 @@
1
+ # encoding: utf-8
@@ -0,0 +1,3 @@
1
+ # encoding: utf-8
2
+ require 'army-negative'
3
+ Army::Negative.activate!
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+ ActionController::Base.session = {
3
+ :key => '_dummy_session',
4
+ :secret => 'b52c736773f335f181876e4c807039d61c64b3416fb814d284f35314c4f869ccc834976ef187cce12b3fa85eea6897f27d23ba458581df8f1b4f622365b2a4b1'
5
+ }
@@ -0,0 +1 @@
1
+ # encoding: utf-8
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+ class CreateUsers < ActiveRecord::Migration
3
+ def self.up
4
+ create_table :users do |t|
5
+ t.string :username
6
+ t.boolean :enabled
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+
12
+ def self.down
13
+ drop_table :users
14
+ end
15
+ end
@@ -0,0 +1,21 @@
1
+ # This file is auto-generated from the current state of the database. Instead of editing this file,
2
+ # please use the migrations feature of Active Record to incrementally modify your database, and
3
+ # then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your database schema. If you need
6
+ # to create the application database on another system, you should be using db:schema:load, not running
7
+ # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
8
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
9
+ #
10
+ # It's strongly recommended to check this file into your version control system.
11
+
12
+ ActiveRecord::Schema.define(:version => 20110909225432) do
13
+
14
+ create_table "users", :force => true do |t|
15
+ t.string "username"
16
+ t.boolean "enabled"
17
+ t.datetime "created_at"
18
+ t.datetime "updated_at"
19
+ end
20
+
21
+ end
@@ -0,0 +1,3 @@
1
+ one:
2
+ username: eunice
3
+ enabled: -1
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+ require 'rake'
3
+
4
+ # Make RSpec expectations available inside our step definitions
5
+ require 'rspec/expectations'
6
+ World(RSpec::Matchers)
7
+
8
+ # Load the rails environment of our test application
9
+ ENV["RAILS_ENV"] = "test"
10
+ RAILS_ROOT = File.expand_path("../../../dummy", __FILE__)
11
+ require File.join(RAILS_ROOT, "config", "environment")
12
+
13
+ # Runs the named rake tasks for the test rails application using the "test"
14
+ # rails environment.
15
+ def run_rails_rake_tasks(*names)
16
+ ARGV.clear
17
+ ARGV.concat(names)
18
+ ARGV << "RAILS_ENV=test"
19
+ Dir.chdir(RAILS_ROOT) do
20
+ old = Rake.application
21
+ Rake.application = Rake::Application.new
22
+ begin
23
+ Rake.application.run
24
+ ensure
25
+ Rake.application = old
26
+ end
27
+ end
28
+ end
29
+
30
+ # Reset the test rails application's test environment database
31
+ run_rails_rake_tasks("db:reset", "db:fixtures:load")
32
+
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ Given /^an ActiveRecord 'User' model with an 'enabled' boolean field and a 'username' field$/ do
4
+ # Done: see the dummy rails app
5
+ end
6
+
7
+ When /^I create a user named '([^']+)' with '([^']+)' set to true$/ do |username, column|
8
+ User.create :username => username, column.intern => true
9
+ end
10
+
11
+ Then /^the '([^']+)' column for '([^']+)' should be '([^']+)'$/ do |column, username, value|
12
+ user = User.find_by_username(username)
13
+ user.send("#{column}_before_type_cast").should == value
14
+ end
15
+
16
+ When /^I load a user named '([^']+)' who's '([^']+)' column is '(-?\d+)'$/ do |username, column, value|
17
+ @user = User.send("find_by_username_and_#{column}", username, value.to_i)
18
+ @user || raise("Unable to find user '#{username}' (who's '#{column}' column is '#{value}')")
19
+ end
20
+
21
+ Then /^the user model's '([^']+)' field for '([^']+)' should be true$/ do |column, username|
22
+ @user.username.should == username
23
+ @user.send("#{column}?").should be_true
24
+ end
25
+
@@ -0,0 +1,16 @@
1
+ Feature: True is stored as a negative one
2
+
3
+ In order to allow my rails application to work with my legacy database
4
+ As a web application developer
5
+ I want rails to store 'true' as negative one in my MySQL TINYINT(1) columns
6
+
7
+ Scenario: Save a record with a 'true' value
8
+ Given an ActiveRecord 'User' model with an 'enabled' boolean field and a 'username' field
9
+ When I create a user named 'howard' with 'enabled' set to true
10
+ Then the 'enabled' column for 'howard' should be '-1'
11
+
12
+ Scenario: Interpret a record with -1 as true
13
+ Given an ActiveRecord 'User' model with an 'enabled' boolean field and a 'username' field
14
+ When I load a user named 'eunice' who's 'enabled' column is '-1'
15
+ Then the user model's 'enabled' field for 'eunice' should be true
16
+
@@ -1,4 +1,4 @@
1
- require 'army-negative/railtie' if defined?(Rails)
1
+ require 'army-negative/version'
2
2
 
3
3
  module Army
4
4
  module Negative
@@ -7,17 +7,20 @@ module Army
7
7
  autoload :Quoting, 'army-negative/quoting'
8
8
  autoload :MysqlAdapter, 'army-negative/mysql_adapter'
9
9
 
10
- def patch_active_record!
11
- ActiveRecord::ConnectionAdapters::Column.send :include, Column
12
- ActiveRecord::ConnectionAdapters::Quoting.send :include, Quoting
13
- end
14
- module_function :patch_active_record!
15
-
16
- def patch_mysql_adapter!
17
- require 'active_record/connection_adapters/mysql_adapter'
10
+ #
11
+ # Call this in an initializer in order to active army-negative and ensure
12
+ # all true values get stored as -1 and -1's are recognized as true.
13
+ #
14
+ # Example:
15
+ # require 'army-negative'
16
+ # Army::Negative.activate!
17
+ #
18
+ def activate!
19
+ ActiveRecord::ConnectionAdapters::Column.send :extend, Column
20
+ ActiveRecord::ConnectionAdapters::Quoting.send :include, Quoting
18
21
  ActiveRecord::ConnectionAdapters::MysqlAdapter.send :include, MysqlAdapter
19
22
  end
20
- module_function :patch_mysql_adapter!
23
+ module_function :activate!
21
24
 
22
25
  end
23
26
  end
@@ -1,15 +1,17 @@
1
- require 'set'
2
-
3
1
  module Army
4
2
  module Negative
5
3
  module Column
6
- TRUE_VALUES_WITH_NEGATIVE_ONES = [-1, '-1'].to_set
4
+
5
+ # Augments ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES
6
+ TRUE_VALUES_WITH_NEGATIVE_ONES = [-1, '-1']
7
7
 
8
8
  #
9
- # Extend ActiveRecord::ConnectionAdapters::Column
9
+ # Called when you extend ActiveRecord::ConnectionAdapters::Column with
10
+ # this module. Uses #alias_method_chain so that
11
+ # #value_to_boolean_with_negative_ones is called instead of
12
+ # #value_to_boolean
10
13
  #
11
- def self.included(klass)
12
- klass.send(:extend, ClassMethods)
14
+ def self.extended(klass)
13
15
  klass.instance_eval do
14
16
  class << self
15
17
  alias_method_chain :value_to_boolean, :negative_ones
@@ -17,14 +19,13 @@ module Army
17
19
  end
18
20
  end
19
21
 
20
- module ClassMethods
21
- #
22
- # Recognize integer -1 and string '-1' as "true" values.
23
- #
24
- def value_to_boolean_with_negative_ones(value)
25
- return true if TRUE_VALUES_WITH_NEGATIVE_ONES.include?(value)
26
- value_to_boolean_without_negative_ones(value)
27
- end
22
+ #
23
+ # Replaces #value_to_boolean in order to recognize integer -1 and string
24
+ # '-1' as "true" values.
25
+ #
26
+ def value_to_boolean_with_negative_ones(value)
27
+ return true if TRUE_VALUES_WITH_NEGATIVE_ONES.include?(value)
28
+ value_to_boolean_without_negative_ones(value)
28
29
  end
29
30
 
30
31
  end
@@ -1,11 +1,16 @@
1
- require 'set'
2
-
3
1
  module Army
4
2
  module Negative
5
3
  module MysqlAdapter
6
4
 
5
+ # Effectively replaces ActiveRecord::ConnectionAdapters::MysqlAdapter::QUOTED_TRUE
7
6
  QUOTED_TRUE_AS_NEGATIVE_ONE = "-1".freeze
8
7
 
8
+ #
9
+ # Called when this module is included in
10
+ # ActiveRecord::ConnectionAdapters::MysqlAdapter. Uses #alias_method to
11
+ # replace the original #quoted_true implementation with this module's
12
+ # implementation named #quoted_true_as_negative_one
13
+ #
9
14
  def self.included(klass)
10
15
  klass.instance_eval do
11
16
  alias_method :quoted_true, :quoted_true_as_negative_one
@@ -13,9 +18,9 @@ module Army
13
18
  end
14
19
 
15
20
  #
16
- # This doesn't seem to actually be necessary in rails 3.0 (though it doesn't
17
- # break anything either) but I'm doing this for completeness: make is so
18
- # that MySQL adapter-specific calls to #quoted_true also get "-1".
21
+ # Replaces the original #quoted_true implementation. When asked for a
22
+ # "quoted_true" value, return our variation (QUOTED_TRUE_AS_NEGATIVE_ONE)
23
+ # instead of the default QUOTED_TRUE value.
19
24
  #
20
25
  def quoted_true_as_negative_one
21
26
  QUOTED_TRUE_AS_NEGATIVE_ONE
@@ -3,7 +3,10 @@ module Army
3
3
  module Quoting
4
4
 
5
5
  #
6
- # Extend ActiveRecord::ConnectionAdapters::Quoting
6
+ # Called when this module is included in
7
+ # ActiveRecord::ConnectionAdapters::Quoting. Uses #alias_method_chain to
8
+ # replace the original #quote method with our #quote_with_negative_one
9
+ # variation.
7
10
  #
8
11
  def self.included(klass)
9
12
  klass.instance_eval do
@@ -12,8 +15,8 @@ module Army
12
15
  end
13
16
 
14
17
  #
15
- # Ensure "true" values get stored as -1 in the database where they'd
16
- # normally have been stored as 1
18
+ # Wraps the original #quote method, ensuring that "true" values get stored
19
+ # as -1 in the database where they'd normally have been stored as 1.
17
20
  #
18
21
  def quote_with_negative_one(value, column = nil)
19
22
  result = quote_without_negative_one(value, column)
@@ -1,10 +1,10 @@
1
1
  module Army
2
2
  module Negative
3
3
  module Version
4
- MAJOR = 1
4
+ MAJOR = 2
5
5
  MINOR = 0
6
6
  TINY = 0
7
- STRING = [MAJOR, MINOR, TINY].join('.')
7
+ STRING = [MAJOR, MINOR, TINY].join(".")
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: army-negative
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
4
+ hash: 15
5
+ prerelease:
6
6
  segments:
7
- - 1
7
+ - 2
8
8
  - 0
9
9
  - 0
10
- version: 1.0.0
10
+ version: 2.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kendall Gifford
@@ -15,41 +15,139 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-11 00:00:00 -07:00
19
- default_executable:
20
- dependencies: []
21
-
18
+ date: 2011-09-12 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ prerelease: false
22
+ type: :runtime
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 2
31
+ - 3
32
+ - 0
33
+ version: 2.3.0
34
+ version_requirements: *id001
35
+ name: rails
36
+ - !ruby/object:Gem::Dependency
37
+ prerelease: false
38
+ type: :runtime
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 45
45
+ segments:
46
+ - 2
47
+ - 8
48
+ - 1
49
+ version: 2.8.1
50
+ version_requirements: *id002
51
+ name: mysql
52
+ - !ruby/object:Gem::Dependency
53
+ prerelease: false
54
+ type: :development
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ hash: 51
61
+ segments:
62
+ - 1
63
+ - 0
64
+ - 18
65
+ version: 1.0.18
66
+ version_requirements: *id003
67
+ name: bundler
68
+ - !ruby/object:Gem::Dependency
69
+ prerelease: false
70
+ type: :development
71
+ requirement: &id004 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ hash: 17
77
+ segments:
78
+ - 1
79
+ - 0
80
+ - 3
81
+ version: 1.0.3
82
+ version_requirements: *id004
83
+ name: cucumber
84
+ - !ruby/object:Gem::Dependency
85
+ prerelease: false
86
+ type: :development
87
+ requirement: &id005 !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ~>
91
+ - !ruby/object:Gem::Version
92
+ hash: 23
93
+ segments:
94
+ - 2
95
+ - 6
96
+ - 0
97
+ version: 2.6.0
98
+ version_requirements: *id005
99
+ name: rspec
22
100
  description: |-
23
- When this gem is loaded in your rails app (Gemfile) your MySQL connection
24
- adapter for ActiveRecord will be monkey-patched. The patch simply tweaks it
25
- to store all boolean "true" values as negative one instead of positive one
26
- inside your TINYINT columns. It also patches it to recognize and interpret
27
- negative one as "true". Positive one will still be recognized as true as
28
- well.
101
+ When this gem is loaded and activated inside your rails app, your MySQL
102
+ connection adapter for ActiveRecord will be monkey-patched. The patch simply
103
+ tweaks it to store all boolean "true" values as negative one instead of
104
+ positive one inside your TINYINT columns. It also patches it to recognize
105
+ and interpret negative one as "true". Positive one will still be recognized
106
+ as true as well.
29
107
  Used for special cases, such as developing rails apps that must, for
30
108
  example, work with existing databases that use such a convention.
109
+ Use versions ~> 2.0 for rails 2.x apps. and versions > 2 for rails 3 apps.
31
110
  email:
32
111
  - zettabyte@gmail.com
33
112
  executables: []
34
113
 
35
114
  extensions: []
36
115
 
37
- extra_rdoc_files: []
38
-
116
+ extra_rdoc_files:
117
+ - README.rdoc
118
+ - LICENSE
119
+ - CHANGELOG.rdoc
39
120
  files:
121
+ - .gitignore
122
+ - CHANGELOG.rdoc
123
+ - Gemfile
124
+ - LICENSE
125
+ - README.rdoc
126
+ - Rakefile
127
+ - army-negative.gemspec
128
+ - dummy/Rakefile
129
+ - dummy/app/models/user.rb
130
+ - dummy/config/boot.rb
131
+ - dummy/config/database.yml
132
+ - dummy/config/environment.rb
133
+ - dummy/config/environments/test.rb
134
+ - dummy/config/initializers/army-negative.rb
135
+ - dummy/config/initializers/session_store.rb
136
+ - dummy/config/routes.rb
137
+ - dummy/db/migrate/20110909225432_create_users.rb
138
+ - dummy/db/schema.rb
139
+ - dummy/test/fixtures/users.yml
140
+ - features/support/env.rb
141
+ - features/support/step_definitions.rb
142
+ - features/true_is_negative_one.feature
143
+ - lib/army-negative.rb
40
144
  - lib/army-negative/column.rb
41
- - lib/army-negative/railtie.rb
42
145
  - lib/army-negative/mysql_adapter.rb
43
146
  - lib/army-negative/quoting.rb
44
147
  - lib/army-negative/version.rb
45
- - lib/army-negative.rb
46
- - LICENSE
47
- - README.rdoc
48
- - CHANGELOG.rdoc
49
- has_rdoc: true
50
- homepage: http://github.com/zettabyte/army-negative/wiki
51
- licenses: []
52
-
148
+ homepage: http://github.com/zettabyte/army-negative
149
+ licenses:
150
+ - MIT
53
151
  post_install_message:
54
152
  rdoc_options: []
55
153
 
@@ -69,16 +167,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
167
  requirements:
70
168
  - - ">="
71
169
  - !ruby/object:Gem::Version
72
- hash: 23
170
+ hash: 3
73
171
  segments:
74
- - 1
75
- - 3
76
- - 6
77
- version: 1.3.6
172
+ - 0
173
+ version: "0"
78
174
  requirements: []
79
175
 
80
- rubyforge_project: army-negative
81
- rubygems_version: 1.3.7
176
+ rubyforge_project:
177
+ rubygems_version: 1.8.6
82
178
  signing_key:
83
179
  specification_version: 3
84
180
  summary: Monkey-patches ActiveRecord's MySQL (ARMy) connection adapter to store boolean trues as negative ones
@@ -1,13 +0,0 @@
1
- require 'army-negative'
2
- require 'rails'
3
-
4
- module Army
5
- module Negative
6
- class Railtie < Rails::Railtie
7
- initializer "army-negative.patch_active_record", :after => "active_record.initialize_database" do
8
- Army::Negative.patch_active_record!
9
- Army::Negative.patch_mysql_adapter!
10
- end
11
- end
12
- end
13
- end