cloud_powers 0.2.7.18 → 0.2.7.19

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: 67494328df5302a9b4d213c72db3e9908242b29b
4
- data.tar.gz: 1b55bde60cf41b5c91e124adb701c28acdcee806
3
+ metadata.gz: add8b897e6b88171351687b3569a5dc467db297b
4
+ data.tar.gz: 63247946561f1847a897027f02c1207cf2ee86b6
5
5
  SHA512:
6
- metadata.gz: 437893087eaad11bd923a28752a13d577c964224e2a587aaf942d1fa5c05c5d36d5329b331f9d62fead7c7e2719d8508753e887e75feeae54a0da218ef53050b
7
- data.tar.gz: c3925079a69e4b58d74a8ea42d04e8c6df77fc46a366188e9bc03ccef87d613db65465f3879387507014b553a0bb3ae89d0181d03b0a02787ed92efa16678247
6
+ metadata.gz: c863eb713865222925ba6e93d3c3dfd1f63a8150e2092834839f6a2728e84f6352c0a429c4c856797269cd658ba7875ebc2c0cae0a7499f86ee00e227e424273
7
+ data.tar.gz: 3d57a7d912c85c21b35f8fbb72ef6c65f21b31ca407cbd55ff609f6a8ee83916ace37ee7f258777773169621a53ecddb7b2b3dd30c430ce33518b502d7ee5353
@@ -58,8 +58,7 @@ module Smash
58
58
  if approved_task? task
59
59
  source_task(task)
60
60
  require_relative task_require_path(task)
61
- # Smash.const_get(to_pascal(task)).new(id, body)
62
- Smash.const_get(to_pascal(task)).create(id, body)
61
+ Smash.const_get(to_pascal(task)).public_send :create, id, body
63
62
  else
64
63
  Smash::Task.new(id, body) # returns a default Task
65
64
  end
@@ -1,3 +1,3 @@
1
1
  module CloudPowers
2
- VERSION = '0.2.7.18'
2
+ VERSION = '0.2.7.19'
3
3
  end
@@ -39,10 +39,10 @@ module Smash
39
39
  # }
40
40
  # }
41
41
  #
42
- # ##Returns
42
+ # Returns
43
43
  # * +nil+
44
44
  #
45
- # ##Example
45
+ # Example
46
46
  # * build the workflow using the description from above
47
47
  # class Job
48
48
  # # code code code...
@@ -85,6 +85,7 @@ module Smash
85
85
  # # => :building
86
86
  #
87
87
  # Notes
88
+ # * See <tt>description_to_s()</tt>
88
89
  # * TODO: There has got to be a better way, so if any of you have suggestions...
89
90
  # The fact that the eval gets evaluated and invoked in the workflow gem
90
91
  # is of little comfort, despite how nice the gem is. Long story short,
@@ -92,6 +93,51 @@ module Smash
92
93
  # * see the workflow gem docs and question me if you want some nice ways
93
94
  # to really use this module. {workflow homepage}[https://github.com/geekq/workflow]
94
95
  def inject_workflow(description)
96
+ workflow_spec_string = description_to_s(description)
97
+ begin
98
+ self.class.class_eval(workflow_spec_string)
99
+ define_singleton_method(:has_workflow?) { true }
100
+ rescue Exception => e
101
+ define_singleton_method(:has_workflow?) { !!(puts e.backtrace) }
102
+ end
103
+ end
104
+
105
+ # Takes a description and turns it into a string that would describe the
106
+ # workflow you want to insert.
107
+ #
108
+ # Parameters
109
+ # * +description+ +Hash+ - of the format
110
+ # {
111
+ # workflow: {
112
+ # states: [
113
+ # { state_name: { event: :event_name, transitions_to: :transition_to_name } },
114
+ # { state_name: nil }
115
+ # ]
116
+ # }
117
+ # }
118
+ #
119
+ # Returns
120
+ # +String+
121
+ #
122
+ # Example
123
+ # # given the description seen in <tt>inject_workflow()</tt>
124
+ # puts description_to_s(description)
125
+ # # =>
126
+ # workflow do
127
+ # state :new do
128
+ # event :build, :transitions_to => :building
129
+ # end
130
+ # state :building do
131
+ # event :run, :transitions_to => :in_progress
132
+ # end
133
+ # state :in_progress do
134
+ # event :post_results, :transitions_to => :done
135
+ # end
136
+ # state :done
137
+ # end
138
+ # Notes
139
+ # * See <tt>inject_workflow()</tt>
140
+ def description_to_s(description)
95
141
  description_string_builder = ['include Workflow', 'workflow do']
96
142
  description[:workflow][:states].each do |state|
97
143
  state.map do |name, state_description|
@@ -107,12 +153,7 @@ module Smash
107
153
  end
108
154
  end
109
155
  description_string_builder << "end\n"
110
- begin
111
- self.class.class_eval(description_string_builder.join("\n"))
112
- define_singleton_method(:has_workflow?) { true }
113
- rescue Exception => e
114
- define_singleton_method(:has_workflow?) { !!(puts e.backtrace) }
115
- end
156
+ description_string_builder.join("\n")
116
157
  end
117
158
  end
118
159
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloud_powers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7.18
4
+ version: 0.2.7.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Phillipps
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-10-23 00:00:00.000000000 Z
12
+ date: 2016-10-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport-core-ext