env-hound 0.1.0.pre.pre

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: 905c5e5243d6bbc3c5897ef5e7975609b3849190aa56ec8f767db76b9dccb338
4
+ data.tar.gz: 621ba0ae8a5871e56c73e95f7479feb1d9d29fc56b63ca833f696e3b6a4cff8f
5
+ SHA512:
6
+ metadata.gz: 8b525ffa597ca6727e366f79487c6f03944fd973e1bc45835b993e51d05deea80accadabcc22a9fe7faa388c8c2d5c9b7a2047184620f39035d138c9ac900c35
7
+ data.tar.gz: 3b9ca9fcf08739186c73c31cd74e6b7b99fb2edc3e8058192c793a39910af746f94321fc8c9c994e32a7cf810bc0eb5c83a70756a57e4241d54f13202c1de614
data/.editorconfig ADDED
@@ -0,0 +1,9 @@
1
+ root = true
2
+
3
+ [*]
4
+ end_of_line = lf
5
+ indent_size = 2
6
+ indent_style = space
7
+ insert_final_newline = true
8
+ tab_width = 2
9
+ trim_trailing_whitespace = true
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.4
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.4
6
+ before_install: gem install bundler -v 2.1.4
@@ -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 rostislav.zhuravsky@gmail.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
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,21 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ env-hound (0.1.0.pre.pre)
5
+ dry-cli (~> 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ dry-cli (1.0.0)
11
+ minitest (5.18.0)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ env-hound!
18
+ minitest (~> 5.18)
19
+
20
+ BUNDLED WITH
21
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 woarewe
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
+ # Env::Hound
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/env/hound`. 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 'env-hound'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install env-hound
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/[USERNAME]/env-hound. 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/[USERNAME]/env-hound/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 Env::Hound project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/env-hound/blob/master/CODE_OF_CONDUCT.md).
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "env-hound"
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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/env-hound.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ require_relative 'lib/env_hound/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "env-hound"
5
+ spec.version = EnvHound::VERSION
6
+ spec.authors = ["woarewe"]
7
+ spec.email = ["rostislav.zhuravsky@gmail.com"]
8
+
9
+ spec.summary = %q{SUMMARY}
10
+ spec.description = %q{DESCRIPTION}
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
13
+
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+ spec.add_runtime_dependency 'dry-cli', '~> 1.0'
24
+
25
+ spec.add_development_dependency 'minitest', '~> 5.18'
26
+ end
data/exe/env-hound ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/env-hound"
4
+
5
+ Dry::CLI.new(EnvHound::CLI).call
data/lib/env-hound.rb ADDED
@@ -0,0 +1 @@
1
+ require_relative "env_hound"
@@ -0,0 +1,39 @@
1
+ module EnvHound
2
+ class App
3
+ private_class_method :new
4
+
5
+ attr_reader :scanner, :config, :parser
6
+
7
+ def initialize(scanner:, config:, parser:)
8
+ @scanner = scanner
9
+ @config = config
10
+ @parser = parser
11
+ end
12
+
13
+ def files
14
+ config
15
+ .paths
16
+ .map { |path| scanner.call(glob: path) }
17
+ .flatten
18
+ .uniq
19
+ end
20
+
21
+ def variables
22
+ files
23
+ .map { |file| parser.call(content: File.read(file)) }
24
+ .flatten
25
+ .uniq
26
+ end
27
+
28
+ class << self
29
+ def boot()
30
+ config = Config.from_file()
31
+ new(
32
+ scanner: Scanner.new,
33
+ config: config,
34
+ parser: Parser.new
35
+ )
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,10 @@
1
+ module EnvHound
2
+ module CLI
3
+ class Files < Dry::CLI::Command
4
+ def call(*)
5
+ app = App.boot
6
+ puts app.files
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module EnvHound
2
+ module CLI
3
+ class Test < Dry::CLI::Command
4
+ def call(*)
5
+ config = EnvHound::Config.from_file(EnvHound::Config::DEFAULT_PATH)
6
+ binding.irb
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module EnvHound
2
+ module CLI
3
+ class Variables < Dry::CLI::Command
4
+ def call(*)
5
+ app = App.boot
6
+ puts app.variables
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ module EnvHound
2
+ module CLI
3
+ class Version < Dry::CLI::Command
4
+ def call
5
+ puts VERSION
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,17 @@
1
+ require "dry/cli"
2
+
3
+ module EnvHound
4
+ module CLI
5
+ extend Dry::CLI::Registry
6
+
7
+ require_relative "cli/version"
8
+ require_relative "cli/test"
9
+ require_relative "cli/files"
10
+ require_relative "cli/variables"
11
+
12
+ register "version", Version, aliases: ["v", "-v", "--version"]
13
+ register "test", Test
14
+ register "files", Files
15
+ register "variables", Variables
16
+ end
17
+ end
@@ -0,0 +1,30 @@
1
+ require 'yaml'
2
+
3
+ module EnvHound
4
+ class Config
5
+ DEFAULT_PATH = File.expand_path('config.yml', __dir__)
6
+
7
+ private_class_method :new
8
+
9
+ attr_reader(
10
+ :paths
11
+ )
12
+
13
+ def initialize(paths:)
14
+ @paths = paths
15
+ end
16
+
17
+ class << self
18
+ def build(paths:)
19
+ new(paths: paths)
20
+ end
21
+
22
+ def from_file(path = DEFAULT_PATH)
23
+ config = YAML.load_file(path)
24
+ build(
25
+ paths: config['paths']
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ paths:
2
+ - '**/*.rake'
3
+ - '**/*.rb'
@@ -0,0 +1,21 @@
1
+ module EnvHound
2
+ class Parser
3
+ # TODO: Create a separete list for required and optional env vars
4
+ # fetch() - required
5
+ # [] - optional
6
+ REGEXPS = [
7
+ /ENV\[["'](?<variable>\w+)["']\]/,
8
+ /ENV\.fetch\(["'](?<variable>\w+)["']\)/
9
+ ].freeze
10
+
11
+ def call(content:)
12
+ REGEXPS.map do |regexp|
13
+ content.scan(regexp).map do
14
+ Regexp.last_match[:variable]
15
+ end
16
+ end.flatten.uniq
17
+ end
18
+ end
19
+ end
20
+
21
+ ENV['lol']
@@ -0,0 +1,24 @@
1
+ module EnvHound
2
+ class Scanner
3
+ def call(glob:)
4
+ Dir
5
+ .glob(glob)
6
+ .map { |path| process_path(path) }
7
+ .flatten
8
+ end
9
+
10
+ private
11
+
12
+ def process_path(path)
13
+ return path if File.file?(path)
14
+
15
+ process_dir(path)
16
+ end
17
+
18
+ def process_dir(dir)
19
+ Dir
20
+ .children(dir)
21
+ .map { |path| process_path("#{dir}/#{path}") }
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EnvHound
4
+ VERSION = "0.1.0-pre"
5
+ end
data/lib/env_hound.rb ADDED
@@ -0,0 +1,9 @@
1
+ module EnvHound; end
2
+
3
+ require_relative "env_hound/version"
4
+ require_relative "env_hound/config"
5
+ require_relative "env_hound/scanner"
6
+ require_relative "env_hound/parser"
7
+ require_relative "env_hound/app"
8
+ require_relative "env_hound/cli"
9
+
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: env-hound
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.pre.pre
5
+ platform: ruby
6
+ authors:
7
+ - woarewe
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-05-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dry-cli
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: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.18'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.18'
41
+ description: DESCRIPTION
42
+ email:
43
+ - rostislav.zhuravsky@gmail.com
44
+ executables:
45
+ - env-hound
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".editorconfig"
50
+ - ".gitignore"
51
+ - ".ruby-version"
52
+ - ".travis.yml"
53
+ - CODE_OF_CONDUCT.md
54
+ - Gemfile
55
+ - Gemfile.lock
56
+ - LICENSE.txt
57
+ - README.md
58
+ - bin/console
59
+ - bin/setup
60
+ - env-hound.gemspec
61
+ - exe/env-hound
62
+ - lib/env-hound.rb
63
+ - lib/env_hound.rb
64
+ - lib/env_hound/app.rb
65
+ - lib/env_hound/cli.rb
66
+ - lib/env_hound/cli/files.rb
67
+ - lib/env_hound/cli/test.rb
68
+ - lib/env_hound/cli/variables.rb
69
+ - lib/env_hound/cli/version.rb
70
+ - lib/env_hound/config.rb
71
+ - lib/env_hound/config.yml
72
+ - lib/env_hound/parser.rb
73
+ - lib/env_hound/scanner.rb
74
+ - lib/env_hound/version.rb
75
+ homepage:
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: 2.5.0
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">"
91
+ - !ruby/object:Gem::Version
92
+ version: 1.3.1
93
+ requirements: []
94
+ rubygems_version: 3.1.6
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: SUMMARY
98
+ test_files: []