rom-yesql 0.5.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.devtools/templates/changelog.erb +40 -0
- data/.github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md +10 -0
- data/.github/ISSUE_TEMPLATE/---bug-report.md +30 -0
- data/.github/ISSUE_TEMPLATE/---feature-request.md +18 -0
- data/.github/workflows/ci.yml +82 -0
- data/.github/workflows/docsite.yml +62 -0
- data/.github/workflows/sync_configs.yml +53 -0
- data/.rspec +2 -0
- data/.rubocop.yml +117 -39
- data/CHANGELOG.md +32 -12
- data/CODE_OF_CONDUCT.md +13 -0
- data/CONTRIBUTING.md +29 -0
- data/Gemfile +11 -7
- data/Gemfile.devtools +17 -0
- data/Guardfile +7 -5
- data/LICENSE +20 -0
- data/README.md +14 -25
- data/Rakefile +5 -3
- data/changelog.yml +33 -0
- data/lib/rom-yesql.rb +4 -2
- data/lib/rom/yesql.rb +4 -2
- data/lib/rom/yesql/dataset.rb +2 -0
- data/lib/rom/yesql/gateway.rb +8 -6
- data/lib/rom/yesql/relation.rb +5 -4
- data/lib/rom/yesql/relation/class_interface.rb +4 -3
- data/lib/rom/yesql/version.rb +3 -1
- data/project.yml +2 -0
- data/rakelib/rubocop.rake +4 -3
- data/rom-yesql.gemspec +3 -3
- data/spec/integration/adapter_spec.rb +26 -24
- data/spec/shared/database_setup.rb +5 -3
- data/spec/shared/repository_setup.rb +8 -6
- data/spec/shared/users_and_tasks.rb +9 -7
- data/spec/spec_helper.rb +14 -19
- data/spec/support/coverage.rb +15 -0
- data/spec/support/warnings.rb +10 -0
- data/spec/unit/rom/yesql/repository_spec.rb +12 -10
- metadata +29 -22
- data/.rubocop_todo.yml +0 -21
- data/.travis.yml +0 -30
- data/LICENSE.txt +0 -22
data/CHANGELOG.md
CHANGED
@@ -1,49 +1,69 @@
|
|
1
|
-
##
|
1
|
+
## 1.0.0 2020-12-06
|
2
|
+
|
3
|
+
Updated to work with rom 6.0.0 (@mrship)
|
4
|
+
|
5
|
+
|
6
|
+
[Compare v0.5.1...v1.0.0](https://github.com/rom-rb/rom-yesql/compare/v0.5.1...v1.0.0)
|
7
|
+
|
8
|
+
## 0.5.1 2017-03-30
|
2
9
|
|
3
10
|
Updated rom dependency (flash-gordon)
|
4
11
|
|
12
|
+
|
5
13
|
[Compare v0.5.0...v0.5.1](https://github.com/rom-rb/rom-yesql/compare/v0.5.0...v0.5.1)
|
6
14
|
|
7
|
-
##
|
15
|
+
## 0.5.0 2017-03-28
|
8
16
|
|
9
17
|
Updated to work with rom 3.2.0 (flash-gordon)
|
10
18
|
|
19
|
+
|
11
20
|
[Compare v0.4.0...v0.5.0](https://github.com/rom-rb/rom-yesql/compare/v0.4.0...v0.5.0)
|
12
21
|
|
13
|
-
##
|
22
|
+
## 0.4.0 2017-02-10
|
14
23
|
|
15
24
|
Updated to work with rom 3.0.0
|
16
25
|
|
26
|
+
|
17
27
|
[Compare v0.3.0...v0.4.0](https://github.com/rom-rb/rom-yesql/compare/v0.3.0...v0.4.0)
|
18
28
|
|
19
|
-
##
|
20
|
-
|
21
|
-
[Compare v0.2.0...v0.3.0](https://github.com/rom-rb/rom-yesql/compare/v0.2.0...v0.3.0)
|
29
|
+
## 0.3.0 2016-07-31
|
22
30
|
|
23
31
|
Updated to work with rom 2.0.0
|
24
32
|
|
25
|
-
|
33
|
+
|
34
|
+
[Compare v0.2.0...v0.3.0](https://github.com/rom-rb/rom-yesql/compare/v0.2.0...v0.3.0)
|
35
|
+
|
36
|
+
## 0.2.0 2015-08-19
|
26
37
|
|
27
38
|
Updated to work with rom 0.9.0
|
28
39
|
|
40
|
+
|
29
41
|
[Compare v0.1.1...v0.2.0](https://github.com/rom-rb/rom-yesql/compare/v0.1.1...v0.2.0)
|
30
42
|
|
31
|
-
##
|
43
|
+
## 0.1.1 2015-07-27
|
44
|
+
|
45
|
+
Updated to work with rom 0.8 (solnic)
|
32
46
|
|
33
47
|
### Changed
|
34
48
|
|
35
|
-
Updated to work with rom 0.8 (solnic)
|
49
|
+
- Updated to work with rom 0.8 (solnic)
|
36
50
|
|
37
51
|
[Compare v0.1.0...v0.1.1](https://github.com/rom-rb/rom-yesql/compare/v0.1.0...v0.1.1)
|
38
52
|
|
39
|
-
##
|
53
|
+
## 0.1.0 2015-03-22
|
40
54
|
|
41
55
|
Bump rom dep to 0.6.0 final
|
42
56
|
|
43
|
-
|
57
|
+
|
58
|
+
[Compare v0.0.2...v0.1.0](https://github.com/rom-rb/rom-yesql/compare/v0.0.2...v0.1.0)
|
59
|
+
|
60
|
+
## 0.0.2 2015-03-21
|
44
61
|
|
45
62
|
Update to work with rom 0.6.0
|
46
63
|
|
47
|
-
|
64
|
+
|
65
|
+
[Compare v0.0.1...v0.0.2](https://github.com/rom-rb/rom-yesql/compare/v0.0.1...v0.0.2)
|
66
|
+
|
67
|
+
## 0.0.1 2015-03-01
|
48
68
|
|
49
69
|
First public release \o/
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.4.0, available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct](https://www.contributor-covenant.org/version/1/4/code-of-conduct)
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Issue Guidelines
|
2
|
+
|
3
|
+
## Reporting bugs
|
4
|
+
|
5
|
+
If you found a bug, report an issue and describe what's the expected behavior versus what actually happens. If the bug causes a crash, attach a full backtrace. If possible, a reproduction script showing the problem is highly appreciated.
|
6
|
+
|
7
|
+
## Reporting feature requests
|
8
|
+
|
9
|
+
Report a feature request **only after discussing it first on [discourse.rom-rb.org](https://discourse.rom-rb.org)** where it was accepted. Please provide a concise description of the feature, don't link to a discussion thread, and instead summarize what was discussed.
|
10
|
+
|
11
|
+
## Reporting questions, support requests, ideas, concerns etc.
|
12
|
+
|
13
|
+
**PLEASE DON'T** - use [discourse.rom-rb.org](http://discourse.rom-rb.org) instead.
|
14
|
+
|
15
|
+
# Pull Request Guidelines
|
16
|
+
|
17
|
+
A Pull Request will only be accepted if it addresses a specific issue that was reported previously, or fixes typos, mistakes in documentation etc.
|
18
|
+
|
19
|
+
Other requirements:
|
20
|
+
|
21
|
+
1) Do not open a pull request if you can't provide tests along with it. If you have problems writing tests, ask for help in the related issue.
|
22
|
+
2) Follow the style conventions of the surrounding code. In most cases, this is standard ruby style.
|
23
|
+
3) Add API documentation if it's a new feature
|
24
|
+
4) Update API documentation if it changes an existing feature
|
25
|
+
5) Bonus points for sending a PR which updates user documentation in the `docsite` directory
|
26
|
+
|
27
|
+
# Asking for help
|
28
|
+
|
29
|
+
If these guidelines aren't helpful, and you're stuck, please post a message on [discourse.rom-rb.org](https://discourse.rom-rb.org) or join [our chat](https://rom-rb.zulipchat.com).
|
data/Gemfile
CHANGED
@@ -1,15 +1,19 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
2
4
|
|
3
5
|
gemspec
|
4
6
|
|
7
|
+
eval_gemfile "Gemfile.devtools"
|
8
|
+
|
5
9
|
group :test do
|
6
|
-
gem
|
7
|
-
gem
|
8
|
-
gem
|
9
|
-
gem
|
10
|
-
gem
|
10
|
+
gem "codeclimate-test-reporter", require: false
|
11
|
+
gem "inflecto"
|
12
|
+
gem "jdbc-sqlite3", platforms: :jruby
|
13
|
+
gem "rspec", "~> 3.5"
|
14
|
+
gem "sqlite3", platforms: %i[mri rbx]
|
11
15
|
end
|
12
16
|
|
13
17
|
group :tools do
|
14
|
-
gem
|
18
|
+
gem "byebug", platforms: [:mri]
|
15
19
|
end
|
data/Gemfile.devtools
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# this file is managed by rom-rb/devtools project
|
4
|
+
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
6
|
+
|
7
|
+
group :test do
|
8
|
+
gem "simplecov", require: false, platforms: :ruby
|
9
|
+
gem "simplecov-cobertura", require: false, platforms: :ruby
|
10
|
+
|
11
|
+
gem "warning" if RUBY_VERSION >= "2.4.0"
|
12
|
+
end
|
13
|
+
|
14
|
+
group :tools do
|
15
|
+
# this is the same version that we use on codacy
|
16
|
+
gem "rubocop", "0.82.0"
|
17
|
+
end
|
data/Guardfile
CHANGED
@@ -1,19 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
group :red_green_refactor, halt_on_fail: true do
|
2
4
|
guard :rspec, cmd: "rspec", all_on_start: true do
|
3
5
|
# run all specs if Gemfile.lock is modified
|
4
|
-
watch(
|
6
|
+
watch("Gemfile.lock") { "spec" }
|
5
7
|
|
6
8
|
# run all specs if any library code is modified
|
7
|
-
watch(%r{\Alib/.+\.rb\z}) {
|
9
|
+
watch(%r{\Alib/.+\.rb\z}) { "spec" }
|
8
10
|
|
9
11
|
# run all specs if supporting files are modified
|
10
|
-
watch(
|
11
|
-
watch(%r{\Aspec/(?:lib|support|shared)/.+\.rb\z}) {
|
12
|
+
watch("spec/spec_helper.rb") { "spec" }
|
13
|
+
watch(%r{\Aspec/(?:lib|support|shared)/.+\.rb\z}) { "spec" }
|
12
14
|
|
13
15
|
# run a spec if it is modified
|
14
16
|
watch(%r{\Aspec/(?:unit|integration)/.+_spec\.rb\z})
|
15
17
|
|
16
|
-
notification :tmux, display_message: true if ENV.key?(
|
18
|
+
notification :tmux, display_message: true if ENV.key?("TMUX")
|
17
19
|
end
|
18
20
|
|
19
21
|
guard :rubocop do
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015-2020 rom-rb team
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
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, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,39 +1,28 @@
|
|
1
1
|
[gem]: https://rubygems.org/gems/rom-yesql
|
2
|
-
[
|
3
|
-
[
|
4
|
-
[
|
2
|
+
[actions]: https://github.com/rom-rb/rom-yesql/actions
|
3
|
+
[codacy]: https://www.codacy.com/gh/rom-rb/rom-yesql
|
4
|
+
[chat]: https://rom-rb.zulipchat.com
|
5
5
|
[inchpages]: http://inch-ci.org/github/rom-rb/rom-yesql
|
6
6
|
|
7
|
-
# rom-yesql
|
7
|
+
# rom-yesql [![Join the chat at https://rom-rb.zulipchat.com](https://img.shields.io/badge/rom--rb-join%20chat-%23346b7a.svg)][chat]
|
8
8
|
|
9
9
|
[![Gem Version](https://badge.fury.io/rb/rom-yesql.svg)][gem]
|
10
|
-
[![
|
11
|
-
[![
|
12
|
-
[![
|
13
|
-
[![Test Coverage](https://codeclimate.com/github/rom-rb/rom-yesql/badges/coverage.svg)][codeclimate]
|
10
|
+
[![CI Status](https://github.com/rom-rb/rom-yesql/workflows/ci/badge.svg)][actions]
|
11
|
+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/88fbb464691e4666b94e0455468b68bf)][codacy]
|
12
|
+
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/88fbb464691e4666b94e0455468b68bf)][codacy]
|
14
13
|
[![Inline docs](http://inch-ci.org/github/rom-rb/rom-yesql.svg?branch=master)][inchpages]
|
15
14
|
|
15
|
+
## Links
|
16
16
|
|
17
|
-
|
17
|
+
* [User documentation](http://rom-rb.org/learn/yesql)
|
18
|
+
* [API documentation](http://rubydoc.info/gems/rom-yesql)
|
18
19
|
|
19
|
-
|
20
|
-
* [ROM user docs](http://rom-rb.org/learn)
|
20
|
+
## Supported Ruby versions
|
21
21
|
|
22
|
-
|
22
|
+
This library officially supports the following Ruby versions:
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
```ruby
|
27
|
-
gem 'rom-yesql'
|
28
|
-
```
|
29
|
-
|
30
|
-
And then execute:
|
31
|
-
|
32
|
-
$ bundle
|
33
|
-
|
34
|
-
Or install it yourself as:
|
35
|
-
|
36
|
-
$ gem install rom-yesql
|
24
|
+
* MRI >= `2.4`
|
25
|
+
* jruby >= `9.2`
|
37
26
|
|
38
27
|
## License
|
39
28
|
|
data/Rakefile
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
3
5
|
|
4
6
|
RSpec::Core::RakeTask.new(:spec)
|
5
7
|
task default: [:ci]
|
6
8
|
|
7
|
-
desc
|
9
|
+
desc "Run CI tasks"
|
8
10
|
task ci: [:spec]
|
data/changelog.yml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
---
|
2
|
+
- version: 1.0.0
|
3
|
+
date: '2020-12-06'
|
4
|
+
summary: Updated to work with rom 6.0.0 (@mrship)
|
5
|
+
- version: 0.5.1
|
6
|
+
date: '2017-03-30'
|
7
|
+
summary: Updated rom dependency (flash-gordon)
|
8
|
+
- version: 0.5.0
|
9
|
+
date: '2017-03-28'
|
10
|
+
summary: Updated to work with rom 3.2.0 (flash-gordon)
|
11
|
+
- version: 0.4.0
|
12
|
+
date: '2017-02-10'
|
13
|
+
summary: Updated to work with rom 3.0.0
|
14
|
+
- version: 0.3.0
|
15
|
+
date: '2016-07-31'
|
16
|
+
summary: Updated to work with rom 2.0.0
|
17
|
+
- version: 0.2.0
|
18
|
+
date: '2015-08-19'
|
19
|
+
summary: Updated to work with rom 0.9.0
|
20
|
+
- version: 0.1.1
|
21
|
+
date: '2015-07-27'
|
22
|
+
changed:
|
23
|
+
- Updated to work with rom 0.8 (solnic)
|
24
|
+
summary: Updated to work with rom 0.8 (solnic)
|
25
|
+
- version: 0.1.0
|
26
|
+
date: '2015-03-22'
|
27
|
+
summary: Bump rom dep to 0.6.0 final
|
28
|
+
- version: 0.0.2
|
29
|
+
date: '2015-03-21'
|
30
|
+
summary: Update to work with rom 0.6.0
|
31
|
+
- version: 0.0.1
|
32
|
+
date: '2015-03-01'
|
33
|
+
summary: First public release \o/
|
data/lib/rom-yesql.rb
CHANGED
data/lib/rom/yesql.rb
CHANGED
data/lib/rom/yesql/dataset.rb
CHANGED
data/lib/rom/yesql/gateway.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "sequel"
|
4
4
|
|
5
|
-
require
|
6
|
-
|
5
|
+
require "rom/initializer"
|
6
|
+
|
7
|
+
require "rom/yesql/dataset"
|
8
|
+
require "rom/yesql/relation"
|
7
9
|
|
8
10
|
module ROM
|
9
11
|
module Yesql
|
@@ -96,7 +98,7 @@ module ROM
|
|
96
98
|
#
|
97
99
|
# @api private
|
98
100
|
def dataset?(_name)
|
99
|
-
|
101
|
+
!@dataset.nil?
|
100
102
|
end
|
101
103
|
|
102
104
|
private
|
@@ -112,7 +114,7 @@ module ROM
|
|
112
114
|
dataset = File.basename(dir).to_sym
|
113
115
|
|
114
116
|
fs_queries[dataset] = Dir["#{dir}/**/*.sql"].each_with_object({}) do |file, ds_queries|
|
115
|
-
query_name = File.basename(file,
|
117
|
+
query_name = File.basename(file, ".*").to_sym
|
116
118
|
sql = File.read(file).strip
|
117
119
|
|
118
120
|
ds_queries[query_name] = sql
|
data/lib/rom/yesql/relation.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require "dry/core/class_attributes"
|
4
|
+
|
5
|
+
require "rom/relation"
|
6
|
+
require "rom/yesql/relation/class_interface"
|
5
7
|
|
6
8
|
module ROM
|
7
9
|
module Yesql
|
@@ -49,7 +51,6 @@ module ROM
|
|
49
51
|
def self.inherited(klass)
|
50
52
|
super
|
51
53
|
klass.extend(ClassInterface)
|
52
|
-
define_query_methods(klass, queries[klass.dataset] || {})
|
53
54
|
end
|
54
55
|
|
55
56
|
# Extends provided klass with query methods
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ROM
|
2
4
|
module Yesql
|
3
5
|
class Relation < ROM::Relation
|
@@ -14,10 +16,9 @@ module ROM
|
|
14
16
|
#
|
15
17
|
# @api public
|
16
18
|
def dataset(name = Undefined)
|
17
|
-
|
18
|
-
@dataset = name
|
19
|
+
name = relation_name.to_sym if name == Undefined
|
19
20
|
define_query_methods(self, Relation.queries[name] || {})
|
20
|
-
|
21
|
+
->(*) { self }
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
data/lib/rom/yesql/version.rb
CHANGED
data/project.yml
ADDED
data/rakelib/rubocop.rake
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
begin
|
2
4
|
require "rubocop/rake_task"
|
3
5
|
|
@@ -8,11 +10,10 @@ begin
|
|
8
10
|
end
|
9
11
|
|
10
12
|
namespace :rubocop do
|
11
|
-
desc
|
13
|
+
desc "Generate a configuration file acting as a TODO list."
|
12
14
|
task :auto_gen_config do
|
13
15
|
exec "bundle exec rubocop --auto-gen-config"
|
14
16
|
end
|
15
17
|
end
|
16
|
-
|
17
|
-
rescue LoadError # rubocop:disable Lint/HandleExceptions
|
18
|
+
rescue LoadError
|
18
19
|
end
|