army-negative 2.0.0 → 3.0.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.
- data/army-negative.gemspec +7 -4
- data/dummy/Gemfile +5 -0
- data/dummy/Rakefile +2 -6
- data/dummy/config.ru +3 -0
- data/dummy/config/application.rb +9 -0
- data/dummy/config/boot.rb +3 -111
- data/dummy/config/database.yml +5 -14
- data/dummy/config/environment.rb +2 -9
- data/features/support/step_definitions.rb +2 -2
- data/lib/army-negative.rb +5 -6
- data/lib/army-negative/railtie.rb +12 -0
- data/lib/army-negative/version.rb +1 -1
- metadata +24 -20
- data/dummy/config/initializers/army-negative.rb +0 -3
- data/dummy/config/initializers/session_store.rb +0 -5
- data/dummy/config/routes.rb +0 -1
data/army-negative.gemspec
CHANGED
@@ -21,7 +21,10 @@ Gem::Specification.new do |s|
|
|
21
21
|
Used for special cases, such as developing rails apps that must, for
|
22
22
|
example, work with existing databases that use such a convention.
|
23
23
|
|
24
|
-
|
24
|
+
For a rails app version X.Y.Z, use army-negative version "~> X.Y.0". For
|
25
|
+
example, a rails 3.0.x app should use "~> 3.0.0" and a 3.1.x app would use
|
26
|
+
"~> 3.1.0", etc. The exception is that rails 2.3.x apps should just use
|
27
|
+
"~> 2.0" since 2.3 is the earliest version of rails that's supported.
|
25
28
|
DESCRIPTION
|
26
29
|
|
27
30
|
s.files = `git ls-files`.split("\n")
|
@@ -29,12 +32,12 @@ Gem::Specification.new do |s|
|
|
29
32
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
30
33
|
s.require_paths = ["lib"]
|
31
34
|
|
32
|
-
s.add_dependency "rails",
|
33
|
-
s.add_dependency "
|
35
|
+
s.add_dependency "rails", "~> 3.0.0"
|
36
|
+
s.add_dependency "mysql2", "~> 0.2.11"
|
34
37
|
|
35
38
|
if s.respond_to?(:add_development_dependency)
|
36
39
|
s.add_development_dependency "bundler", "~> 1.0.18"
|
37
|
-
s.add_development_dependency "cucumber", "~> 1.0.
|
40
|
+
s.add_development_dependency "cucumber", "~> 1.0.5"
|
38
41
|
s.add_development_dependency "rspec", "~> 2.6.0"
|
39
42
|
end
|
40
43
|
|
data/dummy/Gemfile
ADDED
data/dummy/Rakefile
CHANGED
@@ -1,8 +1,4 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require
|
3
|
-
|
2
|
+
require File.expand_path('../config/application', __FILE__)
|
4
3
|
require 'rake'
|
5
|
-
|
6
|
-
require 'rake/rdoctask'
|
7
|
-
|
8
|
-
require 'tasks/rails'
|
4
|
+
Dummy::Application.load_tasks
|
data/dummy/config.ru
ADDED
data/dummy/config/boot.rb
CHANGED
@@ -1,112 +1,4 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
3
|
-
|
4
|
-
|
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!
|
2
|
+
require 'rubygems'
|
3
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
4
|
+
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
|
data/dummy/config/database.yml
CHANGED
@@ -1,21 +1,12 @@
|
|
1
1
|
# MySQL. Versions 4.1 and 5.0 are recommended.
|
2
2
|
#
|
3
3
|
# Install the MySQL driver:
|
4
|
-
# gem install
|
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.
|
4
|
+
# gem install mysql2
|
14
5
|
#
|
15
6
|
# And be sure to use new-style password hashing:
|
16
7
|
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
|
17
8
|
development:
|
18
|
-
adapter:
|
9
|
+
adapter: mysql2
|
19
10
|
encoding: utf8
|
20
11
|
reconnect: false
|
21
12
|
database: dummy_development
|
@@ -28,7 +19,7 @@ development:
|
|
28
19
|
# re-generated from your development database when you run "rake".
|
29
20
|
# Do not set this db to the same as development or production.
|
30
21
|
test:
|
31
|
-
adapter:
|
22
|
+
adapter: mysql2
|
32
23
|
encoding: utf8
|
33
24
|
reconnect: false
|
34
25
|
database: dummy_test
|
@@ -38,11 +29,11 @@ test:
|
|
38
29
|
socket: /var/run/mysqld/mysqld.sock
|
39
30
|
|
40
31
|
production:
|
41
|
-
adapter:
|
32
|
+
adapter: mysql2
|
42
33
|
encoding: utf8
|
43
34
|
reconnect: false
|
44
35
|
database: dummy_production
|
45
36
|
pool: 5
|
46
37
|
username: root
|
47
|
-
password:
|
38
|
+
password:
|
48
39
|
socket: /var/run/mysqld/mysqld.sock
|
data/dummy/config/environment.rb
CHANGED
@@ -1,10 +1,3 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
3
|
-
|
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
|
2
|
+
require File.expand_path('../application', __FILE__)
|
3
|
+
Dummy::Application.initialize!
|
@@ -8,9 +8,9 @@ When /^I create a user named '([^']+)' with '([^']+)' set to true$/ do |username
|
|
8
8
|
User.create :username => username, column.intern => true
|
9
9
|
end
|
10
10
|
|
11
|
-
Then /^the '([^']+)' column for '([^']+)' should be '(
|
11
|
+
Then /^the '([^']+)' column for '([^']+)' should be '(-?\d+)'$/ do |column, username, value|
|
12
12
|
user = User.find_by_username(username)
|
13
|
-
user.send("#{column}_before_type_cast").should == value
|
13
|
+
user.send("#{column}_before_type_cast").should == value.to_i
|
14
14
|
end
|
15
15
|
|
16
16
|
When /^I load a user named '([^']+)' who's '([^']+)' column is '(-?\d+)'$/ do |username, column, value|
|
data/lib/army-negative.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'army-negative/version'
|
2
|
+
require 'army-negative/railtie' if defined?(Rails)
|
2
3
|
|
3
4
|
module Army
|
4
5
|
module Negative
|
@@ -8,14 +9,12 @@ module Army
|
|
8
9
|
autoload :MysqlAdapter, 'army-negative/mysql_adapter'
|
9
10
|
|
10
11
|
#
|
11
|
-
#
|
12
|
-
# all true values get stored as -1 and
|
13
|
-
#
|
14
|
-
# Example:
|
15
|
-
# require 'army-negative'
|
16
|
-
# Army::Negative.activate!
|
12
|
+
# Called during gem initialization (via Army::Negative::Railtie) in order to
|
13
|
+
# active army-negative and ensure all true values get stored as -1 and that
|
14
|
+
# -1's are recognized as true.
|
17
15
|
#
|
18
16
|
def activate!
|
17
|
+
require 'active_record/connection_adapters/mysql_adapter'
|
19
18
|
ActiveRecord::ConnectionAdapters::Column.send :extend, Column
|
20
19
|
ActiveRecord::ConnectionAdapters::Quoting.send :include, Quoting
|
21
20
|
ActiveRecord::ConnectionAdapters::MysqlAdapter.send :include, MysqlAdapter
|
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:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
|
-
-
|
7
|
+
- 3
|
8
8
|
- 0
|
9
9
|
- 0
|
10
|
-
version:
|
10
|
+
version: 3.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kendall Gifford
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-09-
|
18
|
+
date: 2011-09-13 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
prerelease: false
|
@@ -25,12 +25,12 @@ dependencies:
|
|
25
25
|
requirements:
|
26
26
|
- - ~>
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
hash:
|
28
|
+
hash: 7
|
29
29
|
segments:
|
30
|
-
- 2
|
31
30
|
- 3
|
32
31
|
- 0
|
33
|
-
|
32
|
+
- 0
|
33
|
+
version: 3.0.0
|
34
34
|
version_requirements: *id001
|
35
35
|
name: rails
|
36
36
|
- !ruby/object:Gem::Dependency
|
@@ -41,14 +41,14 @@ dependencies:
|
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
hash:
|
44
|
+
hash: 1
|
45
45
|
segments:
|
46
|
+
- 0
|
46
47
|
- 2
|
47
|
-
-
|
48
|
-
|
49
|
-
version: 2.8.1
|
48
|
+
- 11
|
49
|
+
version: 0.2.11
|
50
50
|
version_requirements: *id002
|
51
|
-
name:
|
51
|
+
name: mysql2
|
52
52
|
- !ruby/object:Gem::Dependency
|
53
53
|
prerelease: false
|
54
54
|
type: :development
|
@@ -73,12 +73,12 @@ dependencies:
|
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
hash:
|
76
|
+
hash: 29
|
77
77
|
segments:
|
78
78
|
- 1
|
79
79
|
- 0
|
80
|
-
-
|
81
|
-
version: 1.0.
|
80
|
+
- 5
|
81
|
+
version: 1.0.5
|
82
82
|
version_requirements: *id004
|
83
83
|
name: cucumber
|
84
84
|
- !ruby/object:Gem::Dependency
|
@@ -106,7 +106,10 @@ description: |-
|
|
106
106
|
as true as well.
|
107
107
|
Used for special cases, such as developing rails apps that must, for
|
108
108
|
example, work with existing databases that use such a convention.
|
109
|
-
|
109
|
+
For a rails app version X.Y.Z, use army-negative version "~> X.Y.0". For
|
110
|
+
example, a rails 3.0.x app should use "~> 3.0.0" and a 3.1.x app would use
|
111
|
+
"~> 3.1.0", etc. The exception is that rails 2.3.x apps should just use
|
112
|
+
"~> 2.0" since 2.3 is the earliest version of rails that's supported.
|
110
113
|
email:
|
111
114
|
- zettabyte@gmail.com
|
112
115
|
executables: []
|
@@ -125,15 +128,15 @@ files:
|
|
125
128
|
- README.rdoc
|
126
129
|
- Rakefile
|
127
130
|
- army-negative.gemspec
|
131
|
+
- dummy/Gemfile
|
128
132
|
- dummy/Rakefile
|
129
133
|
- dummy/app/models/user.rb
|
134
|
+
- dummy/config.ru
|
135
|
+
- dummy/config/application.rb
|
130
136
|
- dummy/config/boot.rb
|
131
137
|
- dummy/config/database.yml
|
132
138
|
- dummy/config/environment.rb
|
133
139
|
- 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
140
|
- dummy/db/migrate/20110909225432_create_users.rb
|
138
141
|
- dummy/db/schema.rb
|
139
142
|
- dummy/test/fixtures/users.yml
|
@@ -144,6 +147,7 @@ files:
|
|
144
147
|
- lib/army-negative/column.rb
|
145
148
|
- lib/army-negative/mysql_adapter.rb
|
146
149
|
- lib/army-negative/quoting.rb
|
150
|
+
- lib/army-negative/railtie.rb
|
147
151
|
- lib/army-negative/version.rb
|
148
152
|
homepage: http://github.com/zettabyte/army-negative
|
149
153
|
licenses:
|
@@ -174,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
178
|
requirements: []
|
175
179
|
|
176
180
|
rubyforge_project:
|
177
|
-
rubygems_version: 1.8.
|
181
|
+
rubygems_version: 1.8.10
|
178
182
|
signing_key:
|
179
183
|
specification_version: 3
|
180
184
|
summary: Monkey-patches ActiveRecord's MySQL (ARMy) connection adapter to store boolean trues as negative ones
|
data/dummy/config/routes.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|