activequery 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/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +32 -0
- data/LICENSE.txt +21 -0
- data/README.md +91 -0
- data/Rakefile +19 -0
- data/activequery.gemspec +53 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/activequery +27 -0
- data/lib/active_query/config.rb +14 -0
- data/lib/active_query/configuration.rb +14 -0
- data/lib/active_query/data_adapters/adapter_base.rb +15 -0
- data/lib/active_query/data_adapters/postgresql_adapter.rb +22 -0
- data/lib/active_query/sql_parser.rb +43 -0
- data/lib/active_query/sql_renderer.rb +15 -0
- data/lib/active_query/sql_template.rb +54 -0
- data/lib/active_query/version.rb +3 -0
- data/lib/active_query.rb +88 -0
- metadata +151 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 604df6bd427cfff0873ed44e5812adf4fc61584a6c51dbba5ec92fb18f5cac11
|
4
|
+
data.tar.gz: 3b99b1b2cc2b17bbaefcda6e89666dffa5ef9c99b68b6484012318e60cf6a6cb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ce0c3882bd16c514e661ce1942f2f028754e2a1995766a71da3080abfd50ce465619822b853a56b7e7186529cc90870590b70e1b5dc4d54dadc76f915461e958
|
7
|
+
data.tar.gz: 35321a4999149a389919979d7f8363a786bd6f94a7d0fe825b8d36a70ecb8aff3394207fab5969967ee17c2e5ad41e335c937efaf78bd62f4c89015b76647836
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
activequery (0.1.0)
|
5
|
+
strscan (~> 1.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
coderay (1.1.2)
|
11
|
+
method_source (0.9.2)
|
12
|
+
minitest (5.11.3)
|
13
|
+
pg (1.1.4)
|
14
|
+
pry (0.12.2)
|
15
|
+
coderay (~> 1.1.0)
|
16
|
+
method_source (~> 0.9.0)
|
17
|
+
rake (10.5.0)
|
18
|
+
strscan (1.0.0)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
activequery!
|
25
|
+
bundler (~> 1.17)
|
26
|
+
minitest (~> 5.0)
|
27
|
+
pg (~> 1.0)
|
28
|
+
pry
|
29
|
+
rake (~> 10.0)
|
30
|
+
|
31
|
+
BUNDLED WITH
|
32
|
+
1.17.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Marko
|
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,91 @@
|
|
1
|
+
# ActiveQuery
|
2
|
+
|
3
|
+
[](https://travis-ci.org/mtunjic/activequery)
|
4
|
+
[](https://badge.fury.io/rb/activequery)
|
5
|
+
|
6
|
+
### SQL & ruby
|
7
|
+
Ideal for reports, large queries, separating SQL from code logic, command and query responsibility segregation (CQRS)
|
8
|
+
|
9
|
+
> Ruby is a great language for writing DSLs, but we don't need a new one. SQL is already a mature DSL.
|
10
|
+
> (Don't agree? Wait until this extra syntax layer breaks down and you start wrestling with a (raw-sql) function.)
|
11
|
+
> ~ Kris Jenkins (yesql)
|
12
|
+
|
13
|
+
```SQL
|
14
|
+
-- name: users_by_country
|
15
|
+
SELECT *
|
16
|
+
FROM users
|
17
|
+
WHERE country_code = :country_code
|
18
|
+
```
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
ActiveQuery.users_by_country # return raw sql
|
22
|
+
# You use symbols as params
|
23
|
+
ActiveQuery.run(:users_by_country) # run query as full-scan
|
24
|
+
# async call, stream the results Postgres only
|
25
|
+
ActiveQuery.async_run(:all_users) {|u| puts u["name"] }
|
26
|
+
```
|
27
|
+
|
28
|
+
## Installation
|
29
|
+
|
30
|
+
Add this line to your application's Gemfile:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
gem 'activequery'
|
34
|
+
```
|
35
|
+
|
36
|
+
And then execute:
|
37
|
+
|
38
|
+
$ bundle
|
39
|
+
|
40
|
+
Or install it yourself as:
|
41
|
+
|
42
|
+
$ gem install activequery
|
43
|
+
|
44
|
+
## Usage
|
45
|
+
|
46
|
+
Create template dir inside your app
|
47
|
+
|
48
|
+
```console
|
49
|
+
mkdir -p app/sqltemplates
|
50
|
+
touch app/sqltemplates/my_query.sql
|
51
|
+
```
|
52
|
+
|
53
|
+
Add created path to config
|
54
|
+
For Rails users:
|
55
|
+
|
56
|
+
```console
|
57
|
+
activequery rails
|
58
|
+
```
|
59
|
+
|
60
|
+
Configure:
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
ActiveQuery.configure do |config|
|
64
|
+
config.template_path = "."
|
65
|
+
config.adapter = :postgres
|
66
|
+
config.connection = "dbname=rails6pg_development user=dev"
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
### TODO:
|
71
|
+
- [x] Ruby On Rails easy integration
|
72
|
+
- [x] PostgreSQL Adapter
|
73
|
+
- [x] Ruby erb inside sql template files
|
74
|
+
- [x] Async/Stream results (ideal for realtime reporting/analytics)
|
75
|
+
- [ ] Named parameters, and ?-style positional parameters
|
76
|
+
- [ ] class: MyClass param to create or extend ruby class with
|
77
|
+
- [ ] Import/Export to Materialized Views
|
78
|
+
- [ ] Retrieving SQL templates from custom stores (Redis, Riak)
|
79
|
+
- [ ] Add connection pooling. (If you use this with Rails ActiveRecord has its own connection pool)
|
80
|
+
- [ ] Add Actors/Workers
|
81
|
+
- [ ] MySQL and SQLite providers
|
82
|
+
- [ ] Generate CRUD
|
83
|
+
|
84
|
+
|
85
|
+
## Contributing
|
86
|
+
|
87
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mtunjic/activequery.
|
88
|
+
|
89
|
+
## License
|
90
|
+
|
91
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.libs << "lib"
|
7
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
8
|
+
end
|
9
|
+
|
10
|
+
namespace :active_query do
|
11
|
+
desc "Create config file for Rails"
|
12
|
+
task :setup do
|
13
|
+
rails_initializer_path = 'config/initializers/active_query.rb'
|
14
|
+
open(rails_initializer_path, 'w') { |f| f << "This file contains great truths.\n" }
|
15
|
+
puts 'The config file is created to config/initializers.'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
task :default => :test
|
data/activequery.gemspec
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "active_query/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "activequery"
|
8
|
+
spec.version = ActiveQuery::VERSION
|
9
|
+
spec.authors = ["Marko"]
|
10
|
+
spec.email = ["marko.tunjic@live.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A Ruby library for using SQL (Streaming, CQRS)}
|
13
|
+
spec.description = %q{Raw sql with ruby - ideal for reports, large queries, separating SQL from code logic and CQRS}
|
14
|
+
spec.homepage = "https://github.com/mtunjic/activequery"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = Dir["CHANGELOG.md", "MIT-LICENSE", "README.rdoc", "lib/**/*"]
|
18
|
+
spec.require_path = "lib"
|
19
|
+
|
20
|
+
# spec.extra_rdoc_files = %w(README.rdoc)
|
21
|
+
# spec.rdoc_options.concat ["--main", "README.rdoc"]
|
22
|
+
|
23
|
+
if spec.respond_to?(:metadata)
|
24
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
25
|
+
|
26
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
27
|
+
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
28
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
29
|
+
else
|
30
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
31
|
+
"public gem pushes."
|
32
|
+
end
|
33
|
+
|
34
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
35
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
36
|
+
end
|
37
|
+
spec.bindir = "exe"
|
38
|
+
#spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
39
|
+
spec.executables = ["activequery"]
|
40
|
+
spec.require_paths = ["lib"]
|
41
|
+
|
42
|
+
|
43
|
+
spec.add_runtime_dependency 'strscan', '~> 1.0'
|
44
|
+
|
45
|
+
|
46
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
47
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
48
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
49
|
+
spec.add_development_dependency "pry"
|
50
|
+
spec.add_development_dependency 'pg', '~> 1.0'
|
51
|
+
|
52
|
+
|
53
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "activequery"
|
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/activequery
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# TODO: use Railtie for rails rake tasks
|
4
|
+
|
5
|
+
CONFIG_FILE =
|
6
|
+
%q{
|
7
|
+
require 'active_query'
|
8
|
+
TEMPLATE_PATH = Rails.root.join('app', 'templates')
|
9
|
+
# Adapters: postgres, sqlite, mysql
|
10
|
+
ActiveQuery.configure do |config|
|
11
|
+
config.template_path = TEMPLATE_PATH.to_s
|
12
|
+
config.adapter = :postgres
|
13
|
+
#config.connection = "dbname=test user=dev"
|
14
|
+
end
|
15
|
+
}.strip
|
16
|
+
|
17
|
+
def create_config_file
|
18
|
+
rails_initializer_path = 'config/initializers/active_query.rb'
|
19
|
+
open(rails_initializer_path, 'w') { |f| f << CONFIG_FILE }
|
20
|
+
puts 'The config file is created to config/initializers.'
|
21
|
+
end
|
22
|
+
|
23
|
+
if ARGV[0] == "rails"
|
24
|
+
create_config_file
|
25
|
+
else
|
26
|
+
puts "Usage: activequery rails"
|
27
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative "configuration"
|
2
|
+
|
3
|
+
module ActiveQuery
|
4
|
+
module Config
|
5
|
+
|
6
|
+
TEMPLATE_PATH = File.expand_path('../../test/templates', __dir__)
|
7
|
+
puts TEMPLATE_PATH
|
8
|
+
ActiveQuery.configure do |config|
|
9
|
+
config.template_path = TEMPLATE_PATH
|
10
|
+
config.adapter = :postgres
|
11
|
+
config.connection = "host=localhost port=5432 dbname=rails6pg_development connect_timeout=10 user=dev"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module ActiveQuery
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :template_path, :adapter, :connection
|
4
|
+
|
5
|
+
def initialize(options = {}, &block)
|
6
|
+
@template_path = ""
|
7
|
+
@adapter = ""
|
8
|
+
@connection = ""
|
9
|
+
options.each { |k,v| send("#{k}=", v) }
|
10
|
+
instance_eval(&block) if block_given?
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ActiveQuery
|
2
|
+
module DataAdapters
|
3
|
+
require_relative "adapter_base"
|
4
|
+
|
5
|
+
class PostgresqlAdapter < AdapterBase
|
6
|
+
|
7
|
+
def self.open(params)
|
8
|
+
begin
|
9
|
+
conn = PG::connect(params)
|
10
|
+
return conn unless block_given?
|
11
|
+
yield(conn)
|
12
|
+
rescue PG::Error => err
|
13
|
+
$stderr.puts "%p PgConn::open: %s" % [ err.class, err.message ]
|
14
|
+
conn.reset
|
15
|
+
ensure
|
16
|
+
conn.close if conn
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end #PostgresqlAdapter
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module ActiveQuery
|
2
|
+
module SQLParser
|
3
|
+
|
4
|
+
require 'strscan'
|
5
|
+
class SyntaxError < StandardError; end
|
6
|
+
|
7
|
+
Query = Struct.new(:name, :params, :comment, :query)
|
8
|
+
|
9
|
+
WHITESPACE = /\s+/
|
10
|
+
NAME = /^\s*--\s*name\s*:\s*(.+)/
|
11
|
+
END_QUERY = /;/
|
12
|
+
|
13
|
+
def self.parse_file(text)
|
14
|
+
@scanner = StringScanner.new(text)
|
15
|
+
@line = 0
|
16
|
+
@queries = []
|
17
|
+
|
18
|
+
until @scanner.eos? || @scanner.check_until(END_QUERY).nil?
|
19
|
+
@line += 1
|
20
|
+
@queries << parse_line
|
21
|
+
end
|
22
|
+
@queries
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def self.parse_line
|
27
|
+
@scanner.skip(NAME)
|
28
|
+
|
29
|
+
qname = @scanner.captures
|
30
|
+
if qname
|
31
|
+
qname = qname.first
|
32
|
+
else
|
33
|
+
fail SyntaxError, "error on line #{@line} (pos. #{@scanner.pos})"
|
34
|
+
end
|
35
|
+
|
36
|
+
query = @scanner.scan_until(END_QUERY)
|
37
|
+
unless query
|
38
|
+
fail SyntaxError, "error on line #{@line} (pos. #{@scanner.pos})"
|
39
|
+
end
|
40
|
+
Query.new(qname, "", "", query)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module ActiveQuery
|
2
|
+
|
3
|
+
class ApplicationError < StandardError; end
|
4
|
+
class TemplatePathError < ApplicationError; end
|
5
|
+
class ScannerError < ApplicationError; end
|
6
|
+
|
7
|
+
class SQLTemplate
|
8
|
+
|
9
|
+
require_relative "sql_parser"
|
10
|
+
require 'erb'
|
11
|
+
require 'find'
|
12
|
+
|
13
|
+
attr_accessor :config
|
14
|
+
attr_reader :templates
|
15
|
+
|
16
|
+
def initialize(config = Configuration.new)
|
17
|
+
@config = config
|
18
|
+
@templates = {}
|
19
|
+
end
|
20
|
+
|
21
|
+
def load!
|
22
|
+
template_path = @config.template_path
|
23
|
+
unless File.directory?(template_path)
|
24
|
+
raise TemplatePathError, "error: #{template_path} template path is invalid, please make sure it exists."
|
25
|
+
else
|
26
|
+
Find.find(template_path) do |path|
|
27
|
+
if File.basename(path) =~ /sql$/
|
28
|
+
parse_sql(path)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def templates
|
35
|
+
@templates ||= Hash.new
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.get(query)
|
39
|
+
@templates[query.to_s]
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def read_sql_file(path:)
|
44
|
+
open(path, "r") { |t| ERB.new(t.read).result(binding) }
|
45
|
+
end
|
46
|
+
|
47
|
+
def parse_sql(path)
|
48
|
+
sql_template = read_sql_file(path: path)
|
49
|
+
sql = ActiveQuery::SQLParser.parse_file(sql_template)
|
50
|
+
sql.each {|q| @templates[q.name] = q.query.strip }
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
data/lib/active_query.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
require "active_query/version"
|
2
|
+
require "active_query/configuration"
|
3
|
+
require "active_query/sql_template"
|
4
|
+
require "active_query/data_adapters/postgresql_adapter"
|
5
|
+
require 'pg'
|
6
|
+
module ActiveQuery
|
7
|
+
include ActiveQuery::DataAdapters
|
8
|
+
# Configuration
|
9
|
+
class << self
|
10
|
+
attr_writer :config
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.config
|
14
|
+
@config ||= Configuration.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.reset
|
18
|
+
@config = Configuration.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.configure
|
22
|
+
yield(config)
|
23
|
+
end
|
24
|
+
|
25
|
+
# runners...
|
26
|
+
# Full-Scan
|
27
|
+
def self.run(query)
|
28
|
+
if query.is_a? Symbol
|
29
|
+
query = self.send(query)
|
30
|
+
end
|
31
|
+
con_str = ActiveQuery.config.connection
|
32
|
+
PostgresqlAdapter.open(con_str) { |c| c.exec(query) }
|
33
|
+
end
|
34
|
+
|
35
|
+
# async_exec(sql) {|pg_result| block }
|
36
|
+
# This function has the same behavior as sync_exec, but is implemented using the
|
37
|
+
# asynchronous command processing API of libpq.
|
38
|
+
def self.async_run(query, &block)
|
39
|
+
con_str = ActiveQuery.config.connection
|
40
|
+
|
41
|
+
if query.is_a? Symbol
|
42
|
+
query = self.send(query)
|
43
|
+
end
|
44
|
+
|
45
|
+
PostgresqlAdapter.open(con_str) do |conn|
|
46
|
+
conn.send_query(query)
|
47
|
+
conn.set_single_row_mode
|
48
|
+
conn.get_result.stream_each do |row|
|
49
|
+
yield(row)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.reload!
|
55
|
+
#t = ActiveQuery::SQLTemplate.new(ActiveQuery.config)
|
56
|
+
t = ActiveQuery::SQLTemplate.new(self.config)
|
57
|
+
t.load!
|
58
|
+
t.templates.each do |qname, query|
|
59
|
+
define_singleton_method("#{qname}") do
|
60
|
+
query
|
61
|
+
end
|
62
|
+
end
|
63
|
+
rescue ApplicationError => err
|
64
|
+
$stderr.puts "%p ::SQLTemplate.load! %s" % [ err.class, err.message ]
|
65
|
+
end
|
66
|
+
|
67
|
+
# WIP Init config
|
68
|
+
require "active_query/config"
|
69
|
+
include ActiveQuery::Config
|
70
|
+
# Build heleper methods for query names
|
71
|
+
#fail TemplatePathError, "templates path missing" if self.config.template_path.empty?
|
72
|
+
puts "Loading SQL templates from #{self.config.template_path}"
|
73
|
+
t = ActiveQuery::SQLTemplate.new(self.config)
|
74
|
+
t.load!
|
75
|
+
t.templates.each do |qname, query|
|
76
|
+
define_singleton_method("#{qname}") do
|
77
|
+
query
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
puts "SQL templates loaded."
|
82
|
+
rescue ApplicationError => err
|
83
|
+
$stderr.puts "%p ::SQLTemplate.load! %s" % [ err.class, err.message ]
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: activequery
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marko
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: strscan
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.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: '1.17'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.17'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
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: pg
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.0'
|
97
|
+
description: Raw sql with ruby - ideal for reports, large queries, separating SQL
|
98
|
+
from code logic and CQRS
|
99
|
+
email:
|
100
|
+
- marko.tunjic@live.com
|
101
|
+
executables:
|
102
|
+
- activequery
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".gitignore"
|
107
|
+
- ".travis.yml"
|
108
|
+
- Gemfile
|
109
|
+
- Gemfile.lock
|
110
|
+
- LICENSE.txt
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- activequery.gemspec
|
114
|
+
- bin/console
|
115
|
+
- bin/setup
|
116
|
+
- exe/activequery
|
117
|
+
- lib/active_query.rb
|
118
|
+
- lib/active_query/config.rb
|
119
|
+
- lib/active_query/configuration.rb
|
120
|
+
- lib/active_query/data_adapters/adapter_base.rb
|
121
|
+
- lib/active_query/data_adapters/postgresql_adapter.rb
|
122
|
+
- lib/active_query/sql_parser.rb
|
123
|
+
- lib/active_query/sql_renderer.rb
|
124
|
+
- lib/active_query/sql_template.rb
|
125
|
+
- lib/active_query/version.rb
|
126
|
+
homepage: https://github.com/mtunjic/activequery
|
127
|
+
licenses:
|
128
|
+
- MIT
|
129
|
+
metadata:
|
130
|
+
allowed_push_host: https://rubygems.org
|
131
|
+
homepage_uri: https://github.com/mtunjic/activequery
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
requirements: []
|
147
|
+
rubygems_version: 3.0.3
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: A Ruby library for using SQL (Streaming, CQRS)
|
151
|
+
test_files: []
|