arql 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 +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +53 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +2 -0
- data/arql.gemspec +31 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/arql +5 -0
- data/lib/arql/app.rb +50 -0
- data/lib/arql/cli.rb +114 -0
- data/lib/arql/connection.rb +11 -0
- data/lib/arql/definition.rb +27 -0
- data/lib/arql/repl.rb +36 -0
- data/lib/arql/version.rb +3 -0
- data/lib/arql.rb +9 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: acf04b3eab704e69a043994e5f3529315e1e8aa57cf9167867a30213120a3fe5
|
4
|
+
data.tar.gz: 782757a05d29076e1761dfbaebed91b244e01e89a0de4f69b6e239c48dc0c424
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d204ef54833e2dae7acf18ed13632da41baab1dcf149514abe7064cfac51ea9ea2a6556640c2ad0df1a84993827c7ee3afbb800773ec07620dac86b6b81d109f
|
7
|
+
data.tar.gz: a8706a7ae9acf7f06a52a733f871e35c57706d247ea44edd8462f453fb7f1471f28fd5e44f5e942c2fcae184721b5e53ef6242a026d38ae106d7aa5793f6fc06
|
data/.gitignore
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 liuxiang@ktjr.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 [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
arql (0.1.0)
|
5
|
+
activerecord (~> 6.0.0)
|
6
|
+
activesupport (~> 6.0.0)
|
7
|
+
mysql2 (~> 0.5.3)
|
8
|
+
pry (~> 0.13.1)
|
9
|
+
pry-byebug (~> 3.9.0)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
activemodel (6.0.2.2)
|
15
|
+
activesupport (= 6.0.2.2)
|
16
|
+
activerecord (6.0.2.2)
|
17
|
+
activemodel (= 6.0.2.2)
|
18
|
+
activesupport (= 6.0.2.2)
|
19
|
+
activesupport (6.0.2.2)
|
20
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
21
|
+
i18n (>= 0.7, < 2)
|
22
|
+
minitest (~> 5.1)
|
23
|
+
tzinfo (~> 1.1)
|
24
|
+
zeitwerk (~> 2.2)
|
25
|
+
byebug (11.1.3)
|
26
|
+
coderay (1.1.2)
|
27
|
+
concurrent-ruby (1.1.6)
|
28
|
+
i18n (1.8.2)
|
29
|
+
concurrent-ruby (~> 1.0)
|
30
|
+
method_source (1.0.0)
|
31
|
+
minitest (5.14.0)
|
32
|
+
mysql2 (0.5.3)
|
33
|
+
pry (0.13.1)
|
34
|
+
coderay (~> 1.1)
|
35
|
+
method_source (~> 1.0)
|
36
|
+
pry-byebug (3.9.0)
|
37
|
+
byebug (~> 11.0)
|
38
|
+
pry (~> 0.13.0)
|
39
|
+
rake (12.3.3)
|
40
|
+
thread_safe (0.3.6)
|
41
|
+
tzinfo (1.2.7)
|
42
|
+
thread_safe (~> 0.1)
|
43
|
+
zeitwerk (2.3.0)
|
44
|
+
|
45
|
+
PLATFORMS
|
46
|
+
ruby
|
47
|
+
|
48
|
+
DEPENDENCIES
|
49
|
+
arql!
|
50
|
+
rake (~> 12.0)
|
51
|
+
|
52
|
+
BUNDLED WITH
|
53
|
+
2.1.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Liu Xiang
|
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,44 @@
|
|
1
|
+
# Arql
|
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/arql`. 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 'arql'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install arql
|
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. 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/lululau/arql. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/lululau/arql/blob/master/CODE_OF_CONDUCT.md).
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
41
|
+
|
42
|
+
## Code of Conduct
|
43
|
+
|
44
|
+
Everyone interacting in the Arql project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/lululau/arql/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/arql.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative 'lib/arql/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "arql"
|
5
|
+
spec.version = Arql::VERSION
|
6
|
+
spec.authors = ["Liu Xiang"]
|
7
|
+
spec.email = ["liuxiang921@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = %{Rails ActiveRecord is the best SQL query editor.}
|
10
|
+
spec.description = %{Rails ActiveRecord is the best SQL query editor.}
|
11
|
+
spec.homepage = "https://github.com/lululau/arql"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_dependency 'mysql2', '~> 0.5.3'
|
27
|
+
spec.add_dependency 'activerecord', '~> 6.0.0'
|
28
|
+
spec.add_dependency 'activesupport', '~> 6.0.0'
|
29
|
+
spec.add_dependency 'pry', '~> 0.13.1'
|
30
|
+
spec.add_dependency 'pry-byebug', '~> 3.9.0'
|
31
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "arql"
|
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
data/exe/arql
ADDED
data/lib/arql/app.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'active_support/core_ext/hash'
|
2
|
+
|
3
|
+
module Arql
|
4
|
+
class App
|
5
|
+
def initialize(options)
|
6
|
+
@options = options
|
7
|
+
Connection.open(connect_options)
|
8
|
+
@definition = Definition.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def connect_options
|
12
|
+
if use_db_cmd_options?
|
13
|
+
{
|
14
|
+
adapter: @options.db_adapter,
|
15
|
+
host: @options.db_host,
|
16
|
+
username: @options.db_user,
|
17
|
+
password: @options.db_password || '',
|
18
|
+
database: @options.db_name,
|
19
|
+
encoding: @options.db_encoding,
|
20
|
+
pool: @options.db_pool,
|
21
|
+
port: @options.db_port
|
22
|
+
}
|
23
|
+
else
|
24
|
+
config[:db][@options.env]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def config
|
29
|
+
@config ||= YAML.load(IO.read(@options.config_file)).with_indifferent_access
|
30
|
+
end
|
31
|
+
|
32
|
+
def run!
|
33
|
+
if @options.code.present?
|
34
|
+
eval(@options.code)
|
35
|
+
elsif @options.args.present?
|
36
|
+
@options.args.each { |rb| load(rb) }
|
37
|
+
else
|
38
|
+
run_repl!
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def run_repl!
|
43
|
+
Repl.new
|
44
|
+
end
|
45
|
+
|
46
|
+
def use_db_cmd_options?
|
47
|
+
@options.db_host.present?
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/arql/cli.rb
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
module Arql
|
5
|
+
class Cli
|
6
|
+
class << self
|
7
|
+
def start
|
8
|
+
parse_options!
|
9
|
+
App.new(@options).run!
|
10
|
+
end
|
11
|
+
|
12
|
+
def parse_options!
|
13
|
+
@options = OpenStruct.new(db_adapter: 'mysql2',
|
14
|
+
db_encoding: 'UFF-8',
|
15
|
+
db_pool: 5,
|
16
|
+
config_file: default_config_file,
|
17
|
+
initializer: default_initializer)
|
18
|
+
|
19
|
+
|
20
|
+
OptionParser.new do |opts|
|
21
|
+
opts.banner = <<~EOF
|
22
|
+
Usage: arql [options] [ruby file]
|
23
|
+
|
24
|
+
If neither [ruby file] nor -e option specified, a Pry REPL will be launched,
|
25
|
+
otherwise the specified ruby file or -e option value will be run, and no REPL launched
|
26
|
+
|
27
|
+
EOF
|
28
|
+
|
29
|
+
opts.on('-cCONFIG_FILE', '--conf=CONFIG_FILE', 'Specify config file, default is $HOME/.arql.yml, or $HOME/.arql.d/init.yml.') do |config_file|
|
30
|
+
@options.config_file = config_file
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.on('-iINITIALIZER', '--initializer=INITIALIZER', 'Specify initializer ruby file, default is $HOME/.arql.rb, or $HOME/.arql.d/init.rb.') do |initializer|
|
34
|
+
@options.initializer = initializer
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on('-EENVIRON', '--env=ENVIRON', 'Specify config environment.') do |env|
|
38
|
+
@options.env = env
|
39
|
+
end
|
40
|
+
|
41
|
+
opts.on('-jJAVA_CONFIG', '--java-conf=JAVA_CONFIG', 'Use JDBC config in JAVA_CONFIG file, if directory sepcified, first *.properties/*.yml file found in the directory will be used') do |config_file|
|
42
|
+
@options.config_file = config_file
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on('-ADB_ADAPTER', '--db-adapter=DB_ADAPTER', 'Specify DB Adapter, default is mysql2') do |db_adapter|
|
46
|
+
@options.db_adapter = db_adapter
|
47
|
+
end
|
48
|
+
|
49
|
+
opts.on('-HDB_HOST', '--db-host=DB_HOST', 'Specify DB host, if specified -E option will be ignored') do |db_host|
|
50
|
+
@options.db_host = db_host
|
51
|
+
end
|
52
|
+
|
53
|
+
opts.on('-PDB_PORT', '--db-port=DB_PORT', 'Specify DB port, if specified -E option will be ignored') do |db_port|
|
54
|
+
@options.db_port = db_port.to_i
|
55
|
+
end
|
56
|
+
|
57
|
+
opts.on('-DDB_NAME', '--db-name=DB_NAME', 'Specify database name, if specified -E option will be ignored') do |db_name|
|
58
|
+
@options.db_name = db_name
|
59
|
+
end
|
60
|
+
|
61
|
+
opts.on('-UDB_USER', '--db-user=DB_USER', 'Specify database user, if specified -E option will be ignored') do |db_user|
|
62
|
+
@options.db_user = db_user
|
63
|
+
end
|
64
|
+
|
65
|
+
opts.on('-pDB_PASSWORD', '--db-password=DB_PASSWORD', 'Specify database password, if specified -E option will be ignored') do |db_password|
|
66
|
+
@options.db_password = db_password
|
67
|
+
end
|
68
|
+
|
69
|
+
opts.on('-n', '--db-encoding=DB_ENCODING', 'Specify database encoding, default is UTF-8') do |db_encoding|
|
70
|
+
@options.db_encoding = db_encoding
|
71
|
+
end
|
72
|
+
|
73
|
+
opts.on('-o', '--db-pool=DB_POOL', 'Specify database pool size, default is 5') do |db_pool|
|
74
|
+
@options.db_pool = db_pool
|
75
|
+
end
|
76
|
+
|
77
|
+
opts.on('-eCODE', '--eval=CODE', 'evaluate CODE') do |code|
|
78
|
+
@options.code = code
|
79
|
+
end
|
80
|
+
|
81
|
+
opts.on('-h', '--help', 'Prints this help') do
|
82
|
+
puts opts
|
83
|
+
exit
|
84
|
+
end
|
85
|
+
|
86
|
+
end.parse!
|
87
|
+
|
88
|
+
@options.args = ARGV
|
89
|
+
end
|
90
|
+
|
91
|
+
def default_config_file
|
92
|
+
conf = File.expand_path('~/.arql.yml')
|
93
|
+
return conf if File.file?(conf)
|
94
|
+
conf = File.expand_path('~/.arql.yaml')
|
95
|
+
return conf if File.file?(conf)
|
96
|
+
conf = File.expand_path('~/.arql/init.yml')
|
97
|
+
return conf if File.file?(conf)
|
98
|
+
conf = File.expand_path('~/.arql/init.yaml')
|
99
|
+
return conf if File.file?(conf)
|
100
|
+
end
|
101
|
+
|
102
|
+
def default_initializer
|
103
|
+
conf = File.expand_path('~/.arql.yml')
|
104
|
+
return conf if File.file?(conf)
|
105
|
+
conf = File.expand_path('~/.arql.yaml')
|
106
|
+
return conf if File.file?(conf)
|
107
|
+
conf = File.expand_path('~/.arql/init.yml')
|
108
|
+
return conf if File.file?(conf)
|
109
|
+
conf = File.expand_path('~/.arql/init.yaml')
|
110
|
+
return conf if File.file?(conf)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Arql
|
2
|
+
class Definition
|
3
|
+
def initialize
|
4
|
+
ActiveRecord::Base.connection.tap do |conn|
|
5
|
+
conn.tables.each do |table_name|
|
6
|
+
conn.primary_key(table_name).tap do |pkey|
|
7
|
+
table_name.camelize.tap do |const_name|
|
8
|
+
const_name = 'Modul' if const_name == 'Module'
|
9
|
+
const_name = 'Clazz' if const_name == 'Class'
|
10
|
+
Class.new(ActiveRecord::Base) do
|
11
|
+
self.primary_key = pkey
|
12
|
+
self.table_name = table_name
|
13
|
+
self.inheritance_column = nil
|
14
|
+
end.tap do |clazz|
|
15
|
+
Object.const_set(const_name, clazz).tap do |const|
|
16
|
+
const_name.gsub(/[a-z]*/, '').tap do |abbr|
|
17
|
+
Object.const_set abbr, const unless Object.const_defined?(abbr)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/arql/repl.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'pry-byebug'
|
3
|
+
|
4
|
+
module Arql
|
5
|
+
class Repl
|
6
|
+
def initialize
|
7
|
+
Pry.config.prompt = Pry::Prompt.new("", "", prompt)
|
8
|
+
main_object.pry
|
9
|
+
end
|
10
|
+
|
11
|
+
def main_object
|
12
|
+
return @main if @main
|
13
|
+
@main = Object.new
|
14
|
+
@main.instance_eval do
|
15
|
+
def inspect
|
16
|
+
to_s
|
17
|
+
end
|
18
|
+
def to_s
|
19
|
+
"main"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
@main
|
23
|
+
end
|
24
|
+
|
25
|
+
def prompt
|
26
|
+
[proc do |obj, nest_level, _|
|
27
|
+
if obj == main_object && nest_level == 0
|
28
|
+
nest_level_prompt = ''
|
29
|
+
else
|
30
|
+
nest_level_prompt = "(#{obj}:#{nest_level})"
|
31
|
+
end
|
32
|
+
"ARQL#{nest_level_prompt} -> "
|
33
|
+
end]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/arql/version.rb
ADDED
data/lib/arql.rb
ADDED
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: arql
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Liu Xiang
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-05-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mysql2
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.5.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.5.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activerecord
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 6.0.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 6.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 6.0.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 6.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.13.1
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.13.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry-byebug
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.9.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.9.0
|
83
|
+
description: Rails ActiveRecord is the best SQL query editor.
|
84
|
+
email:
|
85
|
+
- liuxiang921@gmail.com
|
86
|
+
executables:
|
87
|
+
- arql
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- CODE_OF_CONDUCT.md
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- arql.gemspec
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- exe/arql
|
102
|
+
- lib/arql.rb
|
103
|
+
- lib/arql/app.rb
|
104
|
+
- lib/arql/cli.rb
|
105
|
+
- lib/arql/connection.rb
|
106
|
+
- lib/arql/definition.rb
|
107
|
+
- lib/arql/repl.rb
|
108
|
+
- lib/arql/version.rb
|
109
|
+
homepage: https://github.com/lululau/arql
|
110
|
+
licenses:
|
111
|
+
- MIT
|
112
|
+
metadata: {}
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: 2.3.0
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
requirements: []
|
128
|
+
rubygems_version: 3.1.2
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Rails ActiveRecord is the best SQL query editor.
|
132
|
+
test_files: []
|