rails2_ruby2 0.1.0 → 1.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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -1
  3. data/lib/rails2_ruby2.rb +0 -4
  4. data/lib/rails2_ruby2/action_mailer.rb +3 -0
  5. data/lib/rails2_ruby2/action_pack.rb +3 -0
  6. data/lib/rails2_ruby2/{named_route_collection_patch.rb → action_pack/named_route_collection_patch.rb} +0 -0
  7. data/lib/rails2_ruby2/action_view.rb +3 -0
  8. data/lib/rails2_ruby2/active_model.rb +3 -0
  9. data/lib/rails2_ruby2/active_record.rb +3 -0
  10. data/lib/rails2_ruby2/active_record/postgresql_adapter.rb +37 -0
  11. data/lib/rails2_ruby2/active_record/schema_statements.rb +9 -0
  12. data/lib/rails2_ruby2/active_resource.rb +3 -0
  13. data/lib/rails2_ruby2/active_support.rb +3 -0
  14. data/lib/rails2_ruby2/{compressed_memcached_store_patch.rb → active_support/compressed_memcached_store_patch.rb} +0 -0
  15. data/lib/rails2_ruby2/{erb_util_silence.rb → active_support/erb_util_silence.rb} +0 -0
  16. data/lib/rails2_ruby2/{i18n_patch.rb → active_support/i18n_patch.rb} +2 -0
  17. data/lib/rails2_ruby2/version.rb +1 -1
  18. data/rails2_ruby2.gemspec +1 -2
  19. metadata +18 -39
  20. data/lib/rails2_ruby2/action_controller_perform_action_patch.rb +0 -24
  21. data/lib/rails2_ruby2/active_record_associations.rb +0 -65
  22. data/lib/rails2_ruby2/active_record_base.rb +0 -19
  23. data/lib/rails2_ruby2/convert_cookies_patch.rb +0 -8
  24. data/lib/rails2_ruby2/core_ext/string.rb +0 -10
  25. data/lib/rails2_ruby2/deserialize_ordered_hashes.rb +0 -3
  26. data/lib/rails2_ruby2/downcase_patch.rb +0 -77
  27. data/lib/rails2_ruby2/filter_parameters_patch.rb +0 -10
  28. data/lib/rails2_ruby2/kernel_helpers.rb +0 -22
  29. data/lib/rails2_ruby2/nokogirisax_patch.rb +0 -13
  30. data/lib/rails2_ruby2/rails_generator_patch.rb +0 -22
  31. data/lib/rails2_ruby2/rails_init.rb +0 -28
  32. data/lib/rails2_ruby2/slice_patch.rb +0 -16
  33. data/lib/rails2_ruby2/time_zone_patch.rb +0 -5
  34. data/lib/rails2_ruby2/tzinfo_patch.rb +0 -26
  35. data/rails/init.rb +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c3c368dccbcc961e88d7c3a0c8228dbcaec6681
4
- data.tar.gz: 1339d22c81559b10dcc22fe11a4c405d6c4bc329
3
+ metadata.gz: bad7ee6547237efb6663e3d1b146e46d11a34553
4
+ data.tar.gz: 1939138fca172997f1284e4342b7ad4cfd296ff8
5
5
  SHA512:
6
- metadata.gz: 6cd9d9db7990cbc1ef4c9cb41db78401995bbaa70de6989c8f81498398cfa452ae6701b954d10de6233ec20ea166a6f649cfe0fe52de48c02c56c9e5299911d9
7
- data.tar.gz: 2eacc32251651cc0d648716386ea1bf1ae0c678fe82073d7e96c3fb9395394f2851701ca5d4e64a0b106ba300d7fa90f51d7a59c28ddf796ccd22527f936f178
6
+ metadata.gz: a1aeb981b52bea82323013312fddfe4e6211ab02487b9ec6e13c0dc2ed594dca67843609562d9e60b6f858cae43ccef54d9e2da84651cd71dae71b9253824a19
7
+ data.tar.gz: dd417c265305d26c03ef84f543e569ef638b665a13e4fb5ac4effc32febb352ba1b89d4f04be099b8c73fda115c692570e554ed9dc6da9d850cbcd56ebb7e6b3
data/README.md CHANGED
@@ -22,7 +22,30 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ If you are using this gem in conjunction with the [Genius rails2 fork]('https://github.com/Genius/rails2') include the following line in your Gemfile:
26
+
27
+ ```ruby
28
+ gem "rails2_ruby2", "~>1.0"
29
+ ```
30
+
31
+ If you are not using the Genius rails2 fork but are instead using something like [rails 2.3 lts](https://github.com/makandra/rails/tree/2-3-lts) you will need to add `rails2_ruby2` to your Gemfile as specified above and manually include the patches by component, e.g.:
32
+
33
+ ```ruby
34
+ require "rails2_ruby2/action_mailer"
35
+
36
+ require "rails2_ruby2/action_pack"
37
+
38
+ require "rails2_ruby2/action_view"
39
+
40
+ require "rails2_ruby2/active_model"
41
+
42
+ require "rails2_ruby2/active_record"
43
+
44
+ require "rails2_ruby2/active_resource"
45
+
46
+ require "rails2_ruby2/active_support"
47
+ ```
48
+
26
49
 
27
50
  ## Development
28
51
 
data/lib/rails2_ruby2.rb CHANGED
@@ -1,9 +1,5 @@
1
1
  require "rails2_ruby2/version"
2
- require "rails2_ruby2/kernel_helpers"
3
2
 
4
- require 'yaml'
5
- require 'syck'
6
- require 'rails2_ruby2/deserialize_ordered_hashes'
7
3
  require 'rails2_ruby2/backport_ruby_config'
8
4
 
9
5
  module Rails2Ruby2
@@ -0,0 +1,3 @@
1
+ # Add extensions to action_mailer/ directory
2
+
3
+ # Shim for action_mailer extensions
@@ -0,0 +1,3 @@
1
+ Dir[File.dirname(__FILE__) + '/action_pack/**/*.rb'].each do |file|
2
+ require file.chomp('.rb')
3
+ end
@@ -0,0 +1,3 @@
1
+ # Add extensions to action_view/ directory
2
+
3
+ # Shim for action_view extensions
@@ -0,0 +1,3 @@
1
+ # Add extensions to active_model/ directory
2
+
3
+ # Shim for active_model extensions
@@ -0,0 +1,3 @@
1
+ Dir[File.dirname(__FILE__) + '/active_record/**/*.rb'].each do |file|
2
+ require file.chomp('.rb')
3
+ end
@@ -0,0 +1,37 @@
1
+ require 'active_record/connection_adapters/postgresql_adapter'
2
+
3
+ ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do
4
+ def schema_search_path
5
+ @schema_search_path ||= query('SHOW search_path')[0][0].split(',').map(&:strip).join(',')
6
+ end
7
+
8
+ # Resets the sequence of a table's primary key to the maximum value.
9
+ def reset_pk_sequence!(table, pk = nil, sequence = nil) #:nodoc:
10
+ unless pk and sequence
11
+ default_pk, default_sequence = pk_and_sequence_for(table)
12
+
13
+ pk ||= default_pk
14
+ sequence ||= default_sequence
15
+ end
16
+
17
+ if @logger && pk && !sequence
18
+ @logger.warn "#{table} has primary key #{pk} with no default sequence"
19
+ end
20
+
21
+ if pk && sequence
22
+ quoted_sequence = quote_table_name(sequence)
23
+ max_pk = select_value("SELECT MAX(#{quote_column_name pk}) FROM #{quote_table_name(table)}")
24
+ if max_pk.nil?
25
+ if postgresql_version >= 100000
26
+ minvalue = select_value("SELECT seqmin FROM pg_sequence WHERE seqrelid = #{quote(quoted_sequence)}::regclass")
27
+ else
28
+ minvalue = select_value("SELECT min_value FROM #{quoted_sequence}")
29
+ end
30
+ end
31
+
32
+ select_value <<-end_sql, 'SCHEMA'
33
+ SELECT setval(#{quote(quoted_sequence)}, #{max_pk ? max_pk : minvalue}, #{max_pk ? true : false})
34
+ end_sql
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,9 @@
1
+ require 'active_record/connection_adapters/abstract/schema_statements'
2
+
3
+ ActiveRecord::ConnectionAdapters::SchemaStatements.module_eval do
4
+ def dump_schema_information #:nodoc:
5
+ sm_table = "public.#{ActiveRecord::Migrator.schema_migrations_table_name}"
6
+ migrated = select_values("SELECT version FROM #{sm_table} ORDER BY version")
7
+ migrated.map { |v| "INSERT INTO #{sm_table} (version) VALUES ('#{v}');" }.join("\n\n")
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ # Add extensions to active_resource/ directory
2
+
3
+ # Shim for active_resource extensions
@@ -0,0 +1,3 @@
1
+ Dir[File.dirname(__FILE__) + '/active_support/**/*.rb'].each do |file|
2
+ require file.chomp('.rb')
3
+ end
@@ -1,3 +1,5 @@
1
+ # This patch will no longer be necessary at Rails 3.2. See commit message
2
+ # for more information.
1
3
  I18n::Backend::Base.class_eval do
2
4
  def load_file(filename)
3
5
  type = File.extname(filename).tr('.', '').downcase
@@ -1,3 +1,3 @@
1
1
  module Rails2Ruby2
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
data/rails2_ruby2.gemspec CHANGED
@@ -20,9 +20,8 @@ Gem::Specification.new do |spec|
20
20
  spec.add_development_dependency "bundler", "~> 1.8"
21
21
  spec.add_development_dependency "rake", "~> 10.0"
22
22
 
23
- spec.add_dependency "syck", "~> 1.0.5"
23
+ spec.add_dependency "syck", "~> 1.4"
24
24
  spec.add_dependency 'iconv'
25
- spec.add_dependency 'test-unit', '1.2.3'
26
25
 
27
26
  spec.required_ruby_version = '~> 2.0'
28
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails2_ruby2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Warner
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-08-20 00:00:00.000000000 Z
12
+ date: 2019-03-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 1.0.5
48
+ version: '1.4'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: 1.0.5
55
+ version: '1.4'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: iconv
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -67,20 +67,6 @@ dependencies:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
- - !ruby/object:Gem::Dependency
71
- name: test-unit
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - '='
75
- - !ruby/object:Gem::Version
76
- version: 1.2.3
77
- type: :runtime
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - '='
82
- - !ruby/object:Gem::Version
83
- version: 1.2.3
84
70
  description: Patches to run rails 2 with ruby 2
85
71
  email:
86
72
  - andrew@genius.com
@@ -100,28 +86,21 @@ files:
100
86
  - bin/console
101
87
  - bin/setup
102
88
  - lib/rails2_ruby2.rb
103
- - lib/rails2_ruby2/action_controller_perform_action_patch.rb
104
- - lib/rails2_ruby2/active_record_associations.rb
105
- - lib/rails2_ruby2/active_record_base.rb
89
+ - lib/rails2_ruby2/action_mailer.rb
90
+ - lib/rails2_ruby2/action_pack.rb
91
+ - lib/rails2_ruby2/action_pack/named_route_collection_patch.rb
92
+ - lib/rails2_ruby2/action_view.rb
93
+ - lib/rails2_ruby2/active_model.rb
94
+ - lib/rails2_ruby2/active_record.rb
95
+ - lib/rails2_ruby2/active_record/postgresql_adapter.rb
96
+ - lib/rails2_ruby2/active_record/schema_statements.rb
97
+ - lib/rails2_ruby2/active_resource.rb
98
+ - lib/rails2_ruby2/active_support.rb
99
+ - lib/rails2_ruby2/active_support/compressed_memcached_store_patch.rb
100
+ - lib/rails2_ruby2/active_support/erb_util_silence.rb
101
+ - lib/rails2_ruby2/active_support/i18n_patch.rb
106
102
  - lib/rails2_ruby2/backport_ruby_config.rb
107
- - lib/rails2_ruby2/compressed_memcached_store_patch.rb
108
- - lib/rails2_ruby2/convert_cookies_patch.rb
109
- - lib/rails2_ruby2/core_ext/string.rb
110
- - lib/rails2_ruby2/deserialize_ordered_hashes.rb
111
- - lib/rails2_ruby2/downcase_patch.rb
112
- - lib/rails2_ruby2/erb_util_silence.rb
113
- - lib/rails2_ruby2/filter_parameters_patch.rb
114
- - lib/rails2_ruby2/i18n_patch.rb
115
- - lib/rails2_ruby2/kernel_helpers.rb
116
- - lib/rails2_ruby2/named_route_collection_patch.rb
117
- - lib/rails2_ruby2/nokogirisax_patch.rb
118
- - lib/rails2_ruby2/rails_generator_patch.rb
119
- - lib/rails2_ruby2/rails_init.rb
120
- - lib/rails2_ruby2/slice_patch.rb
121
- - lib/rails2_ruby2/time_zone_patch.rb
122
- - lib/rails2_ruby2/tzinfo_patch.rb
123
103
  - lib/rails2_ruby2/version.rb
124
- - rails/init.rb
125
104
  - rails2_ruby2.gemspec
126
105
  - tags
127
106
  homepage: https://github.com/Genius/rails2_ruby2
@@ -144,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
123
  version: '0'
145
124
  requirements: []
146
125
  rubyforge_project:
147
- rubygems_version: 2.2.2
126
+ rubygems_version: 2.5.2.3
148
127
  signing_key:
149
128
  specification_version: 4
150
129
  summary: Patches to run rails 2 with ruby 2
@@ -1,24 +0,0 @@
1
- ActionController::Base.class_eval do
2
- private
3
-
4
- def perform_action_without_filters
5
- if action_methods.include?(action_name)
6
- send(action_name)
7
- default_render unless performed?
8
- elsif respond_to?(:method_missing) || protected_methods.include?(:method_missing)
9
- method_missing action_name
10
- default_render unless performed?
11
- else
12
- begin
13
- default_render
14
- rescue ActionView::MissingTemplate => e
15
- # Was the implicit template missing, or was it another template?
16
- if e.path == default_template_name
17
- raise ActionController::UnknownAction, "No action responded to #{action_name}. Actions: #{action_methods.sort.to_sentence(:locale => :en)}", caller
18
- else
19
- raise e
20
- end
21
- end
22
- end
23
- end
24
- end
@@ -1,65 +0,0 @@
1
- module ActiveRecord
2
- module Associations
3
- class AssociationProxy
4
- def proxy_respond_to?(method, include_all = false)
5
- Object.instance_method(:respond_to?).bind(self).call(method, include_all) ||
6
- (!include_all && Object.instance_method(:protected_methods).bind(self).call.include?(method))
7
- end
8
-
9
- private
10
-
11
- # Forwards any missing method call to the \target.
12
- def method_missing(method, *args, &block)
13
- if load_target
14
- if @target.respond_to?(method) || @target.protected_methods.include?(method)
15
- @target.send(method, *args, &block)
16
- else
17
- super
18
- end
19
- end
20
- end
21
- end
22
-
23
- class AssociationCollection < AssociationProxy
24
- def proxy_respond_to?(method, include_all = false)
25
- super ||
26
- @reflection.klass.respond_to?(method, include_all) ||
27
- (!include_all && @reflection.klass.protected_methods.include?(method))
28
- end
29
- end
30
- end
31
- end
32
-
33
-
34
- module ActiveRecord::AutosaveAssociation
35
- private
36
-
37
- def save_collection_association(reflection)
38
- if association = association_instance_get(reflection.name)
39
- autosave = reflection.options[:autosave]
40
-
41
- if records = associated_records_to_validate_or_save(association, @new_record_before_save, autosave)
42
- records.each do |record|
43
- next if record.destroyed?
44
-
45
- if autosave && record.marked_for_destruction?
46
- association.destroy(record)
47
- elsif autosave != false && (@new_record_before_save || record.new_record?)
48
- if autosave
49
- saved = association.send(:insert_record, record, false, false)
50
- else
51
- association.send(:insert_record, record)
52
- end
53
- elsif autosave
54
- saved = record.save(false)
55
- end
56
-
57
- raise ActiveRecord::Rollback if saved == false
58
- end
59
- end
60
-
61
- # reconstruct the SQL queries now that we know the owner's id
62
- association.send(:construct_sql) if association.respond_to?(:construct_sql, true)
63
- end
64
- end
65
- end
@@ -1,19 +0,0 @@
1
- class ActiveRecord::Base
2
- private
3
- # Assigns attributes, dealing nicely with both multi and single paramater attributes
4
- # Assumes attributes is a hash
5
-
6
- def assign_attributes(attributes={})
7
- multiparameter_attributes = []
8
-
9
- attributes.each do |k, v|
10
- if k.to_s.include?("(")
11
- multiparameter_attributes << [ k, v ]
12
- else
13
- respond_to?(:"#{k}=") || protected_methods.include?(:"#{k}=") ? send(:"#{k}=", v) : raise(ActiveRecord::UnknownAttributeError, "unknown attribute: #{k}")
14
- end
15
- end
16
-
17
- assign_multiparameter_attributes(multiparameter_attributes) unless multiparameter_attributes.empty?
18
- end
19
- end
@@ -1,8 +0,0 @@
1
- ActionController::Response.prepend(Module.new do
2
- private
3
-
4
- def convert_cookies!
5
- cookies = headers['Set-Cookie'].to_s.lines.to_a.compact
6
- headers['Set-Cookie'] = cookies unless cookies.empty?
7
- end
8
- end)
@@ -1,10 +0,0 @@
1
- String.prepend(Module.new do
2
- %i(start_with? starts_with? end_with? ends_with?).each do |method|
3
- module_eval <<-CODE, __FILE__, __LINE__ + 1
4
- def #{method}(*args)
5
- a = args.select { |a| a.respond_to?(:to_str) }
6
- a.empty? ? false : super(*a)
7
- end
8
- CODE
9
- end
10
- end)
@@ -1,3 +0,0 @@
1
- YAML.add_builtin_type("omap") do |type, val|
2
- ActiveSupport::OrderedHash[val.map(&:to_a).map(&:first)]
3
- end
@@ -1,77 +0,0 @@
1
- if defined?(ActiveRecord::Validations::ClassMethods)
2
- class String
3
- def _mb_chars_downcase
4
- mb = self.mb_chars
5
- return mb.downcase if mb === ActiveSupport::Multibyte::Chars
6
-
7
- if encoding == Encoding::UTF_8
8
- ActiveSupport::Multibyte::Chars.new(self).downcase
9
- else
10
- self.downcase
11
- end
12
- end
13
- end
14
-
15
- module ActiveRecord::Validations::ClassMethods
16
- def validates_uniqueness_of(*attr_names)
17
- configuration = { :case_sensitive => true }
18
- configuration.update(attr_names.extract_options!)
19
-
20
- validates_each(attr_names,configuration) do |record, attr_name, value|
21
- # The check for an existing value should be run from a class that
22
- # isn't abstract. This means working down from the current class
23
- # (self), to the first non-abstract class. Since classes don't know
24
- # their subclasses, we have to build the hierarchy between self and
25
- # the record's class.
26
- class_hierarchy = [record.class]
27
- while class_hierarchy.first != self
28
- class_hierarchy.insert(0, class_hierarchy.first.superclass)
29
- end
30
-
31
- # Now we can work our way down the tree to the first non-abstract
32
- # class (which has a database table to query from).
33
- finder_class = class_hierarchy.detect { |klass| !klass.abstract_class? }
34
-
35
- column = finder_class.columns_hash[attr_name.to_s]
36
-
37
- if value.nil?
38
- comparison_operator = "IS ?"
39
- elsif column.text?
40
- comparison_operator = "#{connection.case_sensitive_equality_operator} ?"
41
- value = column.limit ? value.to_s.mb_chars[0, column.limit] : value.to_s
42
- else
43
- comparison_operator = "= ?"
44
- end
45
-
46
- sql_attribute = "#{record.class.quoted_table_name}.#{connection.quote_column_name(attr_name)}"
47
-
48
- if value.nil? || (configuration[:case_sensitive] || !column.text?)
49
- condition_sql = "#{sql_attribute} #{comparison_operator}"
50
- condition_params = [value]
51
- else
52
- condition_sql = "LOWER(#{sql_attribute}) #{comparison_operator}"
53
- condition_params = [value._mb_chars_downcase]
54
- end
55
-
56
- if scope = configuration[:scope]
57
- Array(scope).map do |scope_item|
58
- scope_value = record.send(scope_item)
59
- condition_sql << " AND " << attribute_condition("#{record.class.quoted_table_name}.#{connection.quote_column_name(scope_item)}", scope_value)
60
- condition_params << scope_value
61
- end
62
- end
63
-
64
- unless record.new_record?
65
- condition_sql << " AND #{record.class.quoted_table_name}.#{record.class.primary_key} <> ?"
66
- condition_params << record.send(:id)
67
- end
68
-
69
- finder_class.with_exclusive_scope do
70
- if finder_class.exists?([condition_sql, *condition_params])
71
- record.errors.add(attr_name, :taken, :default => configuration[:message], :value => value)
72
- end
73
- end
74
- end
75
- end
76
- end
77
- end
@@ -1,10 +0,0 @@
1
- ActionController::Base.prepend(Module.new do
2
- private
3
-
4
- def log_processing_for_parameters
5
- parameters = respond_to?(:filter_parameters, true) ? filter_parameters(params) : params.dup
6
- parameters = parameters.except!(:controller, :action, :format, :_method)
7
-
8
- logger.info " Parameters: #{parameters.inspect}" unless parameters.empty?
9
- end
10
- end)
@@ -1,22 +0,0 @@
1
- def when_library_loaded(lib_string, options = {})
2
- version_file = options.fetch(:version_file, nil)
3
- lib_const_string = options.fetch(:lib_const_string, lib_string)
4
-
5
- begin
6
- Object.const_get(lib_string)
7
- rescue NameError
8
- return
9
- end
10
-
11
- if version_file
12
- begin
13
- require(version_file)
14
- rescue MissingSourceFile
15
- return
16
- end
17
- end
18
-
19
- if Object.const_get(lib_const_string).const_get('VERSION').const_get('MAJOR') == 2
20
- yield
21
- end
22
- end
@@ -1,13 +0,0 @@
1
- ActiveSupport::XmlMini.singleton_class.prepend(Module.new do
2
- def backend=(name)
3
- super(name).tap do
4
- if !name.is_a?(Module) && name.to_s.downcase == 'nokogirisax'
5
- ActiveSupport::XmlMini_NokogiriSAX::HashBuilder.prepend(Module.new do
6
- def start_element(name, attrs = [])
7
- super(name, attrs.flatten)
8
- end
9
- end)
10
- end
11
- end
12
- end
13
- end)
@@ -1,22 +0,0 @@
1
- require 'rails_generator'
2
- require 'rails_generator/scripts/generate'
3
-
4
- Rails::Generator::Commands::Create.class_eval do
5
- def template(relative_source, relative_destination, template_options = {})
6
- file(relative_source, relative_destination, template_options) do |file|
7
- # Evaluate any assignments in a temporary, throwaway binding
8
- vars = template_options[:assigns] || {}
9
- b = template_options[:binding] || binding
10
- # this no longer works, eval throws "undefined local variable or method `vars'"
11
- # vars.each { |k, v| eval "#{k} = vars[:#{k}] || vars['#{k}']", b }
12
- vars.each { |k, v| b.local_variable_set(:"#{k}", v) }
13
-
14
- # Render the source file with the temporary binding
15
- ERB.new(file.read, nil, '-').result(b)
16
- end
17
- end
18
- end
19
-
20
- Rails::Generator::NamedBase.class_eval do
21
- public :attributes
22
- end
@@ -1,28 +0,0 @@
1
- when_library_loaded('Rails') do
2
- require 'rails2_ruby2/rails_generator_patch'
3
- end
4
-
5
- when_library_loaded('ActiveRecord', :version_file => 'active_record/version') do
6
- require 'rails2_ruby2/active_record_associations'
7
- require 'rails2_ruby2/active_record_base'
8
- require 'rails2_ruby2/downcase_patch'
9
- end
10
-
11
- when_library_loaded('ActiveSupport', :version_file => 'active_support/version') do
12
- require 'rails2_ruby2/i18n_patch'
13
- require 'rails2_ruby2/slice_patch'
14
- require 'rails2_ruby2/tzinfo_patch'
15
- require 'rails2_ruby2/time_zone_patch'
16
- require 'rails2_ruby2/compressed_memcached_store_patch'
17
- require 'rails2_ruby2/nokogirisax_patch'
18
- require 'rails2_ruby2/core_ext/string'
19
- require 'rails2_ruby2/erb_util_silence'
20
- end
21
-
22
- when_library_loaded('ActionController',
23
- :lib_const_string => 'ActionPack', :version_file => 'action_pack/version') do
24
- require 'rails2_ruby2/named_route_collection_patch'
25
- require 'rails2_ruby2/convert_cookies_patch'
26
- require 'rails2_ruby2/filter_parameters_patch'
27
- require 'rails2_ruby2/action_controller_perform_action_patch'
28
- end
@@ -1,16 +0,0 @@
1
- ActiveSupport::CoreExtensions::Hash::Slice.class_eval do
2
- def slice(*keys)
3
- keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true)
4
- hash = self.class.new
5
- keys.each { |k| hash[k] = self[k] if has_key?(k) }
6
- hash
7
- end
8
-
9
- def slice!(*keys)
10
- keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true)
11
- omit = slice(*self.keys - keys)
12
- hash = slice(*keys)
13
- replace(hash)
14
- omit
15
- end
16
- end
@@ -1,5 +0,0 @@
1
- ActiveSupport::TimeZone.prepend(Module.new do
2
- def parse(str, now=self.now)
3
- super(str, now)
4
- end
5
- end)
@@ -1,26 +0,0 @@
1
- # from https://gist.github.com/cypriss/1976864
2
-
3
- require 'tzinfo'
4
-
5
- TZInfo::RubyCoreSupport.class_eval do
6
- HALF_DAYS_IN_DAY = rational_new!(1, 2)
7
-
8
- def self.datetime_new!(ajd = 0, of = 0, sg = Date::ITALY)
9
- # Convert from an Astronomical Julian Day number to a civil Julian Day number.
10
- jd = ajd + of + HALF_DAYS_IN_DAY
11
-
12
- # Ruby trunk revision 31862 changed the behaviour of DateTime.jd so that it will no
13
- # longer accept a fractional civil Julian Day number if further arguments are specified.
14
- # Calculate the hours, minutes and seconds to pass to jd.
15
-
16
- jd_i = jd.to_i
17
- jd_i -= 1 if jd < 0
18
- hours = (jd - jd_i) * 24
19
- hours_i = hours.to_i
20
- minutes = (hours - hours_i) * 60
21
- minutes_i = minutes.to_i
22
- seconds = (minutes - minutes_i) * 60
23
-
24
- DateTime.jd(jd_i, hours_i, minutes_i, seconds, of, sg)
25
- end
26
- end
data/rails/init.rb DELETED
@@ -1 +0,0 @@
1
- require File.expand_path('../../lib/rails2_ruby2/rails_init', __FILE__)