strategy 0.1.1 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 313846f0c19dea154b8ba65298ce28eb79043bc5
4
- data.tar.gz: ff25f117d25be39dc138c54f230f7512d3b7a48e
3
+ metadata.gz: b90a3cd26bb65310c0188bc84c4c32cf01c6eaa8
4
+ data.tar.gz: ffe523137e89a5d3514d6eddda99f67f8169af36
5
5
  SHA512:
6
- metadata.gz: eea489e5ae66e91a7d8dc14aa11a3c5ca0166ce485a006fd70c1a3678d5e1e84a7420db23c37e84952fc5399fa2999353c40f87f91b34d3bca619a9ef4727779
7
- data.tar.gz: ef5e7e701e18ba6749bb5829c1bd90624584419066f9b61076db8fc7418f1ae98799f144d1f3293a49b0dcdf34ff1f4b74b801f14bcd1ecc161c67a3be272e8f
6
+ metadata.gz: 46c3eb57bd9e9cd9e19b2c52682d7b92a645db9d996d97b095cf4ede803fd3b157b162198e76f5bdc2d85f9d372c5ac99b7a8c36d4d44b03e89916205b4c7eaf
7
+ data.tar.gz: 7fd270a4ba0a6ec123948af44beba92c82d91a41ae122cd68e6ef1f1d50e7a719a523560dfe87986c8bc481d6855dd25c238dbe6ef7f2a8d4a161e3e59cfe782
@@ -1,2 +1,30 @@
1
1
  require 'strategy/step'
2
2
  require 'strategy/plan'
3
+
4
+ module Strategy
5
+ # Convenience function to get a new Step quickly
6
+ #
7
+ # == Parameters:
8
+ # desc::
9
+ # The description of the new step
10
+ #
11
+ # == Returns:
12
+ # A Strategy::Step with the specified description
13
+ #
14
+ def self.step desc
15
+ Strategy::Step.new desc
16
+ end
17
+
18
+ # Convenience function to get a new Plan quickly
19
+ #
20
+ # == Parameters:
21
+ # desc::
22
+ # The description of the new plan
23
+ #
24
+ # == Returns:
25
+ # A Strategy::Plan with the specified description
26
+ #
27
+ def self.plan desc
28
+ Strategy::Plan.new desc
29
+ end
30
+ end
@@ -5,17 +5,17 @@ module Strategy
5
5
  # highest-level container around an execution strategy, and may contain as few
6
6
  # or as many Step objects as required.
7
7
  class Plan
8
- attr_reader :name, :steps
8
+ attr_reader :description, :steps
9
9
 
10
10
  # Create a new plan, to which individual execution steps will be added.
11
11
  #
12
12
  # == Parameters:
13
- # name::
14
- # The name of the execution plan. This is a short sentence which
13
+ # description::
14
+ # The description of the execution plan. This is a short sentence which
15
15
  # describes what the plan will do.
16
16
  #
17
- def initialize name
18
- @name = name
17
+ def initialize description
18
+ @description = description
19
19
  @steps = []
20
20
  end
21
21
 
@@ -41,7 +41,7 @@ module Strategy
41
41
  @steps.each do |step|
42
42
  n += 1
43
43
  if block_given?
44
- yield n, step.name
44
+ yield n, step.description
45
45
  end
46
46
  step.execute!
47
47
  end
@@ -51,10 +51,10 @@ module Strategy
51
51
  # a textual representation of the execution plan which can be displayed to a
52
52
  # user before executing anything for confirmation.
53
53
  def describe
54
- description = [@name]
54
+ description = [@description]
55
55
  n = 0
56
56
  @steps.each do |step|
57
- description << " #{n+=1}. #{step.name}"
57
+ description << " #{n+=1}. #{step.description}"
58
58
  end
59
59
  description.join "\n"
60
60
  end
@@ -3,17 +3,17 @@ module Strategy
3
3
  # contains a set of actions, which are the actual pieces of executable
4
4
  # code, as well as a high-level description of what the step accomplishes.
5
5
  class Step
6
- attr_reader :name, :actions
6
+ attr_reader :description, :actions
7
7
 
8
8
  # Creates a new Step, which can later be added to a Plan.
9
9
  #
10
10
  # == Parameters:
11
- # name::
12
- # The name of the step. This is a high-level description of what the
13
- # step is supposed to accomplish.
11
+ # description::
12
+ # The description of the step. This is a high-level description of what
13
+ # the step is supposed to accomplish.
14
14
  #
15
- def initialize name
16
- @name = name
15
+ def initialize description
16
+ @description = description
17
17
  @actions = []
18
18
  end
19
19
 
@@ -2,29 +2,29 @@ require 'spec_helper'
2
2
 
3
3
  describe 'Plan' do
4
4
  before :all do
5
- @plan = Strategy::Plan.new 'Test Plan'
5
+ @plan = Strategy.plan 'Test Plan'
6
6
 
7
- step = Strategy::Step.new 'Step 1'
7
+ step = Strategy.step 'Step 1'
8
8
  step.action { puts 1 }
9
9
  @plan.add step
10
10
 
11
- step = Strategy::Step.new 'Step 2'
11
+ step = Strategy.step 'Step 2'
12
12
  step.action { puts 2 }
13
13
  @plan.add step
14
14
  end
15
15
 
16
16
  it 'should add a description to the plan' do
17
- expect(@plan.name).to eq('Test Plan')
17
+ expect(@plan.description).to eq('Test Plan')
18
18
  end
19
19
 
20
20
  it 'should accept new steps' do
21
- step = Strategy::Step.new 'Step 3'
21
+ step = Strategy.step 'Step 3'
22
22
  step.action { puts 3 }
23
23
  @plan.add step
24
24
  expect(@plan.steps.length).to eq(3)
25
25
  end
26
26
 
27
- it 'should reflect the proper plan name' do
27
+ it 'should reflect the proper plan description' do
28
28
  expect(@plan.describe).to include('Test Plan')
29
29
  end
30
30
 
@@ -2,11 +2,11 @@ require 'spec_helper'
2
2
 
3
3
  describe 'Step' do
4
4
  before :all do
5
- @step = Strategy::Step.new 'Test Step'
5
+ @step = Strategy.step 'Test Step'
6
6
  end
7
7
 
8
- it 'should create a new step with proper name' do
9
- expect(@step.name).to eq('Test Step')
8
+ it 'should create a new step with proper description' do
9
+ expect(@step.description).to eq('Test Step')
10
10
  end
11
11
 
12
12
  it 'should add an action properly' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strategy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Uber