cli-mastermind 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a932d12a8cc90bcdf962b0980e81a6ccb0e11b3c2be7545c62dd8c9de93be1d
4
- data.tar.gz: 80ba0ee26a3ec8aa2f85cea56b1c62f982066a06608d12010b234cbdad90e514
3
+ metadata.gz: 6b685a85669b39aaaf6f66c502c3705f6c3927fb93b719ca511ec1f5ad504b32
4
+ data.tar.gz: dd4403bde3e61c28288e4f17e8b7b8f9aa408c15a39e62ff40e73044581d751d
5
5
  SHA512:
6
- metadata.gz: f27becd1dcccb97e1ef7e4764e05711b09e1ef031a7e97c35100999992220dae941648751a522a8f8d0d556054d605622bf6f0238834dbecb4d63271f3034216
7
- data.tar.gz: 4c60255fa408f8e73c602ab5e855623073b2430a65fcc4e578a4a4ee01a03b172d82dc1ba596798dff488ab9faff08896896ad6ee5e35b4176fb9ba0b4f1e2a6
6
+ metadata.gz: 0e75a90c7e61ba882085ab1efd9044ee58eb1b6e8f1225314f3449646be530656e5fba2a266f62d2b285c9de688202d674d03cf6520019059cc1f63161cdcec1
7
+ data.tar.gz: ed1cee7f906e6ae8983f8b4d75e8c59650c6ed5528aa2cb6a5aeb703ccda2266d06accf35d9a31ff827d0ce8015e41a1aedc5bba27780c6df4221722ce0047e3
data/README.md CHANGED
@@ -5,6 +5,10 @@ command line tools.
5
5
 
6
6
  Mastermind is designed for flexibility, extensibility, minimal dependencies.
7
7
 
8
+ ## My devious plot cannot wait! Tell me your secrets!
9
+
10
+ If you want to jump right into using Mastermind, head over to the [wiki][wiki].
11
+
8
12
  ## Flexibility
9
13
 
10
14
  Mastermind is written in Ruby and, therefore, provides first-class citizenship
@@ -39,6 +43,9 @@ Obviously, it'd be a bit difficult to write your plan files in an entirely separ
39
43
  language, but there's nothing stopping you from delegating actions to another
40
44
  executable or even writing some C code to call into something else alltogether.
41
45
 
46
+ If you are writing your plans in Ruby, Mastermind provides `CLI::Mastermind::Plan::Interface`
47
+ which you can include in your plans to provide the basic `Plan` interface.
48
+
42
49
  ## Minimal Dependencies
43
50
 
44
51
  Mastermind only has one dependency, Shopify's excelent [cli-ui project][cli-ui].
@@ -60,10 +67,13 @@ Any arguments specified after `--` are passed as-is down to the executed plan.
60
67
  You can then process those arguments however you like or ignore them completely!
61
68
 
62
69
  Unlike Rake and other, similar, tools that allow you to run multiple tasks in
63
- parallel, Mastermind is designed to run only one task at a time. Specifying
70
+ parallel, _Mastermind is designed to run only one task at a time_. Specifying
64
71
  multiple plan names on the command line is how you walk down the tree to a
65
72
  specific plan.
66
73
 
74
+ For more information on how to use and configure Mastermind, check out the
75
+ [wiki][wiki].
76
+
67
77
  ## Development
68
78
 
69
79
  After checking out the repo, run `bin/setup` to install dependencies. You can
@@ -83,5 +93,6 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/chall8
83
93
 
84
94
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
85
95
 
86
- [writing-masterplans]: wiki/Writing-Masterplans
96
+ [wiki]: https://github.com/chall8908/cli-mastermind/wiki
97
+ [writing-masterplans]: https://github.com/chall8908/cli-mastermind/wiki/Writing-Masterplans
87
98
  [cli-ui]: https://github.com/shopify/cli-ui
@@ -3,14 +3,14 @@ require 'cli/ui'
3
3
  require 'cli/mastermind/arg_parse'
4
4
  require 'cli/mastermind/configuration'
5
5
  require 'cli/mastermind/errors'
6
- require 'cli/mastermind/interface'
6
+ require 'cli/mastermind/user_interface'
7
7
  require 'cli/mastermind/loader'
8
8
  require 'cli/mastermind/plan'
9
9
  require 'cli/mastermind/version'
10
10
 
11
11
  module CLI
12
12
  module Mastermind
13
- extend Interface
13
+ extend UserInterface
14
14
 
15
15
  class << self
16
16
  # Expose the configuration loaded during +execute+.
@@ -1,24 +1,15 @@
1
1
  require 'forwardable'
2
+ require 'cli/mastermind/plan/interface'
2
3
 
3
4
  module CLI
4
5
  module Mastermind
5
6
  class Plan
6
- extend Forwardable
7
+ include UserInterface
7
8
  include Interface
8
9
 
9
- # The name of the plan. Used to specify the plan from the command line
10
- # or from the interactive menu
11
- attr_reader :name
12
-
13
- # Displayed in the non-interactive list of available plans
14
- attr_reader :description
15
-
16
10
  # Used in the interactive plan selector to display child plans
17
11
  attr_reader :children
18
12
 
19
- # The file this plan was loaded from, if any
20
- attr_reader :filename
21
-
22
13
  # Loads a particular plan from the filesystem.
23
14
  # @see Loader
24
15
  def self.load(filename)
@@ -28,10 +19,8 @@ module CLI
28
19
  end
29
20
 
30
21
  def initialize(name, description=nil, filename=nil, &block)
31
- @name = name.to_s.freeze
32
- @description = description.freeze
33
- @filename = filename
34
- @block = block
22
+ super
23
+
35
24
  @children = {}
36
25
  end
37
26
 
@@ -75,7 +64,9 @@ module CLI
75
64
  end
76
65
 
77
66
  # Otherwise, the plan defined later wins and overwrites the existing plan
78
- warn <<~PLAN_COLLISON.strip
67
+
68
+ # Warn the user that this is happening, unless we're running tests.
69
+ warn <<~PLAN_COLLISON.strip unless defined? RSpec
79
70
  Plan name collision encountered when loading plans from "#{plan.filename}" that cannot be merged.
80
71
  "#{plan.name}" was previously defined in "#{existing_plan.filename}".
81
72
  Plans from "#{plan.filename}" will be used instead.
@@ -84,10 +75,6 @@ module CLI
84
75
 
85
76
  @children[plan.name] = plan
86
77
  end
87
-
88
- # Delegate configuration to the top-level configuration object
89
- def_delegator :'CLI::Mastermind', :configuration
90
- alias_method :config, :configuration
91
78
  end
92
79
  end
93
80
  end
@@ -0,0 +1,49 @@
1
+ module CLI::Mastermind
2
+ class Plan
3
+ # The plan interface is everything that is required in order for an object
4
+ # to be usable as a plan.
5
+ #
6
+ # Objects adhering to this interface must implement their own +call+ method.
7
+ # This method is what is invoked by Mastermind to execute a plan.
8
+ #
9
+ # Mastermind assumes that any plan it encounters could have children, hence
10
+ # the +has_children?+ method here. Since the default PlanfileLoader doesn't
11
+ # permit custom plan classes when defining a plan with children, it's assumed
12
+ # that any custom plans (which include this interface) won't have any children
13
+ # at all.
14
+ module Interface
15
+ extend Forwardable
16
+
17
+ def self.included(base)
18
+ # The name of the plan. Used to specify the plan from the command line
19
+ # or from the interactive menu
20
+ base.attr_reader :name
21
+
22
+ # Displayed in the non-interactive list of available plans
23
+ base.attr_reader :description
24
+
25
+ # The file this plan was loaded from, if any
26
+ base.attr_reader :filename
27
+ end
28
+
29
+ def initialize(name, description=nil, filename=nil, &block)
30
+ @name = name.to_s.freeze
31
+ @description = description.freeze
32
+ @filename = filename
33
+ @block = block
34
+ end
35
+
36
+ def has_children?
37
+ false
38
+ end
39
+
40
+ def call(options=nil)
41
+ raise NotImplementedError
42
+ end
43
+
44
+ # Delegate configuration to the top-level configuration object
45
+ def_delegator :'CLI::Mastermind', :configuration
46
+ alias_method :config, :configuration
47
+ end
48
+ end
49
+ end
@@ -1,6 +1,6 @@
1
1
  # Wraps methods from CLI::UI in a slightly nicer DSL
2
2
  # @see https://github.com/Shopify/cli-ui
3
- module CLI::Mastermind::Interface
3
+ module CLI::Mastermind::UserInterface
4
4
  # Enables cli-ui's STDOUT Router for fancy UIs
5
5
  def enable_ui
6
6
  CLI::UI::StdoutRouter.enable
@@ -7,8 +7,8 @@ module CLI
7
7
 
8
8
  module VERSION
9
9
  RELEASE = 0
10
- MAJOR = 1
11
- MINOR = 1
10
+ MAJOR = 2
11
+ MINOR = 0
12
12
  PATCH = nil
13
13
 
14
14
  STRING = [RELEASE, MAJOR, MINOR, PATCH].compact.join('.').freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cli-mastermind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Hall
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-27 00:00:00.000000000 Z
11
+ date: 2019-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cli-ui
@@ -77,10 +77,11 @@ files:
77
77
  - lib/cli/mastermind/arg_parse.rb
78
78
  - lib/cli/mastermind/configuration.rb
79
79
  - lib/cli/mastermind/errors.rb
80
- - lib/cli/mastermind/interface.rb
81
80
  - lib/cli/mastermind/loader.rb
82
81
  - lib/cli/mastermind/loader/planfile_loader.rb
83
82
  - lib/cli/mastermind/plan.rb
83
+ - lib/cli/mastermind/plan/interface.rb
84
+ - lib/cli/mastermind/user_interface.rb
84
85
  - lib/cli/mastermind/version.rb
85
86
  homepage: https://github.com/chall8908/cli-mastermind
86
87
  licenses: