eel 0.0.1
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/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +3 -0
- data/Rakefile +1 -0
- data/eel.gemspec +21 -0
- data/lib/eel.rb +9 -0
- data/lib/eel/active_record.rb +1 -0
- data/lib/eel/active_record/query_extensions.rb +36 -0
- data/lib/eel/core_ext/symbol.rb +32 -0
- data/lib/eel/version.rb +3 -0
- metadata +88 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Ivan Efremov
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/eel.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'eel/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = 'eel'
|
8
|
+
gem.version = Eel::VERSION
|
9
|
+
gem.authors = ['Ivan Efremov']
|
10
|
+
gem.email = ['st8998@gmail.com']
|
11
|
+
gem.description = %q{It is more like Squeel but without Squ}
|
12
|
+
gem.summary = %q{It is more like Squeel but without Squ}
|
13
|
+
gem.homepage = 'https://github.com/StrangeMood/eel'
|
14
|
+
|
15
|
+
gem.add_dependency 'activerecord', '~> 3.2'
|
16
|
+
gem.add_dependency 'activesupport', '~> 3.2'
|
17
|
+
|
18
|
+
gem.files = `git ls-files`.split($/)
|
19
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
|
+
gem.require_paths = ['lib']
|
21
|
+
end
|
data/lib/eel.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ActiveRecord::Relation.send :include, Eel::ActiveRecord::QueryExtensions
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Eel
|
2
|
+
module ActiveRecord
|
3
|
+
module QueryExtensions
|
4
|
+
|
5
|
+
def order *args
|
6
|
+
return self if args.blank?
|
7
|
+
|
8
|
+
super *args.flatten.map { |a| assign_context(a) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def build_where(opts, other = [])
|
12
|
+
case opts
|
13
|
+
when Arel::Nodes::Node
|
14
|
+
nodes = [opts] + other
|
15
|
+
nodes.each do |node|
|
16
|
+
assign_context(node.left)
|
17
|
+
assign_context(node.right)
|
18
|
+
end
|
19
|
+
nodes
|
20
|
+
else
|
21
|
+
super
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def assign_context attr
|
28
|
+
if attr.is_a?(Arel::Attributes::Attribute) && attr.relation.blank?
|
29
|
+
attr.relation = table
|
30
|
+
end
|
31
|
+
attr
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class Symbol
|
2
|
+
|
3
|
+
delegate :gt, :gteq, :lt, :lteq,
|
4
|
+
:eq, :in,
|
5
|
+
:desc, :asc,
|
6
|
+
to: :attr
|
7
|
+
|
8
|
+
def attr
|
9
|
+
attr = Arel::Attributes::Attribute.new
|
10
|
+
attr.name = self
|
11
|
+
attr
|
12
|
+
end
|
13
|
+
|
14
|
+
def of val
|
15
|
+
relation = case val
|
16
|
+
when Class
|
17
|
+
val.arel_table
|
18
|
+
when Symbol
|
19
|
+
val.to_s.classify.constantize
|
20
|
+
when String
|
21
|
+
val.classify.constantize
|
22
|
+
else
|
23
|
+
raise "Can't use #{val.class} as a relation"
|
24
|
+
end
|
25
|
+
|
26
|
+
attr = Arel::Attributes::Attribute.new
|
27
|
+
attr.name = self
|
28
|
+
attr.relation = relation
|
29
|
+
attr
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/lib/eel/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ivan Efremov
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
type: :runtime
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '3.2'
|
21
|
+
none: false
|
22
|
+
requirement: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.2'
|
27
|
+
none: false
|
28
|
+
name: activerecord
|
29
|
+
prerelease: false
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ~>
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '3.2'
|
37
|
+
none: false
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '3.2'
|
43
|
+
none: false
|
44
|
+
name: activesupport
|
45
|
+
prerelease: false
|
46
|
+
description: It is more like Squeel but without Squ
|
47
|
+
email:
|
48
|
+
- st8998@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- eel.gemspec
|
59
|
+
- lib/eel.rb
|
60
|
+
- lib/eel/active_record.rb
|
61
|
+
- lib/eel/active_record/query_extensions.rb
|
62
|
+
- lib/eel/core_ext/symbol.rb
|
63
|
+
- lib/eel/version.rb
|
64
|
+
homepage: https://github.com/StrangeMood/eel
|
65
|
+
licenses: []
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
none: false
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
none: false
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 1.8.24
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: It is more like Squeel but without Squ
|
88
|
+
test_files: []
|