guard-zeitwerk 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 82747ffd33eb432ab5bee2c369f9f9b16e72e6a69ba9d3ebfd45aff21c714dc3
4
+ data.tar.gz: 527b4cf80c4f18ae56543751a95361399cfbc353e86e33de27e7ed8b0dac5807
5
+ SHA512:
6
+ metadata.gz: e419c692055364711f204ae4bff977864e393949fa3142e3fd3a3b341830e54c2a4ed05cd95ea81b2ff1985efde0e5d63ce80beb8139e0591468d53b6a1ce8fe
7
+ data.tar.gz: 87e191369c6d61ec01a3de37ff45d6b812bec8792d30b5cfe2ebf994ced92f4f57adb05d329a8b472e358d883f3fb3596a7537584c1871099652e567120bef43
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.standard.yml ADDED
@@ -0,0 +1,3 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/testdouble/standard
3
+ ruby_version: 2.6
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-07-24
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders 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, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at bradgessler@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in guard-zeitwerk.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "standard", "~> 1.3"
13
+
14
+ gem "zeitwerk", "~> 2.6", github: "fxn/zeitwerk"
15
+
16
+ gem "guard", "~> 2.18"
data/Gemfile.lock ADDED
@@ -0,0 +1,117 @@
1
+ GIT
2
+ remote: https://github.com/fxn/zeitwerk.git
3
+ revision: 607e162a6086901240e334480ff495cf25acfcd7
4
+ specs:
5
+ zeitwerk (2.6.8)
6
+
7
+ PATH
8
+ remote: .
9
+ specs:
10
+ guard-zeitwerk (0.1.0)
11
+ guard (~> 2.1)
12
+ guard-compat (~> 1.1)
13
+ zeitwerk
14
+
15
+ GEM
16
+ remote: https://rubygems.org/
17
+ specs:
18
+ ast (2.4.2)
19
+ coderay (1.1.3)
20
+ diff-lcs (1.5.0)
21
+ ffi (1.15.5)
22
+ formatador (1.1.0)
23
+ guard (2.18.0)
24
+ formatador (>= 0.2.4)
25
+ listen (>= 2.7, < 4.0)
26
+ lumberjack (>= 1.0.12, < 2.0)
27
+ nenv (~> 0.1)
28
+ notiffany (~> 0.0)
29
+ pry (>= 0.13.0)
30
+ shellany (~> 0.0)
31
+ thor (>= 0.18.1)
32
+ guard-compat (1.2.1)
33
+ json (2.6.3)
34
+ language_server-protocol (3.17.0.3)
35
+ lint_roller (1.1.0)
36
+ listen (3.8.0)
37
+ rb-fsevent (~> 0.10, >= 0.10.3)
38
+ rb-inotify (~> 0.9, >= 0.9.10)
39
+ lumberjack (1.2.9)
40
+ method_source (1.0.0)
41
+ nenv (0.3.0)
42
+ notiffany (0.1.3)
43
+ nenv (~> 0.1)
44
+ shellany (~> 0.0)
45
+ parallel (1.23.0)
46
+ parser (3.2.2.3)
47
+ ast (~> 2.4.1)
48
+ racc
49
+ pry (0.14.2)
50
+ coderay (~> 1.1)
51
+ method_source (~> 1.0)
52
+ racc (1.7.1)
53
+ rainbow (3.1.1)
54
+ rake (13.0.6)
55
+ rb-fsevent (0.11.2)
56
+ rb-inotify (0.10.1)
57
+ ffi (~> 1.0)
58
+ regexp_parser (2.8.1)
59
+ rexml (3.2.5)
60
+ rspec (3.12.0)
61
+ rspec-core (~> 3.12.0)
62
+ rspec-expectations (~> 3.12.0)
63
+ rspec-mocks (~> 3.12.0)
64
+ rspec-core (3.12.2)
65
+ rspec-support (~> 3.12.0)
66
+ rspec-expectations (3.12.3)
67
+ diff-lcs (>= 1.2.0, < 2.0)
68
+ rspec-support (~> 3.12.0)
69
+ rspec-mocks (3.12.6)
70
+ diff-lcs (>= 1.2.0, < 2.0)
71
+ rspec-support (~> 3.12.0)
72
+ rspec-support (3.12.1)
73
+ rubocop (1.52.1)
74
+ json (~> 2.3)
75
+ parallel (~> 1.10)
76
+ parser (>= 3.2.2.3)
77
+ rainbow (>= 2.2.2, < 4.0)
78
+ regexp_parser (>= 1.8, < 3.0)
79
+ rexml (>= 3.2.5, < 4.0)
80
+ rubocop-ast (>= 1.28.0, < 2.0)
81
+ ruby-progressbar (~> 1.7)
82
+ unicode-display_width (>= 2.4.0, < 3.0)
83
+ rubocop-ast (1.29.0)
84
+ parser (>= 3.2.1.0)
85
+ rubocop-performance (1.18.0)
86
+ rubocop (>= 1.7.0, < 2.0)
87
+ rubocop-ast (>= 0.4.0)
88
+ ruby-progressbar (1.13.0)
89
+ shellany (0.0.1)
90
+ standard (1.30.1)
91
+ language_server-protocol (~> 3.17.0.2)
92
+ lint_roller (~> 1.0)
93
+ rubocop (~> 1.52.0)
94
+ standard-custom (~> 1.0.0)
95
+ standard-performance (~> 1.1.0)
96
+ standard-custom (1.0.2)
97
+ lint_roller (~> 1.0)
98
+ rubocop (~> 1.50)
99
+ standard-performance (1.1.2)
100
+ lint_roller (~> 1.1)
101
+ rubocop-performance (~> 1.18.0)
102
+ thor (1.2.2)
103
+ unicode-display_width (2.4.2)
104
+
105
+ PLATFORMS
106
+ arm64-darwin-22
107
+
108
+ DEPENDENCIES
109
+ guard (~> 2.18)
110
+ guard-zeitwerk!
111
+ rake (~> 13.0)
112
+ rspec (~> 3.0)
113
+ standard (~> 1.3)
114
+ zeitwerk (~> 2.6)!
115
+
116
+ BUNDLED WITH
117
+ 2.4.8
data/Guardfile ADDED
@@ -0,0 +1,4 @@
1
+ # Watches all Ruby files in a project.
2
+ guard :zeitwerk, require: "./lib/guard/zeitwerk.rb" do
3
+ watch(/.*\.rb$/)
4
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Brad Gessler
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,45 @@
1
+ # Guard::Zeitwerk
2
+
3
+ Automatically adds the module definitions to blank files, inflected from Zeitwerk. This means if you run `touch ./lib/my-gem/fizz/buzz.rb` and open the file, you'll see:
4
+
5
+ ```ruby
6
+ class MyGem::Fizz::Buzz
7
+ end
8
+ ```
9
+
10
+ Or from your favorite code editor, create a file, save it, reload the file, and your module will be ready for coding. No more boilerplate!
11
+
12
+ > *** Note
13
+ > Future versions of Guard Zeitwerk will allow greater customization for generated files. This initial release focuses on getting the basics out into the world.
14
+
15
+ ## Installation
16
+
17
+ Install the gem and add to the application's Gemfile by executing:
18
+
19
+ $ bundle add guard-zeitwerk
20
+
21
+ Then add to your project's `Guardfile` by running:
22
+
23
+ $ bundle exec guard init rspec
24
+
25
+ ## Limitations
26
+
27
+ Guard Zeitwerk currently does not inflect on whether or not the namespace that's being generated is a class or module. Future releases will likely include the behavior.
28
+
29
+ ## Development
30
+
31
+ 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.
32
+
33
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rubymonolith/guard-zeitwerk. 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/rubymonolith/guard-zeitwerk/blob/main/CODE_OF_CONDUCT.md).
38
+
39
+ ## License
40
+
41
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
42
+
43
+ ## Code of Conduct
44
+
45
+ Everyone interacting in the Guard::Zeitwerk project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rubymonolith/guard-zeitwerk/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "standard/rake"
9
+
10
+ task default: %i[spec standard]
@@ -0,0 +1,7 @@
1
+ # Watches all Ruby files in a project.
2
+ #
3
+ # The `require:` parameter is configured for a Rails project. If using it for
4
+ # a gem, change the require path to whatever loads a Zeitwerk::Autoloader.
5
+ guard :zeitwerk, require: "config/application.rb" do
6
+ watch(/.*\.rb$/)
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Guard
4
+ module ZeitwerkGuard
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "zeitwerk/version"
4
+
5
+ require "guard"
6
+ require "guard/plugin"
7
+ require "zeitwerk"
8
+
9
+ module Guard
10
+ class Zeitwerk < Plugin
11
+ def initialize(options = {})
12
+ super
13
+ require options[:require] if options.key? :require
14
+ end
15
+
16
+ def start
17
+ warn_zero_loaders
18
+ detect_and_initialize_rails
19
+ end
20
+
21
+ def run_all
22
+ # Called when running all Guards
23
+ end
24
+
25
+ def run_on_additions(paths)
26
+ process(paths)
27
+ end
28
+
29
+ def run_on_modifications(paths)
30
+ process(paths)
31
+ end
32
+
33
+ def stop
34
+ # Called when Guard is stopped
35
+ end
36
+
37
+ protected
38
+
39
+ def detect_and_initialize_rails
40
+ Rails.initialize! if defined? Rails and not Rails.initialized?
41
+ end
42
+
43
+ def warn_zero_loaders
44
+ if ::Zeitwerk::Registry.loaders.count.zero?
45
+ UI.info "No Zeitwerk::Loader instances running. Make sure the file specified in the `require:` argument creates Zeitwerk::Loader instances."
46
+ end
47
+ end
48
+
49
+ def process(paths)
50
+ paths.each do |path|
51
+ next unless File.zero?(path)
52
+
53
+ ::Zeitwerk::Registry.loaders.each do |loader|
54
+ namespace = loader.cpath_at(path)
55
+ next if namespace.nil?
56
+
57
+ *constant_names, object_name = namespace.split("::")
58
+ module_name = constant_names.join("::")
59
+
60
+ File.write path, <<~RUBY
61
+ class #{namespace}
62
+ end
63
+ RUBY
64
+
65
+ UI.info "Generated module namespace #{namespace} in #{path}"
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,6 @@
1
+ module Guard
2
+ class Zeitwerk
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-zeitwerk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Brad Gessler
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-07-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: zeitwerk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: guard
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard-compat
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
55
+ description: Create an empty file in a Ruby project and guard-zeitwerk will add the
56
+ module declaration for you.
57
+ email:
58
+ - bradgessler@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".rspec"
64
+ - ".standard.yml"
65
+ - CHANGELOG.md
66
+ - CODE_OF_CONDUCT.md
67
+ - Gemfile
68
+ - Gemfile.lock
69
+ - Guardfile
70
+ - LICENSE.txt
71
+ - README.md
72
+ - Rakefile
73
+ - lib/guard/zeitwerk.rb
74
+ - lib/guard/zeitwerk/templates/Guardfile
75
+ - lib/guard/zeitwerk/version.rb
76
+ - sig/guard/zeitwerk.rbs
77
+ homepage: https://github.com/rubymonolith/guard-zeitwerk
78
+ licenses:
79
+ - MIT
80
+ metadata:
81
+ allowed_push_host: https://rubygems.org/
82
+ homepage_uri: https://github.com/rubymonolith/guard-zeitwerk
83
+ source_code_uri: https://github.com/rubymonolith/guard-zeitwerk
84
+ changelog_uri: https://github.com/rubymonolith/guard-zeitwerk
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: 2.6.0
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubygems_version: 3.4.6
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Adds Ruby module to empty files
104
+ test_files: []