cobra_commander 0.15.0 → 1.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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -2
  3. data/.rubocop.yml +0 -5
  4. data/Gemfile +7 -0
  5. data/cobra_commander.gemspec +6 -1
  6. data/doc/dependency_decisions.yml +9 -0
  7. data/docs/CHANGELOG.md +19 -2
  8. data/docs/README.md +3 -129
  9. data/exe/cobra +5 -0
  10. data/lib/cobra_commander/affected.rb +19 -51
  11. data/lib/cobra_commander/cli/filters.rb +1 -3
  12. data/lib/cobra_commander/{output → cli/output}/ascii_tree.rb +7 -5
  13. data/lib/cobra_commander/cli/output/change.rb +91 -0
  14. data/lib/cobra_commander/cli/output/dot_graph.rb +21 -0
  15. data/lib/cobra_commander/cli.rb +58 -30
  16. data/lib/cobra_commander/component.rb +6 -10
  17. data/lib/cobra_commander/executor/command.rb +75 -0
  18. data/lib/cobra_commander/executor/execution.rb +52 -0
  19. data/lib/cobra_commander/executor/interactive_printer.rb +53 -0
  20. data/lib/cobra_commander/executor/job.rb +51 -0
  21. data/lib/cobra_commander/executor/markdown_printer.rb +21 -0
  22. data/lib/cobra_commander/executor/package_criteria.rb +21 -0
  23. data/lib/cobra_commander/executor/script.rb +45 -0
  24. data/lib/cobra_commander/executor/spinners.rb +40 -0
  25. data/lib/cobra_commander/executor.rb +37 -6
  26. data/lib/cobra_commander/git_changed.rb +16 -11
  27. data/lib/cobra_commander/package.rb +21 -0
  28. data/lib/cobra_commander/registry.rb +29 -0
  29. data/lib/cobra_commander/source.rb +37 -0
  30. data/lib/cobra_commander/umbrella.rb +70 -17
  31. data/lib/cobra_commander/version.rb +1 -1
  32. data/lib/cobra_commander.rb +10 -16
  33. data/mkdocs.yml +1 -1
  34. metadata +37 -43
  35. data/.editorconfig +0 -11
  36. data/.github/workflows/ci.yml +0 -44
  37. data/.github/workflows/release.yml +0 -20
  38. data/.rubocop_todo.yml +0 -15
  39. data/LICENSE.txt +0 -21
  40. data/_config.yml +0 -1
  41. data/docs/CODE_OF_CONDUCT.md +0 -74
  42. data/gemfiles/bundler1.gemfile +0 -7
  43. data/gemfiles/bundler2.gemfile +0 -7
  44. data/lib/cobra_commander/change.rb +0 -87
  45. data/lib/cobra_commander/dependencies/bundler/package.rb +0 -17
  46. data/lib/cobra_commander/dependencies/bundler.rb +0 -44
  47. data/lib/cobra_commander/dependencies/yarn/package.rb +0 -21
  48. data/lib/cobra_commander/dependencies/yarn.rb +0 -40
  49. data/lib/cobra_commander/dependencies.rb +0 -4
  50. data/lib/cobra_commander/executor/concurrent.rb +0 -51
  51. data/lib/cobra_commander/executor/context.rb +0 -49
  52. data/lib/cobra_commander/output/flat_list.rb +0 -16
  53. data/lib/cobra_commander/output/graph_viz.rb +0 -27
  54. data/lib/cobra_commander/output/interactive_printer.rb +0 -53
  55. data/lib/cobra_commander/output/markdown_printer.rb +0 -24
  56. data/lib/cobra_commander/output.rb +0 -7
  57. data/portal.yml +0 -12
  58. data/renovate.json +0 -8
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CobraCommander
4
+ module Registry
5
+ def [](key)
6
+ Class.new(self) do
7
+ define_singleton_method(:key) { key }
8
+ define_method(:key) { key }
9
+
10
+ def self.inherited(base)
11
+ super
12
+ superclass.all[key] = base
13
+ end
14
+ end
15
+ end
16
+
17
+ def all
18
+ @all ||= {}
19
+ end
20
+
21
+ def select(**selector)
22
+ return all.values unless selector.values.any?
23
+
24
+ all.filter_map do |key, klass|
25
+ klass if selector[key]
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cobra_commander/package"
4
+ require "cobra_commander/registry"
5
+
6
+ module CobraCommander
7
+ class Source
8
+ Error = Class.new(StandardError)
9
+
10
+ include Enumerable
11
+ extend CobraCommander::Registry
12
+
13
+ attr_reader :path, :config
14
+
15
+ def initialize(path, config)
16
+ @path = Pathname.new(path)
17
+ @config = config || {}
18
+ super()
19
+ end
20
+
21
+ def to_ary
22
+ to_a
23
+ end
24
+
25
+ def each(&block)
26
+ packages.each(&block)
27
+ rescue Errno::ENOENT => e
28
+ raise Error, e.message
29
+ end
30
+
31
+ def self.load(path, config = nil, **selector)
32
+ select(**selector).map do |source|
33
+ source.new(path, config&.dig(source.key))
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,40 +1,93 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "yaml"
4
+
3
5
  module CobraCommander
4
6
  # An umbrella application
5
7
  class Umbrella
6
- attr_reader :name, :path
8
+ attr_reader :path, :config
9
+
10
+ def self.load_config(path)
11
+ return {} unless path.exist?
12
+
13
+ YAML.safe_load(path.read, permitted_classes: [Symbol], aliases: true)
14
+ end
7
15
 
8
- def initialize(name, path)
9
- @root_component = Component.new(self, name)
10
- @path = path
16
+ # Umbrella constructor. This will load the given source packages.
17
+ #
18
+ # @see Umbrella#load
19
+ # @param path [String,Pathname] path to umbrella app
20
+ # @param **source_selector [Symbol => Boolean] selector as explained above
21
+ #
22
+ def initialize(path, config = nil, **source_selector)
23
+ @path = Pathname.new(path)
11
24
  @components = {}
25
+ @config = config || Umbrella.load_config(@path.join("cobra.yml"))
26
+ load(**source_selector)
12
27
  end
13
28
 
29
+ #
30
+ # Finds a component by name
31
+ #
32
+ # @param name [String] the name of the component
33
+ # @return [::CobraCommander::Component,nil] the component with a matching name or nil
34
+ #
14
35
  def find(name)
15
36
  @components[name]
16
37
  end
17
38
 
18
- def root
19
- @root_component
20
- end
21
-
22
- def resolve(component_root_path)
23
- return root if root.root_paths.include?(component_root_path)
24
-
39
+ #
40
+ # Resolve a component given the path.
41
+ #
42
+ # This method resolves the component if the given path is inside
43
+ # any of the packages composing this component.
44
+ #
45
+ # @param path [String,Pathname] the path to be resolved
46
+ # @return [::CobraCommander::Component,nil] the component where the path is
47
+ #
48
+ def resolve(path)
25
49
  components.find do |component|
26
- component.root_paths.include?(component_root_path)
50
+ component.root_paths.any? do |component_path|
51
+ component_path.eql?(Pathname.new(path)) || path.to_s.start_with?("#{component_path.cleanpath}/")
52
+ end
27
53
  end
28
54
  end
29
55
 
30
- def add_source(key, source)
31
- @root_component.add_package key, source.root
32
- source.packages.each do |packages|
33
- @components[packages.name] ||= Component.new(self, packages.name)
34
- @components[packages.name].add_package key, packages
56
+ #
57
+ # Loads the given sources, or all of none given. This method is fired
58
+ # by the constructor with the inital selector.
59
+ #
60
+ # I.e.:
61
+ #
62
+ # If the environment has both ruby and yarn plugins loaded, this
63
+ # would load the yarn workspaces packages and rubygems package
64
+ # graphs:
65
+ #
66
+ # umbrella.load(ruby: true, js: true)
67
+ #
68
+ # If no selector is given, all plugins are loaded. So assuming the
69
+ # same plugins exist, this would also load yarn and ruby packages:
70
+ #
71
+ # umbrella.load()
72
+ #
73
+ # Specifying plugins will only load what is specified, and this would
74
+ # only load ruby packages:
75
+ #
76
+ # umbrella.load(ruby: true)
77
+ #
78
+ # @see CobraCommander::Registry
79
+ #
80
+ def load(**source_selector)
81
+ Source.load(path, config["sources"], **source_selector).flatten.each do |package|
82
+ @components[package.name] ||= Component.new(self, package.name)
83
+ @components[package.name].add_package package
35
84
  end
36
85
  end
37
86
 
87
+ # All components in this umbrella
88
+ #
89
+ # @return [Array<CobraCommander::Component>]
90
+ #
38
91
  def components
39
92
  @components.values
40
93
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CobraCommander
4
- VERSION = "0.15.0"
4
+ VERSION = "1.0.0"
5
5
  end
@@ -1,7 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "cobra_commander/dependencies"
3
+ require "bundler"
4
+
5
+ require "cobra_commander/affected"
4
6
  require "cobra_commander/component"
7
+ require "cobra_commander/executor"
8
+ require "cobra_commander/git_changed"
9
+ require "cobra_commander/package"
10
+ require "cobra_commander/source"
5
11
  require "cobra_commander/umbrella"
6
12
  require "cobra_commander/version"
7
13
 
@@ -9,20 +15,8 @@ require "cobra_commander/version"
9
15
  # Includes tools for graphing the components of an app and their relationships, as well as selectively
10
16
  # testing components based on changes made.
11
17
  module CobraCommander
12
- UMBRELLA_APP_NAME = "App"
13
-
14
- def self.umbrella(root_path, yarn: false, bundler: false, name: UMBRELLA_APP_NAME)
15
- umbrella = Umbrella.new(name, root_path)
16
- umbrella.add_source(:yarn, Dependencies::Yarn.new(root_path)) unless bundler
17
- umbrella.add_source(:bundler, Dependencies::Bundler.new(root_path)) unless yarn
18
- umbrella
19
- end
20
-
21
- def self.umbrella_tree(path)
22
- CalculatedComponentTree.new(UMBRELLA_APP_NAME, path)
23
- end
24
-
25
- def self.tree_from_cache(cache_file)
26
- CachedComponentTree.from_cache_file(cache_file)
18
+ # @deprecated Use Umbrella.new
19
+ def self.umbrella(root_path, **selector)
20
+ Umbrella.new(root_path, **selector)
27
21
  end
28
22
  end
data/mkdocs.yml CHANGED
@@ -1,8 +1,8 @@
1
1
  site_name: Cobra Commander
2
2
  site_description: Cobra Commander Documentation
3
+ repo_url: https://github.com/powerhome/cobra_commander
3
4
  nav:
4
5
  - "Home": "README.md"
5
6
  - "Changelog": "CHANGELOG.md"
6
- - "Code of Conduct": "CODE_OF_CONDUCT.md"
7
7
  plugins:
8
8
  - techdocs-core
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cobra_commander
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Langfeld
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2022-08-17 00:00:00.000000000 Z
13
+ date: 2022-12-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -40,20 +40,6 @@ dependencies:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '1.1'
43
- - !ruby/object:Gem::Dependency
44
- name: ruby-graphviz
45
- requirement: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - "~>"
48
- - !ruby/object:Gem::Version
49
- version: 1.2.3
50
- type: :runtime
51
- prerelease: false
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - "~>"
55
- - !ruby/object:Gem::Version
56
- version: 1.2.3
57
43
  - !ruby/object:Gem::Dependency
58
44
  name: thor
59
45
  requirement: !ruby/object:Gem::Requirement
@@ -158,6 +144,20 @@ dependencies:
158
144
  - - ">="
159
145
  - !ruby/object:Gem::Version
160
146
  version: '0'
147
+ - !ruby/object:Gem::Dependency
148
+ name: license_finder
149
+ requirement: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '7.0'
154
+ type: :development
155
+ prerelease: false
156
+ version_requirements: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '7.0'
161
161
  - !ruby/object:Gem::Dependency
162
162
  name: pry
163
163
  requirement: !ruby/object:Gem::Requirement
@@ -241,57 +241,51 @@ executables:
241
241
  extensions: []
242
242
  extra_rdoc_files: []
243
243
  files:
244
- - ".editorconfig"
245
- - ".github/workflows/ci.yml"
246
- - ".github/workflows/release.yml"
247
244
  - ".gitignore"
248
245
  - ".rspec"
249
246
  - ".rubocop.yml"
250
- - ".rubocop_todo.yml"
251
247
  - Gemfile
252
248
  - Guardfile
253
- - LICENSE.txt
254
249
  - Rakefile
255
- - _config.yml
256
250
  - bin/console
257
251
  - bin/setup
258
252
  - cobra_commander.gemspec
253
+ - doc/dependency_decisions.yml
259
254
  - docs/CHANGELOG.md
260
- - docs/CODE_OF_CONDUCT.md
261
255
  - docs/README.md
262
256
  - exe/cobra
263
- - gemfiles/bundler1.gemfile
264
- - gemfiles/bundler2.gemfile
265
257
  - lib/cobra_commander.rb
266
258
  - lib/cobra_commander/affected.rb
267
- - lib/cobra_commander/change.rb
268
259
  - lib/cobra_commander/cli.rb
269
260
  - lib/cobra_commander/cli/filters.rb
261
+ - lib/cobra_commander/cli/output/ascii_tree.rb
262
+ - lib/cobra_commander/cli/output/change.rb
263
+ - lib/cobra_commander/cli/output/dot_graph.rb
270
264
  - lib/cobra_commander/component.rb
271
- - lib/cobra_commander/dependencies.rb
272
- - lib/cobra_commander/dependencies/bundler.rb
273
- - lib/cobra_commander/dependencies/bundler/package.rb
274
- - lib/cobra_commander/dependencies/yarn.rb
275
- - lib/cobra_commander/dependencies/yarn/package.rb
276
265
  - lib/cobra_commander/executor.rb
277
- - lib/cobra_commander/executor/concurrent.rb
278
- - lib/cobra_commander/executor/context.rb
266
+ - lib/cobra_commander/executor/command.rb
267
+ - lib/cobra_commander/executor/execution.rb
268
+ - lib/cobra_commander/executor/interactive_printer.rb
269
+ - lib/cobra_commander/executor/job.rb
270
+ - lib/cobra_commander/executor/markdown_printer.rb
271
+ - lib/cobra_commander/executor/package_criteria.rb
272
+ - lib/cobra_commander/executor/script.rb
273
+ - lib/cobra_commander/executor/spinners.rb
279
274
  - lib/cobra_commander/git_changed.rb
280
- - lib/cobra_commander/output.rb
281
- - lib/cobra_commander/output/ascii_tree.rb
282
- - lib/cobra_commander/output/flat_list.rb
283
- - lib/cobra_commander/output/graph_viz.rb
284
- - lib/cobra_commander/output/interactive_printer.rb
285
- - lib/cobra_commander/output/markdown_printer.rb
275
+ - lib/cobra_commander/package.rb
276
+ - lib/cobra_commander/registry.rb
277
+ - lib/cobra_commander/source.rb
286
278
  - lib/cobra_commander/umbrella.rb
287
279
  - lib/cobra_commander/version.rb
288
280
  - mkdocs.yml
289
- - portal.yml
290
- - renovate.json
291
281
  homepage: http://tech.powerhrg.com/cobra_commander/
292
282
  licenses:
293
283
  - MIT
294
- metadata: {}
284
+ metadata:
285
+ rubygems_mfa_required: 'true'
286
+ homepage_uri: http://tech.powerhrg.com/cobra_commander/
287
+ source_code_uri: https://github.com/powerhome/cobra_commander
288
+ changelog_uri: https://github.com/powerhome/cobra_commander/blob/main/cobra_commander/docs/CHANGELOG.md
295
289
  post_install_message:
296
290
  rdoc_options: []
297
291
  require_paths:
@@ -307,7 +301,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
307
301
  - !ruby/object:Gem::Version
308
302
  version: '0'
309
303
  requirements: []
310
- rubygems_version: 3.3.7
304
+ rubygems_version: 3.4.1
311
305
  signing_key:
312
306
  specification_version: 4
313
307
  summary: Tools for working with Component Based Rails Apps
data/.editorconfig DELETED
@@ -1,11 +0,0 @@
1
- # EditorConfig is awesome: https://EditorConfig.org
2
- # top-most EditorConfig file
3
- root = true
4
-
5
- # Unix-style newlines with a newline ending every file
6
- [*]
7
- end_of_line = lf
8
- insert_final_newline = true
9
- trim_trailing_whitespace = true
10
- indent_style = space
11
- indent_size = 2
@@ -1,44 +0,0 @@
1
- name: CI
2
-
3
- on: push
4
-
5
- jobs:
6
- test:
7
- name: Tests
8
- runs-on: ubuntu-latest
9
- strategy:
10
- fail-fast: false
11
- matrix:
12
- ruby:
13
- - "2.7"
14
- - "3.0"
15
- bundler:
16
- - "1"
17
- - "2"
18
- env:
19
- BUNDLE_GEMFILE: gemfiles/bundler${{ matrix.bundler }}.gemfile
20
- steps:
21
- - uses: actions/checkout@v3
22
- - uses: ruby/setup-ruby@v1
23
- with:
24
- ruby-version: ${{ matrix.ruby }}
25
- bundler: ${{ matrix.bundler }}
26
- bundler-cache: true
27
- - name: Install bundler v1 # Even if we're testing bundler v2, we need v1 available because the fixture components have it in their Gemfile.locks
28
- run: gem install bundler -v "~> 1" --no-document
29
- - name: Install Graphviz
30
- run: sudo apt -qq install graphviz
31
- - name: Run tests
32
- run: bundle exec rake spec
33
- lint:
34
- name: Lint Ruby
35
- runs-on: ubuntu-latest
36
- steps:
37
- - uses: actions/checkout@v3
38
- - uses: ruby/setup-ruby@v1
39
- with:
40
- ruby-version: 3.0
41
- - name: Bundle
42
- run: bundle
43
- - name: Run Rubocop
44
- run: bundle exec rubocop
@@ -1,20 +0,0 @@
1
- name: Publish Gem
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
- tags:
8
- - v*
9
- jobs:
10
- build:
11
- runs-on: ubuntu-latest
12
- steps:
13
- - uses: actions/checkout@v3
14
- - name: Release Gem
15
- uses: cadwallion/publish-rubygems-action@master
16
- if: contains(github.ref, 'refs/tags/v')
17
- env:
18
- GITHUB_TOKEN: ${{ secrets.github_token }}
19
- RUBYGEMS_API_KEY: ${{ secrets.rubygems_api_key }}
20
- RELEASE_COMMAND: rake release
data/.rubocop_todo.yml DELETED
@@ -1,15 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2022-08-09 19:10:45 UTC using RuboCop version 1.30.1.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 8
10
- Performance/MethodObjectAsBlock:
11
- Exclude:
12
- - 'lib/cobra_commander/affected.rb'
13
- - 'lib/cobra_commander/component.rb'
14
- - 'lib/cobra_commander/dependencies/yarn_workspace.rb'
15
- - 'lib/cobra_commander/output/interactive_printer.rb'
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2017 Power Home Remodelling Group LLC
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/_config.yml DELETED
@@ -1 +0,0 @@
1
- theme: jekyll-theme-architect
@@ -1,74 +0,0 @@
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 blangfeld@powerhrg.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 [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- gemspec path: "../"
6
-
7
- gem "bundler", "~> 1.17.3"
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- gemspec path: "../"
6
-
7
- gem "bundler", "~> 2.3.5"
@@ -1,87 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "cobra_commander/git_changed"
4
- require "cobra_commander/affected"
5
-
6
- module CobraCommander
7
- # Calculates and prints affected components & files
8
- class Change
9
- InvalidSelectionError = Class.new(StandardError)
10
-
11
- def initialize(umbrella, oformat, branch, changes: nil)
12
- @format = oformat
13
- @branch = branch
14
- @umbrella = umbrella
15
- @changes = changes || GitChanged.new(umbrella.path, branch)
16
- end
17
-
18
- def run!
19
- assert_valid_result_choice
20
- if selected_format?("json")
21
- puts affected.json_representation
22
- else
23
- show_full if selected_format?("full")
24
- tests_to_run
25
- end
26
- rescue GitChanged::InvalidSelectionError => e
27
- puts e.message
28
- end
29
-
30
- private
31
-
32
- def affected
33
- @affected ||= Affected.new(@umbrella, @changes)
34
- end
35
-
36
- def show_full
37
- changes_since_last_commit
38
- directly_affected_components
39
- transitively_affected_components
40
- end
41
-
42
- def assert_valid_result_choice
43
- return if %w[test full name json].include?(@format)
44
-
45
- raise InvalidSelectionError, "--results must be 'test', 'full', 'name' or 'json'"
46
- end
47
-
48
- def selected_format?(result)
49
- @format == result
50
- end
51
-
52
- def changes_since_last_commit
53
- puts "<<< Changes since last commit on #{@branch} >>>"
54
- puts(*@changes) if @changes.any?
55
- puts blank_line
56
- end
57
-
58
- def directly_affected_components
59
- puts "<<< Directly affected components >>>"
60
- affected.directly.each { |component| puts display(**component) }
61
- puts blank_line
62
- end
63
-
64
- def transitively_affected_components
65
- puts "<<< Transitively affected components >>>"
66
- affected.transitively.each { |component| puts display(**component) }
67
- puts blank_line
68
- end
69
-
70
- def tests_to_run
71
- puts "<<< Test scripts to run >>>" if selected_format?("full")
72
- if selected_format?("name")
73
- affected.names.each { |component_name| puts component_name }
74
- else
75
- affected.scripts.each { |component_script| puts component_script }
76
- end
77
- end
78
-
79
- def display(name:, type:, **)
80
- "#{name} - #{type}"
81
- end
82
-
83
- def blank_line
84
- ""
85
- end
86
- end
87
- end