rails2_ruby2 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/rails2_ruby2.rb +10 -0
- data/lib/rails2_ruby2/action_controller_perform_action_patch.rb +24 -0
- data/lib/rails2_ruby2/active_record_associations.rb +65 -0
- data/lib/rails2_ruby2/active_record_base.rb +19 -0
- data/lib/rails2_ruby2/backport_ruby_config.rb +1 -0
- data/lib/rails2_ruby2/compressed_memcached_store_patch.rb +6 -0
- data/lib/rails2_ruby2/convert_cookies_patch.rb +8 -0
- data/lib/rails2_ruby2/core_ext/string.rb +10 -0
- data/lib/rails2_ruby2/deserialize_ordered_hashes.rb +3 -0
- data/lib/rails2_ruby2/downcase_patch.rb +77 -0
- data/lib/rails2_ruby2/erb_util_silence.rb +21 -0
- data/lib/rails2_ruby2/filter_parameters_patch.rb +10 -0
- data/lib/rails2_ruby2/i18n_patch.rb +9 -0
- data/lib/rails2_ruby2/kernel_helpers.rb +22 -0
- data/lib/rails2_ruby2/named_route_collection_patch.rb +17 -0
- data/lib/rails2_ruby2/nokogirisax_patch.rb +13 -0
- data/lib/rails2_ruby2/rails_generator_patch.rb +22 -0
- data/lib/rails2_ruby2/rails_init.rb +28 -0
- data/lib/rails2_ruby2/slice_patch.rb +16 -0
- data/lib/rails2_ruby2/time_zone_patch.rb +5 -0
- data/lib/rails2_ruby2/tzinfo_patch.rb +26 -0
- data/lib/rails2_ruby2/version.rb +3 -0
- data/rails/init.rb +1 -0
- data/rails2_ruby2.gemspec +28 -0
- data/tags +8 -0
- metadata +151 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9c3c368dccbcc961e88d7c3a0c8228dbcaec6681
|
4
|
+
data.tar.gz: 1339d22c81559b10dcc22fe11a4c405d6c4bc329
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6cd9d9db7990cbc1ef4c9cb41db78401995bbaa70de6989c8f81498398cfa452ae6701b954d10de6233ec20ea166a6f649cfe0fe52de48c02c56c9e5299911d9
|
7
|
+
data.tar.gz: 2eacc32251651cc0d648716386ea1bf1ae0c678fe82073d7e96c3fb9395394f2851701ca5d4e64a0b106ba300d7fa90f51d7a59c28ddf796ccd22527f936f178
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Andrew Warner
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Rails2Ruby2
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rails2_ruby2`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'rails2_ruby2'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install rails2_ruby2
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/[my-github-username]/rails2_ruby2/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rails2_ruby2"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/rails2_ruby2.rb
ADDED
@@ -0,0 +1,24 @@
|
|
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
|
@@ -0,0 +1,65 @@
|
|
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
|
@@ -0,0 +1,19 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
1
|
+
Config = RbConfig
|
@@ -0,0 +1,6 @@
|
|
1
|
+
ActiveSupport::Cache::CompressedMemCacheStore.module_eval do
|
2
|
+
def write(name, value, options = nil)
|
3
|
+
value = ActiveSupport::Gzip.compress(Marshal.dump(value)).force_encoding('ascii') unless raw?(options)
|
4
|
+
super(name, value, (options || {}).merge(:raw => true))
|
5
|
+
end
|
6
|
+
end
|
@@ -0,0 +1,10 @@
|
|
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)
|
@@ -0,0 +1,77 @@
|
|
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
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# from https://gist.github.com/grosser/599b47bea7f3c5a044cb
|
2
|
+
# fixed in rails 3 by https://github.com/rails/rails/commit/4f12e3a3a5d28b63a74344cc8997b8466d276277
|
3
|
+
# see https://github.com/rails/rails/issues/7430
|
4
|
+
|
5
|
+
class ERB
|
6
|
+
module Util
|
7
|
+
def html_escape(s)
|
8
|
+
s = s.to_s
|
9
|
+
if s.html_safe?
|
10
|
+
s
|
11
|
+
else
|
12
|
+
s.gsub(/[&"'><]/, HTML_ESCAPE).html_safe
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
alias h html_escape
|
17
|
+
|
18
|
+
singleton_class.send(:remove_method, :html_escape)
|
19
|
+
module_function :html_escape, :h
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,10 @@
|
|
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)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
I18n::Backend::Base.class_eval do
|
2
|
+
def load_file(filename)
|
3
|
+
type = File.extname(filename).tr('.', '').downcase
|
4
|
+
# As a fix added second argument as true to respond_to? method
|
5
|
+
raise UnknownFileType.new(type, filename) unless respond_to?(:"load_#{type}", true)
|
6
|
+
data = send(:"load_#{type}", filename) # TODO raise a meaningful exception if this does not yield a Hash
|
7
|
+
data.each { |locale, d| store_translations(locale, d) }
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,22 @@
|
|
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
|
@@ -0,0 +1,17 @@
|
|
1
|
+
ActionController::Routing::RouteSet::NamedRouteCollection.prepend(Module.new do
|
2
|
+
private
|
3
|
+
|
4
|
+
def define_hash_access(route, name, kind, options)
|
5
|
+
super(route, name, kind, options).tap do
|
6
|
+
selector = hash_access_name(name, kind)
|
7
|
+
named_helper_module_eval "public :#{selector}"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def define_url_helper(route, name, kind, options)
|
12
|
+
super(route, name, kind, options).tap do
|
13
|
+
selector = url_helper_name(name, kind)
|
14
|
+
named_helper_module_eval "public :#{selector}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end)
|
@@ -0,0 +1,13 @@
|
|
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)
|
@@ -0,0 +1,22 @@
|
|
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
|
@@ -0,0 +1,28 @@
|
|
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
|
@@ -0,0 +1,16 @@
|
|
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
|
@@ -0,0 +1,26 @@
|
|
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
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path('../../lib/rails2_ruby2/rails_init', __FILE__)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rails2_ruby2/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rails2_ruby2"
|
8
|
+
spec.version = Rails2Ruby2::VERSION
|
9
|
+
spec.authors = ["Andrew Warner", "Mat Brown"]
|
10
|
+
spec.email = ["andrew@genius.com", "mat@genius.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Patches to run rails 2 with ruby 2}
|
13
|
+
spec.description = %q{Patches to run rails 2 with ruby 2}
|
14
|
+
spec.homepage = "https://github.com/Genius/rails2_ruby2"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
|
23
|
+
spec.add_dependency "syck", "~> 1.0.5"
|
24
|
+
spec.add_dependency 'iconv'
|
25
|
+
spec.add_dependency 'test-unit', '1.2.3'
|
26
|
+
|
27
|
+
spec.required_ruby_version = '~> 2.0'
|
28
|
+
end
|
data/tags
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
|
2
|
+
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
|
3
|
+
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
|
4
|
+
!_TAG_PROGRAM_NAME Exuberant Ctags //
|
5
|
+
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
|
6
|
+
!_TAG_PROGRAM_VERSION 5.8 //
|
7
|
+
Rails2Ruby2 lib/rails2_ruby2.rb /^module Rails2Ruby2$/;" m
|
8
|
+
Rails2Ruby2 lib/rails2_ruby2/version.rb /^module Rails2Ruby2$/;" m
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails2_ruby2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Warner
|
8
|
+
- Mat Brown
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-08-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.8'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.8'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '10.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '10.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: syck
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.0.5
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.0.5
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: iconv
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
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
|
+
description: Patches to run rails 2 with ruby 2
|
85
|
+
email:
|
86
|
+
- andrew@genius.com
|
87
|
+
- mat@genius.com
|
88
|
+
executables: []
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- ".gitignore"
|
93
|
+
- ".rspec"
|
94
|
+
- ".travis.yml"
|
95
|
+
- CODE_OF_CONDUCT.md
|
96
|
+
- Gemfile
|
97
|
+
- LICENSE.txt
|
98
|
+
- README.md
|
99
|
+
- Rakefile
|
100
|
+
- bin/console
|
101
|
+
- bin/setup
|
102
|
+
- 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
|
106
|
+
- 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
|
+
- lib/rails2_ruby2/version.rb
|
124
|
+
- rails/init.rb
|
125
|
+
- rails2_ruby2.gemspec
|
126
|
+
- tags
|
127
|
+
homepage: https://github.com/Genius/rails2_ruby2
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
metadata: {}
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '2.0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.2.2
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: Patches to run rails 2 with ruby 2
|
151
|
+
test_files: []
|