scopedog 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/.github/workflows/ci.yml +29 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/scopedog.rb +24 -0
- data/lib/scopedog/directives.rb +4 -0
- data/lib/scopedog/directives/base.rb +63 -0
- data/lib/scopedog/directives/paranoid_directive.rb +23 -0
- data/lib/scopedog/directives/record_directive.rb +8 -0
- data/lib/scopedog/directives/scoping_directive.rb +19 -0
- data/lib/scopedog/exporters/bigquery_exporter.rb +4 -0
- data/lib/scopedog/exporters/markdown_exporter.rb +57 -0
- data/lib/scopedog/railtie.rb +9 -0
- data/lib/scopedog/record_class.rb +88 -0
- data/lib/scopedog/version.rb +3 -0
- data/lib/tasks/export.rake +26 -0
- data/scopedog.gemspec +42 -0
- metadata +222 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3a672c3d3d200250a74efdc0a7c8cf1d7063b5b7a4ef56a6318f9abb27344ec8
|
4
|
+
data.tar.gz: 1587b1a8e5c97c16532dca31f93cb2388aad884b590a6a797eb842b910bb81d6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 78adf6f98247b6423009fdecc1c450a5e6ea856e8127c49ec42755a14a7f9a3c5520aa5501df1a2532bba02409e244f5d096427d17ccdd590ae493060760a304
|
7
|
+
data.tar.gz: 555a0332be5e01ce31e0732c2cfbc723659a3c5b2691480602d3c4ef391b2309b45adb986f3d12bd8f1458645e44f5cb0953e340aa74ee6d81de757b27f30553
|
@@ -0,0 +1,29 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
os: [ ubuntu-latest, macos-latest ]
|
12
|
+
ruby: [ 2.5, 2.6, 2.7 ]
|
13
|
+
runs-on: ${{ matrix.os }}
|
14
|
+
|
15
|
+
steps:
|
16
|
+
- uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: ${{ matrix.ruby }}
|
19
|
+
|
20
|
+
- run: sudo apt-get install libsqlite3-dev
|
21
|
+
if: matrix.os == 'ubuntu-latest'
|
22
|
+
|
23
|
+
- run: gem install bundler -v 2.1.4
|
24
|
+
|
25
|
+
- uses: actions/checkout@v2
|
26
|
+
|
27
|
+
- run: bundle install --jobs 4 --retry 3
|
28
|
+
|
29
|
+
- run: bundle exec rspec
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.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 m@izum.in. 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
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 izumin5210
|
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,43 @@
|
|
1
|
+
# Scopedog
|
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/scopedog`. 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 'scopedog'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install scopedog
|
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/izumin5210/scopedog. 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
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the Scopedog project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/izumin5210/scopedog/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 "scopedog"
|
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/lib/scopedog.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "scopedog/version"
|
2
|
+
|
3
|
+
module Scopedog
|
4
|
+
class Error < StandardError; end
|
5
|
+
|
6
|
+
def self.logger
|
7
|
+
@logger ||= ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT))
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.logger=(logger)
|
11
|
+
@logger = logger
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
require "yard"
|
16
|
+
require "scopedog/directives"
|
17
|
+
require "scopedog/record_class"
|
18
|
+
require "scopedog/exporters/markdown_exporter"
|
19
|
+
|
20
|
+
begin
|
21
|
+
require "scopedog/railtie"
|
22
|
+
rescue LoadError
|
23
|
+
# no-op
|
24
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'active_support/core_ext/string/inflections'
|
2
|
+
|
3
|
+
module Scopedog::Directives
|
4
|
+
# @abstract
|
5
|
+
class Base < YARD::Tags::Directive
|
6
|
+
class << self
|
7
|
+
attr_accessor :abstract_class
|
8
|
+
|
9
|
+
def abstract_class?
|
10
|
+
defined?(@abstract_class) && @abstraact_class == true
|
11
|
+
end
|
12
|
+
|
13
|
+
def inherited(klass)
|
14
|
+
return if klass.abstract_class?
|
15
|
+
|
16
|
+
YARD::Tags::Library.define_directive klass.directive_name, :with_name, klass
|
17
|
+
end
|
18
|
+
|
19
|
+
def directive_name
|
20
|
+
name.demodulize.underscore.gsub(/_directive$/, '')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
self.abstract_class = true
|
25
|
+
|
26
|
+
# @!override YARD::Tags::Directive#after_parse
|
27
|
+
def call; end
|
28
|
+
|
29
|
+
protected
|
30
|
+
|
31
|
+
def add_method!(name = nil, tags: [])
|
32
|
+
name = handler.call_params.first if name.nil?
|
33
|
+
|
34
|
+
obj = create_method_object(name)
|
35
|
+
visibility = parser.state.visibility || handler.visibility
|
36
|
+
|
37
|
+
handler.register_file_info(obj)
|
38
|
+
handler.register_source(obj)
|
39
|
+
handler.register_visibility(obj, visibility)
|
40
|
+
handler.register_group(obj)
|
41
|
+
handler.register_module_function(obj)
|
42
|
+
|
43
|
+
old_obj = parser.object
|
44
|
+
parser.object = obj
|
45
|
+
parser.post_process
|
46
|
+
parser.object = old_obj
|
47
|
+
obj
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [YARD::CodeObjects::MethodObject]
|
51
|
+
def create_method_object(name)
|
52
|
+
scope = parser.state.scope || handler.scope
|
53
|
+
ns = YARD::CodeObjects::NamespaceObject === object ? object : handler.namespace
|
54
|
+
signature = "def #{tag.name}"
|
55
|
+
|
56
|
+
YARD::CodeObjects::MethodObject.new(ns, name, scope).tap do |obj|
|
57
|
+
obj.signature = signature
|
58
|
+
obj.parameters = YARD::Tags::OverloadTag.new(:overload, signature).parameters
|
59
|
+
obj.docstring = YARD::Docstring.new!(parser.text, parser.tags, obj, parser.raw_text, parser.reference)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Scopedog::Directives
|
2
|
+
class ParanoidDirective < Base
|
3
|
+
# @!override YARD::Tags::Directive#after_parse
|
4
|
+
def after_parse
|
5
|
+
parser.state.scope = :class
|
6
|
+
name = tag.name
|
7
|
+
|
8
|
+
add_method! "only_#{name}"
|
9
|
+
add_method! "with_#{name}"
|
10
|
+
add_method! "without_#{name}"
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
# @!override Scopedog::BaseDirective#create_method_object
|
16
|
+
def create_method_object(name)
|
17
|
+
super.tap do |obj|
|
18
|
+
obj.group = 'Scopes'
|
19
|
+
obj.add_tag YARD::Tags::Tag.new(:scoping, '', nil, name)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Scopedog::Directives
|
2
|
+
class ScopingDirective < Base
|
3
|
+
# @!override YARD::Tags::Directive#after_parse
|
4
|
+
def after_parse
|
5
|
+
parser.state.scope = :class
|
6
|
+
add_method!
|
7
|
+
end
|
8
|
+
|
9
|
+
protected
|
10
|
+
|
11
|
+
# @!override Scopedog::BaseDirective#create_method_object
|
12
|
+
def create_method_object(name)
|
13
|
+
super.tap do |obj|
|
14
|
+
obj.group = 'Scopes'
|
15
|
+
obj.add_tag YARD::Tags::Tag.new(:scoping, '', nil, handler.call_params.first)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Scopedog::Exporters
|
2
|
+
class MarkdownExporter
|
3
|
+
# @param opts [Hash]
|
4
|
+
# @option opts [String] :dir
|
5
|
+
def initialize(opts = {})
|
6
|
+
@dir = opts[:dir]
|
7
|
+
end
|
8
|
+
|
9
|
+
# @param record_class [Scopedog::RecordClass]
|
10
|
+
# @param dest [Hash]
|
11
|
+
# @option dest [String] :prefix
|
12
|
+
# @option dest [String] :name
|
13
|
+
def export(record_class, destination = {})
|
14
|
+
name = destination[:name] || record_class.name.to_s.underscore
|
15
|
+
name = "#{name}.md" unless File.extname(name) == '.md'
|
16
|
+
|
17
|
+
dir = @dir
|
18
|
+
dir = File.join(dir, destination[:prefix]) if destination[:prefix]
|
19
|
+
|
20
|
+
if name.include? '/'
|
21
|
+
name, prefix = name.split('/').yield_self { |p| [p[-1], p[0..-2]] }
|
22
|
+
dir = File.join(dir, prefix)
|
23
|
+
end
|
24
|
+
|
25
|
+
FileUtils.mkdir_p(dir) unless File.exists?(dir)
|
26
|
+
|
27
|
+
File.open(File.join(dir, name), 'w') do |f|
|
28
|
+
f.puts <<~MARKDOWN
|
29
|
+
# #{record_class.name}
|
30
|
+
#{record_class.docstring}
|
31
|
+
|
32
|
+
```sql
|
33
|
+
-- default scope
|
34
|
+
#{record_class.default_sql}
|
35
|
+
```
|
36
|
+
MARKDOWN
|
37
|
+
|
38
|
+
unless record_class.scopes.empty?
|
39
|
+
f.puts
|
40
|
+
f.puts "## Scopes"
|
41
|
+
|
42
|
+
record_class.scopes.each do |s|
|
43
|
+
f.puts
|
44
|
+
f.puts <<~MARKDOWN
|
45
|
+
### `#{s.name}`
|
46
|
+
#{s.docstring}
|
47
|
+
|
48
|
+
```sql
|
49
|
+
#{s.sql}
|
50
|
+
```
|
51
|
+
MARKDOWN
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
|
3
|
+
module Scopedog
|
4
|
+
# @attr_reader yard_obj [YARD::CodeObjects::ClassObject]
|
5
|
+
# @attr_reader ar_class [Class<ActiveRecord::Base>]
|
6
|
+
class RecordClass
|
7
|
+
attr_reader :yard_obj, :ar_class
|
8
|
+
|
9
|
+
# @param docs [Array<YARD::CodeObjects::Base>]
|
10
|
+
# @return [Array<RecordClass>]
|
11
|
+
def self.all(docs: YARD::Registry.all, root_const: Object)
|
12
|
+
docs
|
13
|
+
.select { |d| d.type == :class && d.has_tag?(:record) }
|
14
|
+
.each { |d| require_relative d.file if d.file != '(stdin)' }
|
15
|
+
.map { |d| [d, root_const.const_get(d.path)] }
|
16
|
+
.select { |(_, c)| c.ancestors.include?(ActiveRecord::Base) && !c.abstract_class? }
|
17
|
+
.map { |d, c| RecordClass.new(d, c, root_const: root_const) }
|
18
|
+
end
|
19
|
+
|
20
|
+
# @param yard_obj [YARD::CodeObjects::ClassObject]
|
21
|
+
# @param ar_class [Class<ActiveRecord::Base>]
|
22
|
+
def initialize(yard_obj, ar_class, root_const: Object)
|
23
|
+
@yard_obj = yard_obj
|
24
|
+
@ar_class = ar_class
|
25
|
+
@root_const = root_const
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [String]
|
29
|
+
def name
|
30
|
+
ar_class.name.gsub(/^#{@root_const.name}::/, '')
|
31
|
+
end
|
32
|
+
|
33
|
+
# @return [String]
|
34
|
+
def docstring
|
35
|
+
yard_obj.docstring
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [String]
|
39
|
+
def table_name
|
40
|
+
ar_class.table_name
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [Array<YARD::CodeObjects::MethodObject>]
|
44
|
+
def scopes
|
45
|
+
@scopes ||= yard_obj.meths
|
46
|
+
.select { |m| m.has_tag?(:scoping) }
|
47
|
+
.map { |m| Scope.new(self, m) }
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [String]
|
51
|
+
def default_sql
|
52
|
+
ar_class.all.to_sql
|
53
|
+
end
|
54
|
+
|
55
|
+
# @return [String]
|
56
|
+
def unscoped_sql
|
57
|
+
ar_class.all.unscoped.to_sql
|
58
|
+
end
|
59
|
+
|
60
|
+
# @attr_reader record_class [Scopedog::RecordClass]
|
61
|
+
# @attr_reader yard_obj [YARD::CodeObjects::MethodObject]
|
62
|
+
class Scope
|
63
|
+
attr_reader :yard_obj, :record_class
|
64
|
+
|
65
|
+
# @param record_class [Scopedog::RecordClass]
|
66
|
+
# @param meth [YARD::CodeObjects::MethodObject]
|
67
|
+
def initialize(record_class, yard_obj)
|
68
|
+
@record_class = record_class
|
69
|
+
@yard_obj = yard_obj
|
70
|
+
end
|
71
|
+
|
72
|
+
# @return [String]
|
73
|
+
def name
|
74
|
+
yard_obj.name
|
75
|
+
end
|
76
|
+
|
77
|
+
# @return [String]
|
78
|
+
def docstring
|
79
|
+
yard_obj.docstring
|
80
|
+
end
|
81
|
+
|
82
|
+
# @return [String]
|
83
|
+
def sql
|
84
|
+
record_class.ar_class.send(name).to_sql
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
namespace :scopedog do
|
2
|
+
namespace :export do
|
3
|
+
desc "Export ActiveRecord models as markdown"
|
4
|
+
task markdown: :environment do
|
5
|
+
path =
|
6
|
+
if defined? Rails
|
7
|
+
Rails.root.join('app', 'models', '**', '*.rb').to_s
|
8
|
+
else
|
9
|
+
File.join('lib', '**', '*.rb').to_s
|
10
|
+
end
|
11
|
+
|
12
|
+
Scopedog.logger.debug "Parsing #{path}"
|
13
|
+
YARD.parse path
|
14
|
+
|
15
|
+
record_classes = Scopedog::RecordClass.all
|
16
|
+
Scopedog.logger.debug "#{record_classes.size} record classes are found"
|
17
|
+
|
18
|
+
exporter = Scopedog::Exporters::MarkdownExporter.new(dir: 'docs')
|
19
|
+
|
20
|
+
record_classes.each do |record_class|
|
21
|
+
Scopedog.logger.debug "Export #{record_class.name}"
|
22
|
+
exporter.export(record_class)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/scopedog.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "scopedog/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "scopedog"
|
7
|
+
spec.version = Scopedog::VERSION
|
8
|
+
spec.authors = ["izumin5210"]
|
9
|
+
spec.email = ["m@izum.in"]
|
10
|
+
|
11
|
+
spec.summary = %q{Democratize ActiveRecord's scopes}
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = "https://github.comm/izumin5210/scopedog"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
18
|
+
spec.metadata["changelog_uri"] = spec.homepage
|
19
|
+
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
rails_versions = ['>= 5.2', '< 6.1']
|
31
|
+
spec.add_runtime_dependency 'activerecord', rails_versions
|
32
|
+
spec.add_runtime_dependency 'activesupport', rails_versions
|
33
|
+
spec.add_runtime_dependency 'yard', '~> 0.9'
|
34
|
+
spec.add_runtime_dependency "rake", "~> 10.0"
|
35
|
+
|
36
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
38
|
+
spec.add_development_dependency "onkcop", "~> 0.53"
|
39
|
+
spec.add_development_dependency "sqlite3", "~> 1.4"
|
40
|
+
spec.add_development_dependency "rspec-cheki", "~> 0.1.0"
|
41
|
+
spec.add_development_dependency "paranoia", "~> 2.4"
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,222 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: scopedog
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- izumin5210
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-02-16 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: '5.2'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '6.1'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '5.2'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '6.1'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: activesupport
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '5.2'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '6.1'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '5.2'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '6.1'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: yard
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0.9'
|
60
|
+
type: :runtime
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0.9'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rake
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '10.0'
|
74
|
+
type: :runtime
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '10.0'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: bundler
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '2.0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '2.0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rspec
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '3.0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '3.0'
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: onkcop
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0.53'
|
116
|
+
type: :development
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0.53'
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: sqlite3
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '1.4'
|
130
|
+
type: :development
|
131
|
+
prerelease: false
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - "~>"
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '1.4'
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: rspec-cheki
|
139
|
+
requirement: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - "~>"
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: 0.1.0
|
144
|
+
type: :development
|
145
|
+
prerelease: false
|
146
|
+
version_requirements: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - "~>"
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: 0.1.0
|
151
|
+
- !ruby/object:Gem::Dependency
|
152
|
+
name: paranoia
|
153
|
+
requirement: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - "~>"
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '2.4'
|
158
|
+
type: :development
|
159
|
+
prerelease: false
|
160
|
+
version_requirements: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - "~>"
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '2.4'
|
165
|
+
description: Democratize ActiveRecord's scopes
|
166
|
+
email:
|
167
|
+
- m@izum.in
|
168
|
+
executables: []
|
169
|
+
extensions: []
|
170
|
+
extra_rdoc_files: []
|
171
|
+
files:
|
172
|
+
- ".github/workflows/ci.yml"
|
173
|
+
- ".gitignore"
|
174
|
+
- ".rspec"
|
175
|
+
- ".rubocop.yml"
|
176
|
+
- CODE_OF_CONDUCT.md
|
177
|
+
- Gemfile
|
178
|
+
- LICENSE.txt
|
179
|
+
- README.md
|
180
|
+
- Rakefile
|
181
|
+
- bin/console
|
182
|
+
- bin/setup
|
183
|
+
- lib/scopedog.rb
|
184
|
+
- lib/scopedog/directives.rb
|
185
|
+
- lib/scopedog/directives/base.rb
|
186
|
+
- lib/scopedog/directives/paranoid_directive.rb
|
187
|
+
- lib/scopedog/directives/record_directive.rb
|
188
|
+
- lib/scopedog/directives/scoping_directive.rb
|
189
|
+
- lib/scopedog/exporters/bigquery_exporter.rb
|
190
|
+
- lib/scopedog/exporters/markdown_exporter.rb
|
191
|
+
- lib/scopedog/railtie.rb
|
192
|
+
- lib/scopedog/record_class.rb
|
193
|
+
- lib/scopedog/version.rb
|
194
|
+
- lib/tasks/export.rake
|
195
|
+
- scopedog.gemspec
|
196
|
+
homepage: https://github.comm/izumin5210/scopedog
|
197
|
+
licenses:
|
198
|
+
- MIT
|
199
|
+
metadata:
|
200
|
+
homepage_uri: https://github.comm/izumin5210/scopedog
|
201
|
+
source_code_uri: https://github.comm/izumin5210/scopedog
|
202
|
+
changelog_uri: https://github.comm/izumin5210/scopedog
|
203
|
+
post_install_message:
|
204
|
+
rdoc_options: []
|
205
|
+
require_paths:
|
206
|
+
- lib
|
207
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
208
|
+
requirements:
|
209
|
+
- - ">="
|
210
|
+
- !ruby/object:Gem::Version
|
211
|
+
version: '0'
|
212
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
|
+
requirements:
|
214
|
+
- - ">="
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
version: '0'
|
217
|
+
requirements: []
|
218
|
+
rubygems_version: 3.0.3
|
219
|
+
signing_key:
|
220
|
+
specification_version: 4
|
221
|
+
summary: Democratize ActiveRecord's scopes
|
222
|
+
test_files: []
|