boothby 0.1.1

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.
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boothby
4
+ # Read YAML files
5
+ class YAMLReader
6
+ attr_reader :filename
7
+
8
+ def initialize(name)
9
+ @filename = file_name(name)
10
+ end
11
+
12
+ def get(*attributes, environment: nil)
13
+ environment ||= Rails.env
14
+ full_config[environment].dig(*attributes) || full_config.dig(*attributes)
15
+ end
16
+
17
+ def method_missing(method_name, *args, **kwargs, &block)
18
+ env = kwargs.delete(:environment) || kwargs.delete(:env)
19
+ return get(method_name, environment: env) unless env.nil?
20
+
21
+ cfg = full_config.fetch(method_name, nil)
22
+ return (args.empty? ? cfg : cfg.dig(*args)) unless cfg.nil?
23
+
24
+ get(method_name) || super
25
+ end
26
+
27
+ private def full_config
28
+ return unless config_exist?
29
+
30
+ @full_config ||= begin
31
+ content = File.read(@filename)
32
+ content = ERB.new(content).result if erb_file?
33
+ yml = YAML.safe_load(content, [Time, Date], aliases: true)
34
+ yml.with_indifferent_access
35
+ end
36
+ end
37
+
38
+ private def config_exist?
39
+ @filename.present?
40
+ end
41
+
42
+ private def erb_file?
43
+ @filename.to_s.ends_with?('.erb')
44
+ end
45
+
46
+ private def file_name(name)
47
+ return name if yml_file?(name) && absolute_path?(name)
48
+ return Rails.root.join(name) if yml_file?(name)
49
+
50
+ name = Rails.root.join("config/#{name.to_s.downcase.underscore}").to_s unless absolute_path?(name)
51
+
52
+ find_file(name)
53
+ end
54
+
55
+ private def possible_file_extensions
56
+ %w[yml yaml yml.erb yaml.erb]
57
+ end
58
+
59
+ private def yml_file?(file)
60
+ extension(file).in?(possible_file_extensions)
61
+ end
62
+
63
+ private def extension(file)
64
+ File.basename(file.to_s).split('.').drop(1).try(:join, '.')
65
+ end
66
+
67
+ private def absolute_path?(file)
68
+ file.start_with?(Rails.root.to_s)
69
+ end
70
+
71
+ private def find_file(prefix)
72
+ possible_file_extensions.map { |ext| "#{prefix}.#{ext}" }.find do |file|
73
+ File.exist?(file)
74
+ end
75
+ end
76
+ end
77
+ end
data/lib/boothby.rb ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'boothby/version'
4
+ require 'fileutils'
5
+ require 'active_support/core_ext/object/blank'
6
+ require 'active_support/core_ext/object/try'
7
+ require 'active_support/core_ext/class/attribute'
8
+ require 'active_support/concern'
9
+
10
+ module Boothby
11
+ class Error < StandardError; end
12
+
13
+ class << self
14
+ attr_accessor :root
15
+ end
16
+
17
+ def self.configure(&block)
18
+ Boothby::Configuration.configure(&block)
19
+ end
20
+ end
@@ -0,0 +1,10 @@
1
+ {
2
+ "systemParams": "darwin-x64-83",
3
+ "modulesFolders": [],
4
+ "flags": [],
5
+ "linkedModules": [],
6
+ "topLevelPatterns": [],
7
+ "lockfileEntries": {},
8
+ "files": [],
9
+ "artifacts": {}
10
+ }
data/sig/boothby.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Boothby
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
data/yarn.lock ADDED
@@ -0,0 +1,4 @@
1
+ # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
+ # yarn lockfile v1
3
+
4
+
metadata ADDED
@@ -0,0 +1,181 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: boothby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Christopher Hagmann
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-05-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
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: pastel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: tty-spinner
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: tty-command
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '5.2'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '5.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Groundskeeper to manage your rails application
112
+ email:
113
+ - cdhagmann@gmail.com
114
+ executables:
115
+ - boothby
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".rspec"
120
+ - ".rubocop.yml"
121
+ - Gemfile
122
+ - Gemfile.lock
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - boothby.gemspec
127
+ - config/database.yml
128
+ - config/initializers/boothby.rb
129
+ - db/seeds.yml
130
+ - docs/CHANGELOG.md
131
+ - docs/CODE_OF_CONDUCT.md
132
+ - docs/_config.yml
133
+ - docs/index.md
134
+ - exe/boothby
135
+ - lib/boothby.rb
136
+ - lib/boothby/base.rb
137
+ - lib/boothby/cli.rb
138
+ - lib/boothby/command.rb
139
+ - lib/boothby/commands/seed.rb
140
+ - lib/boothby/commands/setup.rb
141
+ - lib/boothby/commands/update.rb
142
+ - lib/boothby/configuration.rb
143
+ - lib/boothby/key_ring.rb
144
+ - lib/boothby/maintenance.rb
145
+ - lib/boothby/seeds.rb
146
+ - lib/boothby/templates/.gitkeep
147
+ - lib/boothby/templates/seed/.gitkeep
148
+ - lib/boothby/templates/setup/.gitkeep
149
+ - lib/boothby/templates/update/.gitkeep
150
+ - lib/boothby/version.rb
151
+ - lib/boothby/yaml_reader.rb
152
+ - node_modules/.yarn-integrity
153
+ - sig/boothby.rbs
154
+ - yarn.lock
155
+ homepage: https://cdhagmann.com/Boothby
156
+ licenses:
157
+ - MIT
158
+ metadata:
159
+ homepage_uri: https://cdhagmann.com/Boothby
160
+ source_code_uri: https://github.com/cdhagmann/Boothby
161
+ changelog_uri: https://cdhagmann.com/Boothby/CHANGELOG.html
162
+ post_install_message:
163
+ rdoc_options: []
164
+ require_paths:
165
+ - lib
166
+ required_ruby_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: 2.7.0
171
+ required_rubygems_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ requirements: []
177
+ rubygems_version: 3.1.6
178
+ signing_key:
179
+ specification_version: 4
180
+ summary: Groundskeeper to manage your rails application
181
+ test_files: []