way_of_working 1.0.0 → 2.0.0

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/CODE_OF_CONDUCT.md +2 -2
  4. data/README.md +53 -55
  5. data/exe/way_of_working +1 -1
  6. data/lib/tasks/audit_gems.rake +2 -2
  7. data/lib/way_of_working/cli.rb +11 -115
  8. data/lib/way_of_working/configuration.rb +18 -0
  9. data/lib/way_of_working/git/repo_reader.rb +1 -3
  10. data/lib/way_of_working/paths.rb +5 -2
  11. data/lib/way_of_working/readme_badge/generators/init.rb +54 -0
  12. data/lib/way_of_working/readme_badge/github_audit_rule.rb +27 -0
  13. data/lib/way_of_working/readme_badge/paths.rb +18 -0
  14. data/lib/way_of_working/readme_badge/templates/README.md +3 -0
  15. data/lib/way_of_working/readme_badge/templates/docs/way_of_working/readme-badges.md.tt +24 -0
  16. data/lib/way_of_working/readme_badge.rb +31 -0
  17. data/lib/way_of_working/sub_commands/base.rb +20 -0
  18. data/lib/way_of_working/sub_commands/exec.rb +11 -0
  19. data/lib/way_of_working/sub_commands/init.rb +17 -0
  20. data/lib/way_of_working/sub_commands/new.rb +11 -0
  21. data/lib/way_of_working/tasks.rb +1 -1
  22. data/lib/way_of_working/version.rb +1 -1
  23. data/lib/way_of_working.rb +18 -4
  24. data/way_of_working.gemspec +4 -1
  25. metadata +60 -23
  26. data/lib/way_of_working/generators/changelog/init.rb +0 -110
  27. data/lib/way_of_working/generators/code_of_conduct/init.rb +0 -32
  28. data/lib/way_of_working/generators/decision_record/init.rb +0 -29
  29. data/lib/way_of_working/generators/decision_record/new.rb +0 -67
  30. data/lib/way_of_working/generators/linter/exec.rb +0 -77
  31. data/lib/way_of_working/generators/linter/init.rb +0 -60
  32. data/lib/way_of_working/generators/rake_tasks/init.rb +0 -47
  33. data/lib/way_of_working/sub_command_base.rb +0 -16
  34. data/lib/way_of_working/templates/.github/linters/.markdown-link-check.json +0 -13
  35. data/lib/way_of_working/templates/.github/linters/rubocop_defaults.yml +0 -55
  36. data/lib/way_of_working/templates/.github/workflows/mega-linter.yml +0 -82
  37. data/lib/way_of_working/templates/.mega-linter.yml +0 -129
  38. data/lib/way_of_working/templates/.rubocop +0 -1
  39. data/lib/way_of_working/templates/CODE_OF_CONDUCT.md.tt +0 -134
  40. data/lib/way_of_working/templates/docs/decisions/README.md +0 -7
  41. data/lib/way_of_working/templates/docs/decisions/adr-template.md.tt +0 -79
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # require 'ndr_dev_support/tasks'
3
+ require 'ndr_dev_support/tasks'
4
4
  require 'rubocop/rake_task'
5
5
 
6
6
  RuboCop::RakeTask.new
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WayOfWorking
4
- VERSION = '1.0.0'
4
+ VERSION = '2.0.0'
5
5
  end
@@ -1,10 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'thor'
4
- require_relative 'way_of_working/cli'
5
- require_relative 'way_of_working/paths'
6
- require_relative 'way_of_working/version'
3
+ require 'way_of_working/cli'
4
+ require 'way_of_working/paths'
5
+ require 'zeitwerk'
7
6
 
7
+ # Require "internal" plugin(s) here
8
+ require 'way_of_working/readme_badge'
9
+
10
+ loader = Zeitwerk::Loader.for_gem
11
+ loader.setup
12
+
13
+ # This is the namespace for everything associated with the Way of Working
8
14
  module WayOfWorking
9
15
  class Error < StandardError; end
10
16
  end
17
+
18
+ # Automatically load way_of_working plugins.
19
+ Gem::Specification.
20
+ select { |gemspec| gemspec.name =~ /\Away_of_working-/ }.
21
+ collect(&:name).uniq. # multiple versions of a single gem may be installed at once
22
+ each do |name|
23
+ require "#{name.gsub('-', '/')}/plugin"
24
+ end
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
26
  spec.files = Dir.chdir(__dir__) do
27
27
  `git ls-files -z`.split("\x0").select do |f|
28
- f.match(%r{\A(?:(?:exe|lib)/|[^/]+\.(?:gemspec|md|txt))})
28
+ f.match(%r{\A(?:(?:exe|lib)/|[^/]+\.(?:gemspec|md|tt|txt))})
29
29
  end
30
30
  end
31
31
  spec.bindir = 'exe'
@@ -37,7 +37,10 @@ Gem::Specification.new do |spec|
37
37
 
38
38
  # For more information and examples about making a new gem, check out our
39
39
  # guide at: https://bundler.io/guides/creating_gem.html
40
+ spec.add_dependency 'activesupport'
40
41
  spec.add_dependency 'git', '~> 1.13'
42
+ spec.add_dependency 'nokogiri'
41
43
  spec.add_dependency 'rainbow', '~> 3.1'
42
44
  spec.add_dependency 'thor', '~> 1.2'
45
+ spec.add_dependency 'zeitwerk', '~> 2.6.18'
43
46
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: way_of_working
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Gentry
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-17 00:00:00.000000000 Z
11
+ date: 2024-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
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'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: git
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -24,6 +38,20 @@ dependencies:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
40
  version: '1.13'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
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'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: rainbow
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -52,7 +80,21 @@ dependencies:
52
80
  - - "~>"
53
81
  - !ruby/object:Gem::Version
54
82
  version: '1.2'
55
- description:
83
+ - !ruby/object:Gem::Dependency
84
+ name: zeitwerk
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 2.6.18
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 2.6.18
97
+ description:
56
98
  email:
57
99
  - 52189+timgentry@users.noreply.github.com
58
100
  executables:
@@ -68,26 +110,21 @@ files:
68
110
  - lib/tasks/audit_gems.rake
69
111
  - lib/way_of_working.rb
70
112
  - lib/way_of_working/cli.rb
71
- - lib/way_of_working/generators/changelog/init.rb
72
- - lib/way_of_working/generators/code_of_conduct/init.rb
73
- - lib/way_of_working/generators/decision_record/init.rb
74
- - lib/way_of_working/generators/decision_record/new.rb
75
- - lib/way_of_working/generators/linter/exec.rb
76
- - lib/way_of_working/generators/linter/init.rb
77
- - lib/way_of_working/generators/rake_tasks/init.rb
113
+ - lib/way_of_working/configuration.rb
78
114
  - lib/way_of_working/git/repo_reader.rb
79
115
  - lib/way_of_working/git/summary_tag.rb
80
116
  - lib/way_of_working/paths.rb
81
- - lib/way_of_working/sub_command_base.rb
117
+ - lib/way_of_working/readme_badge.rb
118
+ - lib/way_of_working/readme_badge/generators/init.rb
119
+ - lib/way_of_working/readme_badge/github_audit_rule.rb
120
+ - lib/way_of_working/readme_badge/paths.rb
121
+ - lib/way_of_working/readme_badge/templates/README.md
122
+ - lib/way_of_working/readme_badge/templates/docs/way_of_working/readme-badges.md.tt
123
+ - lib/way_of_working/sub_commands/base.rb
124
+ - lib/way_of_working/sub_commands/exec.rb
125
+ - lib/way_of_working/sub_commands/init.rb
126
+ - lib/way_of_working/sub_commands/new.rb
82
127
  - lib/way_of_working/tasks.rb
83
- - lib/way_of_working/templates/.github/linters/.markdown-link-check.json
84
- - lib/way_of_working/templates/.github/linters/rubocop_defaults.yml
85
- - lib/way_of_working/templates/.github/workflows/mega-linter.yml
86
- - lib/way_of_working/templates/.mega-linter.yml
87
- - lib/way_of_working/templates/.rubocop
88
- - lib/way_of_working/templates/CODE_OF_CONDUCT.md.tt
89
- - lib/way_of_working/templates/docs/decisions/README.md
90
- - lib/way_of_working/templates/docs/decisions/adr-template.md.tt
91
128
  - lib/way_of_working/version.rb
92
129
  - way_of_working.gemspec
93
130
  homepage: https://healthdatainsight.github.io/way_of_working
@@ -99,7 +136,7 @@ metadata:
99
136
  homepage_uri: https://healthdatainsight.github.io/way_of_working
100
137
  source_code_uri: https://github.com/HealthDataInsight/way_of_working
101
138
  changelog_uri: https://github.com/HealthDataInsight/way_of_working/blob/main/CHANGELOG.md
102
- post_install_message:
139
+ post_install_message:
103
140
  rdoc_options: []
104
141
  require_paths:
105
142
  - lib
@@ -114,8 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
151
  - !ruby/object:Gem::Version
115
152
  version: '0'
116
153
  requirements: []
117
- rubygems_version: 3.1.6
118
- signing_key:
154
+ rubygems_version: 3.3.27
155
+ signing_key:
119
156
  specification_version: 4
120
157
  summary: RubyGem for the HDI way of working.
121
158
  test_files: []
@@ -1,110 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'way_of_working/paths'
4
- require 'way_of_working/git/repo_reader'
5
-
6
- module WayOfWorking
7
- module Generators
8
- module Changelog
9
- # This class fetches the CODE_OF_CONDUCT.md and inserts the contact method
10
- class Init < Thor::Group
11
- include Thor::Actions
12
-
13
- source_root ::WayOfWorking.source_root
14
-
15
- HEADER_TEXT = <<~TEXT
16
- # Changelog
17
-
18
- All notable changes to this project will be documented in this file.
19
-
20
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
21
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
22
-
23
- TEXT
24
-
25
- def add_changelog_to_project
26
- create_file 'CHANGELOG.md' do
27
- HEADER_TEXT + releases + footer
28
- end
29
- end
30
-
31
- private
32
-
33
- def releases
34
- text = "## [Unreleased]\n\n"
35
- text += added_change_text(:minor)
36
- text += deprecated_removed_fixed_security_text(:minor)
37
-
38
- summary_tags.each do |summary_tag|
39
- text += "## [#{summary_tag.version}] - " \
40
- "#{summary_tag.commit_date.strftime('%Y-%m-%d')}\n\n"
41
-
42
- text += added_change_text(summary_tag.change_type)
43
- text += deprecated_removed_fixed_security_text(summary_tag.change_type)
44
- end
45
-
46
- text
47
- end
48
-
49
- def added_change_text(tag_change_type)
50
- return '' if tag_change_type == :patch
51
-
52
- change_text('Added', 'Detail new feature(s) here', true) +
53
- change_text('Change', 'Detail change(s) in existing functionality here',
54
- tag_change_type == :major)
55
- end
56
-
57
- def deprecated_removed_fixed_security_text(tag_change_type)
58
- change_text('Deprecated', 'Detail soon-to-be removed features here') +
59
- change_text('Removed', 'Detail removed features here', tag_change_type == :major) +
60
- change_text('Fixed', 'Detail any bug fixes here', true) +
61
- change_text('Security', 'Detail fixes to vulnerabilities here')
62
- end
63
-
64
- # This method adds all of the reference style markdown links
65
- def footer
66
- return '' if summary_tags.empty?
67
-
68
- previous_tag = nil
69
- footer_text = ''
70
- summary_tags.each do |summary_tag|
71
- footer_text += if previous_tag
72
- release_link(summary_tag.name, previous_tag.name, previous_tag.version)
73
- else
74
- release_link(summary_tag.name, 'HEAD', 'Unreleased')
75
- end
76
-
77
- previous_tag = summary_tag
78
- end
79
-
80
- footer_text += "[#{previous_tag.version}]: #{url}/releases/tag/#{previous_tag.name}\n"
81
-
82
- footer_text
83
- end
84
-
85
- def release_link(start_tag, end_tag, version)
86
- "[#{version}]: #{url}/compare/#{start_tag}...#{end_tag}\n"
87
- end
88
-
89
- def change_text(type, description, likely = false)
90
- text = "### #{type}\n\n- TODO: #{description}"
91
- text += ' (if any)' unless likely
92
- text += "\n\n"
93
- text
94
- end
95
-
96
- def repo_reader
97
- @repo_reader ||= ::WayOfWorking::Git::RepoReader.new(::Git.open('.'))
98
- end
99
-
100
- def summary_tags
101
- @summary_tags ||= repo_reader.summary_tags.reverse
102
- end
103
-
104
- def url
105
- @url ||= repo_reader.likely_upstream_remote_url
106
- end
107
- end
108
- end
109
- end
110
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'way_of_working/paths'
4
-
5
- module WayOfWorking
6
- module Generators
7
- module CodeOfConduct
8
- # This class fetches the CODE_OF_CONDUCT.md and inserts the contact method
9
- class Init < Thor::Group
10
- include Thor::Actions
11
-
12
- source_root ::WayOfWorking.source_root
13
-
14
- class_option :contact_method, required: true
15
-
16
- # Use this method to update the cached template when required
17
- # def download_and_save_code_of_conduct_template
18
- # code_of_conduct_file = 'lib/way_of_working/templates/CODE_OF_CONDUCT.md.tt'
19
-
20
- # get 'https://www.contributor-covenant.org/version/2/1/code_of_conduct/code_of_conduct.md',
21
- # code_of_conduct_file
22
- # gsub_file code_of_conduct_file, '[INSERT CONTACT METHOD]',
23
- # "<%= options['contact_method'] %>"
24
- # end
25
-
26
- def add_code_of_conduct_to_project
27
- template 'CODE_OF_CONDUCT.md'
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'way_of_working/paths'
4
-
5
- module WayOfWorking
6
- module Generators
7
- module DecisionRecord
8
- # This generator add the MADR files to the doc/decisions folder
9
- class Init < Thor::Group
10
- include Thor::Actions
11
-
12
- source_root ::WayOfWorking.source_root
13
-
14
- # Templates are from https://github.com/adr/madr/tree/3.0.0/template
15
- def create_decision_record_files
16
- copy_file 'docs/decisions/README.md'
17
-
18
- # from https://raw.githubusercontent.com/adr/madr/3.0.0/template/adr-template.md
19
- @decision_date = '{YYYY-MM-DD when the decision was last updated}'
20
- @title = '{short title of solved problem and solution}'
21
- template 'docs/decisions/adr-template.md'
22
-
23
- get 'https://raw.githubusercontent.com/adr/madr/3.0.0/template/0000-use-markdown-any-decision-records.md',
24
- 'docs/decisions/0000-use-markdown-any-decision-records.md'
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'date'
4
- require 'way_of_working/paths'
5
-
6
- module WayOfWorking
7
- module Generators
8
- module DecisionRecord
9
- # This generator add a new MADR decision record to the doc/decisions folder
10
- class New < Thor::Group
11
- argument :name, type: :string, required: true, desc: 'The title of the decision record'
12
-
13
- include Thor::Actions
14
-
15
- source_root ::WayOfWorking.source_root
16
-
17
- def create_decision_record_file
18
- case behavior
19
- when :invoke
20
- invoke_decision_record_file
21
- when :revoke
22
- revoke_decision_record_file
23
- end
24
- end
25
-
26
- private
27
-
28
- def invoke_decision_record_file
29
- @decision_date = Date.today.strftime('%Y-%m-%d')
30
- @title = name
31
-
32
- # from https://raw.githubusercontent.com/adr/madr/3.0.0/template/adr-template.md
33
- template 'docs/decisions/adr-template.md',
34
- "docs/decisions/#{next_decision_number}-#{dashed_name}.md"
35
- end
36
-
37
- def revoke_decision_record_file
38
- matching_files = Dir.glob("[0-9][0-9][0-9][0-9]-#{dashed_name}.md",
39
- base: File.join(destination_root, 'docs/decisions'))
40
- raise "No matching decision record for '#{dashed_name}'" if matching_files.empty?
41
-
42
- # based on Thor's remove_file
43
- path = File.expand_path("docs/decisions/#{matching_files.first}", destination_root)
44
-
45
- say_status :remove, relative_to_original_destination_root(path)
46
- return unless !options[:pretend] && (File.exist?(path) || File.symlink?(path))
47
-
48
- require 'fileutils'
49
- ::FileUtils.rm_rf(path)
50
- end
51
-
52
- def next_decision_number
53
- existing_decisions = Dir.glob('[0-9][0-9][0-9][0-9]-*.md',
54
- base: File.join(destination_root, 'docs/decisions'))
55
- last_number = existing_decisions.map do |filename|
56
- filename.match(/\A(\d{4})-/)[1].to_i
57
- end.max || -1
58
- format('%04d', last_number + 1)
59
- end
60
-
61
- def dashed_name
62
- name.downcase.gsub(/[\s_()]/, '-').gsub(/-+/, '-')
63
- end
64
- end
65
- end
66
- end
67
- end
@@ -1,77 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'thor'
4
- require 'rainbow'
5
-
6
- module WayOfWorking
7
- module Generators
8
- module Linter
9
- # This generator runs the linter
10
- class Exec < Thor::Group
11
- argument :path, type: :string, required: false, desc: 'Optional path of the file to lint'
12
-
13
- desc 'This runs the linter on this project'
14
-
15
- def run_first
16
- @start_time = Time.now
17
-
18
- say(Rainbow("Limiting linters to #{path}\n").yellow) if path
19
- end
20
-
21
- # Run RuboCop
22
- def prep_and_run_rubocop
23
- say(Rainbow('Running RuboCop...').yellow)
24
-
25
- @rubocop_ok = run_rubocop(ARGV[2..])
26
- end
27
-
28
- # Run MegaLinter
29
- def prep_and_run_megalinter
30
- command = ['npx', 'mega-linter-runner', '--remove-container']
31
- # Configure MegaLinter to only lint a specific file or folder, if defined
32
- command.prepend("MEGALINTER_FILES_TO_LINT=\"#{path}\"") if path
33
- # We only want reports created in the working directory
34
- command.prepend('env', "GITHUB_WORKSPACE=\"#{Dir.pwd}\"")
35
-
36
- say(Rainbow("\nRunning MegaLinter...").yellow)
37
-
38
- @megalinter_ok = run_megalinter(command)
39
- end
40
-
41
- # We run this last to enable all the linters to run first
42
- def run_last
43
- say(Rainbow("\nTotal time taken: #{(Time.now - @start_time).to_i} seconds").yellow)
44
-
45
- if !@rubocop_ok || !@megalinter_ok
46
- abort(Rainbow("\nLinter failed!").red)
47
- else
48
- say(Rainbow("\nLinter Succeeded!").green)
49
- end
50
- end
51
-
52
- private
53
-
54
- def path_directory
55
- return path if File.directory?(path)
56
-
57
- File.dirname(path)
58
- end
59
-
60
- def run_rubocop(arguments)
61
- # We lazy-load RuboCop so that the task doesn't dramatically impact the
62
- # load time of our commands.
63
- require 'rubocop'
64
-
65
- cli = RuboCop::CLI.new
66
- !cli.run(arguments).nonzero?
67
- end
68
-
69
- def run_megalinter(arguments)
70
- arguments.prepend('time')
71
-
72
- system(*arguments)
73
- end
74
- end
75
- end
76
- end
77
- end
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'thor'
4
- require 'way_of_working/paths'
5
-
6
- module WayOfWorking
7
- module Generators
8
- module Linter
9
- # This generator add the MADR files to the doc/decisions folder
10
- class Init < Thor::Group
11
- include Thor::Actions
12
-
13
- source_root ::WayOfWorking.source_root
14
-
15
- # TODO: copy_rubocop_github_workflow_action
16
-
17
- def copy_github_linters_rubocop_config_file
18
- copy_file '.github/linters/rubocop_defaults.yml'
19
- end
20
-
21
- def copy_github_linters_markdown_link_check_config_file
22
- copy_file '.github/linters/.markdown-link-check.json'
23
- end
24
-
25
- def copy_megalinter_github_workflow_action
26
- copy_file '.github/workflows/mega-linter.yml'
27
- end
28
-
29
- def copy_megalinter_dot_file
30
- copy_file '.mega-linter.yml'
31
- end
32
-
33
- def create_gitignore_if_missing
34
- create_file_if_missing '.gitignore'
35
- end
36
-
37
- def gitignore_reports_folder
38
- append_to_file '.gitignore', "megalinter-reports/\n"
39
- end
40
-
41
- def gitignore_rubocop_cached_file
42
- append_to_file '.gitignore', ".rubocop-https---*\n"
43
- end
44
-
45
- def copy_rubocop_options_file
46
- copy_file '.rubocop'
47
- end
48
-
49
- private
50
-
51
- def create_file_if_missing(path)
52
- path = File.join(destination_root, path)
53
- return if behavior == :revoke || File.exist?(path)
54
-
55
- File.open(path, 'w', &:write)
56
- end
57
- end
58
- end
59
- end
60
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module WayOfWorking
4
- module Generators
5
- module RakeTasks
6
- # This generator installs way of working rake tasks into this project
7
- class Init < Thor::Group
8
- include Thor::Actions
9
-
10
- RAKEFILE_FILENAME = 'Rakefile'
11
- RAILS_LOC = %r{require_relative ["']config/application["']\n}.freeze
12
- BUNDLER_LOC = %r{require ["']bundler/gem_tasks["']\n}.freeze
13
-
14
- def add_to_rakefile
15
- case rakefile_type
16
- when :rails
17
- inject_into_file RAKEFILE_FILENAME,
18
- "require 'way_of_working/tasks' if Rails.env.development? " \
19
- "|| Rails.env.test?\n",
20
- after: RAILS_LOC
21
- when :bundler
22
- inject_into_file RAKEFILE_FILENAME,
23
- "require 'way_of_working/tasks'\n",
24
- after: BUNDLER_LOC
25
- when :none
26
- create_file RAKEFILE_FILENAME, "\nrequire 'way_of_working/tasks'\n"
27
- else
28
- append_to_file RAKEFILE_FILENAME, "\nrequire 'way_of_working/tasks'\n"
29
- end
30
- end
31
-
32
- private
33
-
34
- def rakefile_type
35
- content = File.read(File.expand_path(RAKEFILE_FILENAME, destination_root))
36
-
37
- return :rails if content.match?(RAILS_LOC)
38
- return :bundler if content.match?(BUNDLER_LOC)
39
-
40
- :other
41
- rescue Errno::ENOENT
42
- :none
43
- end
44
- end
45
- end
46
- end
47
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'thor'
4
-
5
- # This class enables subcommands to work correctly with help. See:
6
- # https://github.com/rails/thor/wiki/Subcommands#subcommands-that-work-correctly-with-help
7
- class SubCommandBase < Thor
8
- def self.banner(command, _namespace = nil, _subcommand = false)
9
- "#{basename} #{subcommand_prefix} #{command.usage}"
10
- end
11
-
12
- def self.subcommand_prefix
13
- name.gsub(/.*::/, '').gsub(/^[A-Z]/) { |match| match[0].downcase }.
14
- gsub(/[A-Z]/) { |match| "-#{match[0].downcase}" }
15
- end
16
- end
@@ -1,13 +0,0 @@
1
- {
2
- "ignorePatterns": [
3
- {
4
- "pattern": "^0005-example.md"
5
- },
6
- {
7
- "pattern": "^adr-template.md"
8
- }
9
- ],
10
- "retryOn429": true,
11
- "retryCount": 5,
12
- "aliveStatusCodes": [ 200, 203 ]
13
- }