order_as_arbitrary 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.idea/.gitignore +3 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/inspectionProfiles/Project_Default.xml +6 -0
- data/.idea/misc.xml +10 -0
- data/.idea/modules.xml +8 -0
- data/.idea/order_as_arbitrary.iml +51 -0
- data/.idea/vcs.xml +6 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +109 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/order_as_arbitrary.rb +57 -0
- data/lib/order_as_arbitrary/error.rb +4 -0
- data/lib/order_as_arbitrary/version.rb +3 -0
- data/order_as_arbitrary.gemspec +30 -0
- metadata +150 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 58f567e3e3fc77088c9d08c62704e0b0f609c14d15e3c8e8a69d5081dff95c1e
|
4
|
+
data.tar.gz: af10212a942c2e557f584e5e27dabb966d2aa3f0fdfaaa3748c3014a3b748313
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0bcf23349b18fa7d331f40dad0479192b29acbd6bfa46a5c03696b1e47856fc1710daee7676d8f1b44507da9c1be25903ad21a4978e24568a17c99ccbf1822ae
|
7
|
+
data.tar.gz: 7dd224c52cb984a6b2b83cc208635a47f246eefec9c5f13f87da509e5003415ba9f157084517362c6150e67457746543ca62450cb031d3574368d962882bb9d7
|
data/.gitignore
ADDED
data/.idea/.gitignore
ADDED
data/.idea/.rakeTasks
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
+
You are allowed to:
|
4
|
+
1. Remove rake task
|
5
|
+
2. Add existing rake tasks
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build order_as_arbitrary-0.1.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install order_as_arbitrary-0.1.0.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install order_as_arbitrary-0.1.0.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v0.1.0 and build and push order_as_arbitrary-0.1.0.gem to TODO: Set to 'http://mygemserver.com'" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
|
data/.idea/misc.xml
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="JavaScriptSettings">
|
4
|
+
<option name="languageLevel" value="ES6" />
|
5
|
+
</component>
|
6
|
+
<component name="ProjectPlainTextFileTypeManager">
|
7
|
+
<file url="file://$PROJECT_DIR$/spec/mysql_spec.rb" />
|
8
|
+
</component>
|
9
|
+
<component name="ProjectRootManager" version="2" project-jdk-name="ruby-2.6.3-p62" project-jdk-type="RUBY_SDK" />
|
10
|
+
</project>
|
data/.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectModuleManager">
|
4
|
+
<modules>
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/order_as_arbitrary.iml" filepath="$PROJECT_DIR$/.idea/order_as_arbitrary.iml" />
|
6
|
+
</modules>
|
7
|
+
</component>
|
8
|
+
</project>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="ModuleRunConfigurationManager">
|
4
|
+
<shared />
|
5
|
+
</component>
|
6
|
+
<component name="NewModuleRootManager">
|
7
|
+
<content url="file://$MODULE_DIR$" />
|
8
|
+
<orderEntry type="jdk" jdkName="RVM: ruby-2.6.3" jdkType="RUBY_SDK" />
|
9
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
10
|
+
<orderEntry type="library" scope="PROVIDED" name="actionpack (v4.2.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
11
|
+
<orderEntry type="library" scope="PROVIDED" name="actionview (v4.2.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
12
|
+
<orderEntry type="library" scope="PROVIDED" name="activemodel (v4.2.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
13
|
+
<orderEntry type="library" scope="PROVIDED" name="activerecord (v4.2.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="activesupport (v4.2.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="arel (v6.0.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="builder (v3.2.3, RVM: ruby-2.6.3) [gem]" level="application" />
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.0.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="coderay (v1.1.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.5, RVM: ruby-2.6.3) [gem]" level="application" />
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="crass (v1.0.5, RVM: ruby-2.6.3) [gem]" level="application" />
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.3, RVM: ruby-2.6.3) [gem]" level="application" />
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="erubis (v2.7.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="gemspec (v0.3.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
24
|
+
<orderEntry type="library" scope="PROVIDED" name="i18n (v0.9.5, RVM: ruby-2.6.3) [gem]" level="application" />
|
25
|
+
<orderEntry type="library" scope="PROVIDED" name="json (v1.8.6, RVM: ruby-2.6.3) [gem]" level="application" />
|
26
|
+
<orderEntry type="library" scope="PROVIDED" name="loofah (v2.3.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
27
|
+
<orderEntry type="library" scope="PROVIDED" name="memoist (v0.12.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
28
|
+
<orderEntry type="library" scope="PROVIDED" name="method_source (v0.9.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
29
|
+
<orderEntry type="library" scope="PROVIDED" name="mini_portile2 (v2.4.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
30
|
+
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.13.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
31
|
+
<orderEntry type="library" scope="PROVIDED" name="mysql2 (v0.3.21, RVM: ruby-2.6.3) [gem]" level="application" />
|
32
|
+
<orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.10.5, RVM: ruby-2.6.3) [gem]" level="application" />
|
33
|
+
<orderEntry type="library" scope="PROVIDED" name="pry (v0.12.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
34
|
+
<orderEntry type="library" scope="PROVIDED" name="pry-rails (v0.3.9, RVM: ruby-2.6.3) [gem]" level="application" />
|
35
|
+
<orderEntry type="library" scope="PROVIDED" name="rack (v1.6.11, RVM: ruby-2.6.3) [gem]" level="application" />
|
36
|
+
<orderEntry type="library" scope="PROVIDED" name="rack-test (v0.6.3, RVM: ruby-2.6.3) [gem]" level="application" />
|
37
|
+
<orderEntry type="library" scope="PROVIDED" name="rails-deprecated_sanitizer (v1.0.3, RVM: ruby-2.6.3) [gem]" level="application" />
|
38
|
+
<orderEntry type="library" scope="PROVIDED" name="rails-dom-testing (v1.0.9, RVM: ruby-2.6.3) [gem]" level="application" />
|
39
|
+
<orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.3.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
40
|
+
<orderEntry type="library" scope="PROVIDED" name="railties (v4.2.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
41
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v10.5.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
42
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.9.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
43
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.9.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
44
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.9.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
45
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-rails (v3.9.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
46
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.9.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
47
|
+
<orderEntry type="library" scope="PROVIDED" name="thor (v0.20.3, RVM: ruby-2.6.3) [gem]" level="application" />
|
48
|
+
<orderEntry type="library" scope="PROVIDED" name="thread_safe (v0.3.6, RVM: ruby-2.6.3) [gem]" level="application" />
|
49
|
+
<orderEntry type="library" scope="PROVIDED" name="tzinfo (v1.2.5, RVM: ruby-2.6.3) [gem]" level="application" />
|
50
|
+
</component>
|
51
|
+
</module>
|
data/.idea/vcs.xml
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at 825461025@qq.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
gem 'pry-rails'
|
3
|
+
# Specify your gem's dependencies in order_as_arbitrary.gemspec
|
4
|
+
gem 'gemspec'
|
5
|
+
#
|
6
|
+
# if ENV["TRAVIS"] == "true" && ENV["ACTIVERECORD_VERSION"]
|
7
|
+
# gem "activerecord", ENV["ACTIVERECORD_VERSION"]
|
8
|
+
# end
|
9
|
+
#
|
10
|
+
gem "rspec-rails"
|
11
|
+
gem "mysql2",'~> 0.3.13'
|
12
|
+
gem "activerecord", ENV["ACTIVERECORD_VERSION"]
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionpack (4.2.1)
|
5
|
+
actionview (= 4.2.1)
|
6
|
+
activesupport (= 4.2.1)
|
7
|
+
rack (~> 1.6)
|
8
|
+
rack-test (~> 0.6.2)
|
9
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
10
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
11
|
+
actionview (4.2.1)
|
12
|
+
activesupport (= 4.2.1)
|
13
|
+
builder (~> 3.1)
|
14
|
+
erubis (~> 2.7.0)
|
15
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
16
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
17
|
+
activemodel (4.2.1)
|
18
|
+
activesupport (= 4.2.1)
|
19
|
+
builder (~> 3.1)
|
20
|
+
activerecord (4.2.1)
|
21
|
+
activemodel (= 4.2.1)
|
22
|
+
activesupport (= 4.2.1)
|
23
|
+
arel (~> 6.0)
|
24
|
+
activesupport (4.2.1)
|
25
|
+
i18n (~> 0.7)
|
26
|
+
json (~> 1.7, >= 1.7.7)
|
27
|
+
minitest (~> 5.1)
|
28
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
29
|
+
tzinfo (~> 1.1)
|
30
|
+
arel (6.0.4)
|
31
|
+
builder (3.2.3)
|
32
|
+
coderay (1.1.2)
|
33
|
+
concurrent-ruby (1.1.5)
|
34
|
+
crass (1.0.5)
|
35
|
+
diff-lcs (1.3)
|
36
|
+
erubis (2.7.0)
|
37
|
+
gemspec (0.3.1)
|
38
|
+
activesupport (= 4.2.1)
|
39
|
+
memoist (= 0.12.0)
|
40
|
+
rake (~> 10.4)
|
41
|
+
i18n (0.9.5)
|
42
|
+
concurrent-ruby (~> 1.0)
|
43
|
+
json (1.8.6)
|
44
|
+
loofah (2.3.1)
|
45
|
+
crass (~> 1.0.2)
|
46
|
+
nokogiri (>= 1.5.9)
|
47
|
+
memoist (0.12.0)
|
48
|
+
method_source (0.9.2)
|
49
|
+
mini_portile2 (2.4.0)
|
50
|
+
minitest (5.13.0)
|
51
|
+
mysql2 (0.3.21)
|
52
|
+
nokogiri (1.10.5)
|
53
|
+
mini_portile2 (~> 2.4.0)
|
54
|
+
pry (0.12.2)
|
55
|
+
coderay (~> 1.1.0)
|
56
|
+
method_source (~> 0.9.0)
|
57
|
+
pry-rails (0.3.9)
|
58
|
+
pry (>= 0.10.4)
|
59
|
+
rack (1.6.11)
|
60
|
+
rack-test (0.6.3)
|
61
|
+
rack (>= 1.0)
|
62
|
+
rails-deprecated_sanitizer (1.0.3)
|
63
|
+
activesupport (>= 4.2.0.alpha)
|
64
|
+
rails-dom-testing (1.0.9)
|
65
|
+
activesupport (>= 4.2.0, < 5.0)
|
66
|
+
nokogiri (~> 1.6)
|
67
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
68
|
+
rails-html-sanitizer (1.3.0)
|
69
|
+
loofah (~> 2.3)
|
70
|
+
railties (4.2.1)
|
71
|
+
actionpack (= 4.2.1)
|
72
|
+
activesupport (= 4.2.1)
|
73
|
+
rake (>= 0.8.7)
|
74
|
+
thor (>= 0.18.1, < 2.0)
|
75
|
+
rake (10.5.0)
|
76
|
+
rspec-core (3.9.0)
|
77
|
+
rspec-support (~> 3.9.0)
|
78
|
+
rspec-expectations (3.9.0)
|
79
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
80
|
+
rspec-support (~> 3.9.0)
|
81
|
+
rspec-mocks (3.9.0)
|
82
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
83
|
+
rspec-support (~> 3.9.0)
|
84
|
+
rspec-rails (3.9.0)
|
85
|
+
actionpack (>= 3.0)
|
86
|
+
activesupport (>= 3.0)
|
87
|
+
railties (>= 3.0)
|
88
|
+
rspec-core (~> 3.9.0)
|
89
|
+
rspec-expectations (~> 3.9.0)
|
90
|
+
rspec-mocks (~> 3.9.0)
|
91
|
+
rspec-support (~> 3.9.0)
|
92
|
+
rspec-support (3.9.0)
|
93
|
+
thor (0.20.3)
|
94
|
+
thread_safe (0.3.6)
|
95
|
+
tzinfo (1.2.5)
|
96
|
+
thread_safe (~> 0.1)
|
97
|
+
|
98
|
+
PLATFORMS
|
99
|
+
ruby
|
100
|
+
|
101
|
+
DEPENDENCIES
|
102
|
+
activerecord
|
103
|
+
gemspec
|
104
|
+
mysql2 (~> 0.3.13)
|
105
|
+
pry-rails
|
106
|
+
rspec-rails
|
107
|
+
|
108
|
+
BUNDLED WITH
|
109
|
+
2.0.2
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# OrderAsArbitrary
|
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/order_as_arbitrary`. 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 'order_as_arbitrary'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install order_as_arbitrary
|
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 `rake spec` to run the tests. You can also 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`, which will 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
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/order_as_arbitrary. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## Code of Conduct
|
38
|
+
|
39
|
+
Everyone interacting in the OrderAsArbitrary project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/order_as_arbitrary/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "order_as_arbitrary"
|
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(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require "order_as_arbitrary/version"
|
2
|
+
require "order_as_arbitrary/error"
|
3
|
+
module OrderAsArbitrary
|
4
|
+
def method_missing(name, *args)
|
5
|
+
method_name = get_method_name(name)
|
6
|
+
if method_name
|
7
|
+
check_arguments(args)
|
8
|
+
self.class.send(:define_method, "#{method_name[0]}") do |values|
|
9
|
+
column_name = get_method_name(__method__)[1]
|
10
|
+
if values.is_a? Array
|
11
|
+
if values.empty?
|
12
|
+
return all
|
13
|
+
elsif values.first.is_a? Range
|
14
|
+
conditions = range_clause(column_name, values)
|
15
|
+
else
|
16
|
+
conditions = array_clause(column_name, values)
|
17
|
+
end
|
18
|
+
order_sql = "CASE #{conditions.join(' ')} ELSE #{conditions.size} END"
|
19
|
+
order(Arel.sql(order_sql))
|
20
|
+
else
|
21
|
+
raise OrderAsArbitrary::Error, "Only accept array"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
send(method_name[0], args.first)
|
25
|
+
else
|
26
|
+
super
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def check_arguments(args)
|
33
|
+
raise OrderAsArbitrary::Error, "Wrong number of arguments " if args.empty?
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_method_name(name)
|
37
|
+
name.to_s.match(/^order_as_(\w*)/)
|
38
|
+
end
|
39
|
+
|
40
|
+
def range_clause(column_name, values)
|
41
|
+
values = values.each_with_index.map do |range, index|
|
42
|
+
raise OrderAsArbitrary::Error, "Range needs to be increasing" if range.first >= range.last
|
43
|
+
op = range.exclude_end? ? "<" : "<="
|
44
|
+
"WHEN #{column_name} >= #{range.first} AND #{column_name} #{op} #{range.last} THEN #{index}"
|
45
|
+
end
|
46
|
+
values
|
47
|
+
end
|
48
|
+
|
49
|
+
def array_clause(column_name, values)
|
50
|
+
values = values.each_with_index.map do |value, index|
|
51
|
+
raise OrderAsArbitrary::Error, "Cannot order by `nil`" if value.nil?
|
52
|
+
"WHEN #{column_name} = '#{value}' THEN #{index}"
|
53
|
+
end
|
54
|
+
values
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "order_as_arbitrary/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "order_as_arbitrary"
|
7
|
+
spec.version = OrderAsArbitrary::VERSION
|
8
|
+
spec.authors = ["Vita"]
|
9
|
+
spec.email = ["qs2811531898@gmail.com"]
|
10
|
+
spec.summary = "Add arbitrary ordering to ActiveRecord queries."
|
11
|
+
spec.description = "Obtain ActiveRecord results with a custom ordering "
|
12
|
+
|
13
|
+
# Specify which files should be added to the gem when it is released.
|
14
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
15
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
16
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
end
|
18
|
+
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "activerecord", ">= 6.0.0"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler"
|
25
|
+
spec.add_development_dependency "codecov"
|
26
|
+
spec.add_development_dependency "mysql2"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
|
+
spec.add_development_dependency "rspec-rails"
|
29
|
+
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: order_as_arbitrary
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vita
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-02-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 6.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: codecov
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mysql2
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec-rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: 'Obtain ActiveRecord results with a custom ordering '
|
98
|
+
email:
|
99
|
+
- qs2811531898@gmail.com
|
100
|
+
executables:
|
101
|
+
- console
|
102
|
+
- setup
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".gitignore"
|
107
|
+
- ".idea/.gitignore"
|
108
|
+
- ".idea/.rakeTasks"
|
109
|
+
- ".idea/inspectionProfiles/Project_Default.xml"
|
110
|
+
- ".idea/misc.xml"
|
111
|
+
- ".idea/modules.xml"
|
112
|
+
- ".idea/order_as_arbitrary.iml"
|
113
|
+
- ".idea/vcs.xml"
|
114
|
+
- ".rspec"
|
115
|
+
- ".travis.yml"
|
116
|
+
- CODE_OF_CONDUCT.md
|
117
|
+
- Gemfile
|
118
|
+
- Gemfile.lock
|
119
|
+
- README.md
|
120
|
+
- Rakefile
|
121
|
+
- bin/console
|
122
|
+
- bin/setup
|
123
|
+
- lib/order_as_arbitrary.rb
|
124
|
+
- lib/order_as_arbitrary/error.rb
|
125
|
+
- lib/order_as_arbitrary/version.rb
|
126
|
+
- order_as_arbitrary.gemspec
|
127
|
+
homepage:
|
128
|
+
licenses: []
|
129
|
+
metadata: {}
|
130
|
+
post_install_message:
|
131
|
+
rdoc_options: []
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
requirements: []
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 2.7.7
|
147
|
+
signing_key:
|
148
|
+
specification_version: 4
|
149
|
+
summary: Add arbitrary ordering to ActiveRecord queries.
|
150
|
+
test_files: []
|