rails_backward 0.0.2

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.
@@ -0,0 +1,31 @@
1
+ *.rbc
2
+ capybara-*.html
3
+ .rspec
4
+ /log
5
+ /tmp
6
+ /db/*.sqlite3
7
+ /public/system
8
+ /coverage/
9
+ /spec/tmp
10
+ **.orig
11
+ rerun.txt
12
+ pickle-email-*.html
13
+
14
+ # TODO Comment out these rules if you are OK with secrets being uploaded to the repo
15
+ config/initializers/secret_token.rb
16
+ config/secrets.yml
17
+
18
+ ## Environment normalisation:
19
+ /.bundle
20
+ /vendor/bundle
21
+
22
+ # these should all be checked in to normalise the environment:
23
+ # Gemfile.lock, .ruby-version, .ruby-gemset
24
+
25
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
26
+ .rvmrc
27
+
28
+ # if using bower-rails ignore default bower_components path bower.json files
29
+ /vendor/assets/bower_components
30
+ *.bowerrc
31
+ bower.json
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Hayden Wei
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 all
13
+ 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 THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,45 @@
1
+ # Rails_backward
2
+
3
+ Didn't you realize that some useful and awesome features are provided by Rails 4 but your applications are using Rails 3.x ?
4
+ What should you do if you want to use these features? Yes, as you see, **rails_backward** is here for you. It provides backward
5
+ compatibility for some features in higher versions of Rails to lower versions of Rails, and it is really keeping growing.
6
+
7
+ # Supported Features
8
+
9
+ * ActiveRecord::Base.none
10
+ *
11
+
12
+ # Requirements
13
+
14
+ * Ruby >= 1.9.3
15
+ * Rails >= 3.2.x
16
+
17
+ # Installation
18
+
19
+ Put the following line to your Gemfile:
20
+
21
+ ```ruby
22
+ gem 'rails_backward', '~> 0.0.1'
23
+ ```
24
+
25
+ then,
26
+
27
+ ```ruby
28
+ bundle install
29
+ ```
30
+
31
+ # Contributing
32
+
33
+ Bug report or pull request are welcome.
34
+
35
+ 1. Fork it
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 new Pull Request
40
+
41
+ Please write unit test for your code if necessary.
42
+
43
+ # License
44
+
45
+ See LICENSE file.
Binary file
@@ -0,0 +1,2 @@
1
+ require 'rails_backward/null_relation'
2
+ require 'rails_backward/relation'
@@ -0,0 +1,64 @@
1
+ module ActiveRecord
2
+ module NullRelation # :nodoc:
3
+ def exec_queries
4
+ @records = []
5
+ end
6
+ def pluck(*column_names)
7
+ []
8
+ end
9
+ def delete_all(_conditions = nil)
10
+ 0
11
+ end
12
+ def update_all(_updates, _conditions = nil, _options = {})
13
+ 0
14
+ end
15
+ def delete(_id_or_array)
16
+ 0
17
+ end
18
+ def size
19
+ calculate :size, nil
20
+ end
21
+ def empty?
22
+ true
23
+ end
24
+ def any?
25
+ false
26
+ end
27
+ def many?
28
+ false
29
+ end
30
+ def to_sql
31
+ ""
32
+ end
33
+ def count(*)
34
+ calculate :count, nil
35
+ end
36
+ def sum(*)
37
+ calculate :sum, nil
38
+ end
39
+ def average(*)
40
+ calculate :average, nil
41
+ end
42
+ def minimum(*)
43
+ calculate :minimum, nil
44
+ end
45
+ def maximum(*)
46
+ calculate :maximum, nil
47
+ end
48
+ def calculate(operation, _column_name, _options = {})
49
+ # TODO: Remove _options argument as soon we remove support to
50
+ # activerecord-deprecated_finders.
51
+ if [:count, :sum, :size].include? operation
52
+ group_values.any? ? Hash.new : 0
53
+ elsif [:average, :minimum, :maximum].include?(operation) && group_values.any?
54
+ Hash.new
55
+ else
56
+ nil
57
+ end
58
+ end
59
+
60
+ def exists?(_id = false)
61
+ false
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,33 @@
1
+ module ActiveRecord
2
+ module QueryMethods
3
+ extend ActiveSupport::Concern
4
+
5
+ def extending!(*modules, &block)
6
+
7
+ modules << Module.new(&block) if block
8
+ modules.flatten!
9
+ self.extending_values += modules
10
+ extend(*extending_values) if extending_values.any?
11
+ self
12
+ end
13
+
14
+ def none
15
+ where("1=0").extending(ActiveRecord::NullRelation)
16
+ end
17
+
18
+ end
19
+ end
20
+
21
+ module RailsBackward
22
+ module QueryMethods
23
+ extend ActiveSupport::Concern
24
+
25
+ included do
26
+ class << self
27
+ delegate :none, to: :scoped
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ ActiveRecord::Base.send(:include, RailsBackward::QueryMethods)
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ path = File.expand_path("../lib", __FILE__)
3
+ $:.unshift(path) unless $:.include? path
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "rails_backward"
7
+ s.version = '0.0.2'
8
+ s.authors = ["Hayden Wei"]
9
+ s.email = ["haidongrun@gamil.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Provides some features of Rails 4 into Rails 3.x}
12
+ s.description = %q{Provides some features of Rails 4 into Rails 3.x}
13
+ s.files = `git ls-files`.split("\n")
14
+ s.license = 'MIT'
15
+ s.homepage = 'https://github.com/Gnodiah/rails_backward'
16
+
17
+ # specify any dependencies here; for example:
18
+ # s.add_development_dependency "rspec"
19
+ # s.add_runtime_dependency "rest-client"
20
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_backward
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
11
+ platform: ruby
12
+ authors:
13
+ - Hayden Wei
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2015-03-24 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: Provides some features of Rails 4 into Rails 3.x
22
+ email:
23
+ - haidongrun@gamil.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - .gitignore
32
+ - LICENSE
33
+ - README.md
34
+ - lib/.rails_patch.rb.swp
35
+ - lib/rails_backward.rb
36
+ - lib/rails_backward/.null_relation.rb.swp
37
+ - lib/rails_backward/.relation.rb.swp
38
+ - lib/rails_backward/null_relation.rb
39
+ - lib/rails_backward/relation.rb
40
+ - rails_backward.gemspec
41
+ homepage: https://github.com/Gnodiah/rails_backward
42
+ licenses:
43
+ - MIT
44
+ post_install_message:
45
+ rdoc_options: []
46
+
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ hash: 3
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ requirements: []
68
+
69
+ rubyforge_project:
70
+ rubygems_version: 1.8.25
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: Provides some features of Rails 4 into Rails 3.x
74
+ test_files: []
75
+