sleeping_king_studios-tasks 0.1.0.rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +26 -0
  3. data/DEVELOPMENT.md +50 -0
  4. data/LICENSE +22 -0
  5. data/README.md +405 -0
  6. data/lib/sleeping_king_studios/tasks.rb +27 -0
  7. data/lib/sleeping_king_studios/tasks/apps.rb +49 -0
  8. data/lib/sleeping_king_studios/tasks/apps/app_configuration.rb +68 -0
  9. data/lib/sleeping_king_studios/tasks/apps/applications_task.rb +28 -0
  10. data/lib/sleeping_king_studios/tasks/apps/bundle.rb +8 -0
  11. data/lib/sleeping_king_studios/tasks/apps/bundle/install_runner.rb +21 -0
  12. data/lib/sleeping_king_studios/tasks/apps/bundle/install_task.rb +39 -0
  13. data/lib/sleeping_king_studios/tasks/apps/bundle/update_runner.rb +21 -0
  14. data/lib/sleeping_king_studios/tasks/apps/bundle/update_task.rb +39 -0
  15. data/lib/sleeping_king_studios/tasks/apps/ci.rb +8 -0
  16. data/lib/sleeping_king_studios/tasks/apps/ci/results_reporter.rb +69 -0
  17. data/lib/sleeping_king_studios/tasks/apps/ci/rspec_task.rb +29 -0
  18. data/lib/sleeping_king_studios/tasks/apps/ci/rspec_wrapper.rb +42 -0
  19. data/lib/sleeping_king_studios/tasks/apps/ci/rubocop_task.rb +29 -0
  20. data/lib/sleeping_king_studios/tasks/apps/ci/rubocop_wrapper.rb +29 -0
  21. data/lib/sleeping_king_studios/tasks/apps/ci/simplecov_task.rb +68 -0
  22. data/lib/sleeping_king_studios/tasks/apps/ci/step_wrapper.rb +49 -0
  23. data/lib/sleeping_king_studios/tasks/apps/ci/steps_runner.rb +37 -0
  24. data/lib/sleeping_king_studios/tasks/apps/ci/steps_task.rb +92 -0
  25. data/lib/sleeping_king_studios/tasks/ci.rb +8 -0
  26. data/lib/sleeping_king_studios/tasks/ci/cucumber_parser.rb +118 -0
  27. data/lib/sleeping_king_studios/tasks/ci/cucumber_results.rb +191 -0
  28. data/lib/sleeping_king_studios/tasks/ci/cucumber_runner.rb +53 -0
  29. data/lib/sleeping_king_studios/tasks/ci/cucumber_task.rb +47 -0
  30. data/lib/sleeping_king_studios/tasks/ci/results_helpers.rb +44 -0
  31. data/lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb +118 -0
  32. data/lib/sleeping_king_studios/tasks/ci/rspec_each_task.rb +156 -0
  33. data/lib/sleeping_king_studios/tasks/ci/rspec_results.rb +126 -0
  34. data/lib/sleeping_king_studios/tasks/ci/rspec_runner.rb +62 -0
  35. data/lib/sleeping_king_studios/tasks/ci/rspec_task.rb +71 -0
  36. data/lib/sleeping_king_studios/tasks/ci/rubocop_results.rb +80 -0
  37. data/lib/sleeping_king_studios/tasks/ci/rubocop_runner.rb +46 -0
  38. data/lib/sleeping_king_studios/tasks/ci/rubocop_task.rb +44 -0
  39. data/lib/sleeping_king_studios/tasks/ci/simplecov_results.rb +62 -0
  40. data/lib/sleeping_king_studios/tasks/ci/simplecov_task.rb +25 -0
  41. data/lib/sleeping_king_studios/tasks/ci/steps_runner.rb +69 -0
  42. data/lib/sleeping_king_studios/tasks/ci/steps_task.rb +93 -0
  43. data/lib/sleeping_king_studios/tasks/configuration.rb +114 -0
  44. data/lib/sleeping_king_studios/tasks/file.rb +8 -0
  45. data/lib/sleeping_king_studios/tasks/file/new_task.rb +238 -0
  46. data/lib/sleeping_king_studios/tasks/process_runner.rb +70 -0
  47. data/lib/sleeping_king_studios/tasks/task.rb +95 -0
  48. data/lib/sleeping_king_studios/tasks/task_group.rb +37 -0
  49. data/lib/sleeping_king_studios/tasks/version.rb +58 -0
  50. metadata +271 -0
@@ -0,0 +1,70 @@
1
+ # lib/sleeping_king_studios/tasks/process_runner.rb
2
+
3
+ require 'sleeping_king_studios/tasks'
4
+
5
+ module SleepingKingStudios::Tasks
6
+ # Base class for helpers that execute a system process.
7
+ class ProcessRunner
8
+ # @param env [Hash] Environment variables to set for the RSpec process.
9
+ # @param options [Array] Options to pass to RSpec.
10
+ def initialize env: {}, options: []
11
+ @default_env = env.dup
12
+ @default_options = options
13
+
14
+ return unless ENV['BUNDLE_GEMFILE']
15
+
16
+ @default_env[:bundle_gemfile] ||= ENV['BUNDLE_GEMFILE']
17
+ end # constructor
18
+
19
+ # @return [Hash] Environment variables to set for the RSpec process.
20
+ attr_reader :default_env
21
+
22
+ # @return [Array] Options to pass to RSpec.
23
+ attr_reader :default_options
24
+
25
+ private
26
+
27
+ def base_command
28
+ ':'
29
+ end # method base_command
30
+
31
+ def build_command **kwargs
32
+ env = build_environment(kwargs)
33
+ opts = build_options(kwargs)
34
+
35
+ "#{env} #{base_command} #{opts}".strip
36
+ end # method build_command
37
+
38
+ def build_environment env:, **_kwargs
39
+ default_env.
40
+ merge(env).
41
+ map do |key, value|
42
+ key = tools.string.underscore(key).upcase
43
+ value = %("#{value}") if value.is_a?(String)
44
+
45
+ "#{key}=#{value}"
46
+ end. # map
47
+ join ' '
48
+ end # method build_environment
49
+
50
+ def build_options files: [], options: [], **_kwargs
51
+ (Array(files) + default_options + options).join ' '
52
+ end # method build_options
53
+
54
+ def stream_process command
55
+ Bundler.with_clean_env do
56
+ IO.popen(command) do |io|
57
+ loop do
58
+ char = io.getc
59
+
60
+ char ? print(char) : break
61
+ end # loop
62
+ end # popen
63
+ end # with_clean_env
64
+ end # method stream_process
65
+
66
+ def tools
67
+ SleepingKingStudios::Tools::Toolbelt.new
68
+ end # method tools
69
+ end # class
70
+ end # module
@@ -0,0 +1,95 @@
1
+ # lib/sleeping_king_studios/tasks/task.rb
2
+
3
+ require 'thor'
4
+
5
+ require 'sleeping_king_studios/tasks'
6
+
7
+ module SleepingKingStudios::Tasks
8
+ # Encapsulates a Thor task as a class object.
9
+ class Task
10
+ include ::Thor::Shell
11
+
12
+ module ClassMethods # rubocop:disable Style/Documentation
13
+ # @return [String] The description of the task.
14
+ def description
15
+ 'A non-descript task if ever there was one.'
16
+ end # method description
17
+
18
+ # Defines a permitted option for the task.
19
+ #
20
+ # @param option_name [String, Symbol] The name of the option.
21
+ # @param option_params [Hash] Additional params for the option.
22
+ #
23
+ # @see https://github.com/erikhuda/thor/wiki/Method-Options
24
+ def option option_name, option_params
25
+ options[option_name] = option_params
26
+
27
+ define_helpers option_name, option_params
28
+ end # method option
29
+
30
+ # @return [Hash] The permitted options for the task.
31
+ def options
32
+ @options ||= {}
33
+ end # method options
34
+
35
+ # @return [String] The name of the task.
36
+ def task_name
37
+ tools = SleepingKingStudios::Tools::Toolbelt.instance
38
+
39
+ tools.string.underscore(name.split('::').last).sub(/_task$/, '')
40
+ end # method task_name
41
+
42
+ private
43
+
44
+ def define_helpers option_name, option_params
45
+ tools = SleepingKingStudios::Tools::Toolbelt.instance
46
+ name = tools.string.underscore option_name
47
+
48
+ define_method(name) { options[option_name.to_s] }
49
+
50
+ return unless option_params[:type] == :boolean
51
+
52
+ default = option_params.fetch(:default, false)
53
+ define_method(:"#{name}?") { options.fetch(option_name.to_s, default) }
54
+ end # method define_helpers
55
+ end # module
56
+ extend ClassMethods
57
+
58
+ # @param options [Hash] The command-line options passed in via Thor.
59
+ def initialize options
60
+ @options = options
61
+ end # constructor
62
+
63
+ # @return [Hash] The command-line options passed in via Thor.
64
+ attr_reader :options
65
+
66
+ # Performs the task with the given arguments. Overriden by subclasses.
67
+ def call *_args; end
68
+
69
+ # Mutes the task.
70
+ def mute!
71
+ @mute = true
72
+ end # method mute!
73
+
74
+ # @return [Boolean] True if the task has been muted, otherwise false.
75
+ def mute?
76
+ !!@mute
77
+ end # method mute?
78
+ alias_method :muted?, :mute?
79
+
80
+ # Prints the given message unless the task has been muted.
81
+ #
82
+ # @see Thor::Shell#say.
83
+ def say *args
84
+ return if mute?
85
+
86
+ super
87
+ end # method say
88
+
89
+ private
90
+
91
+ def tools
92
+ SleepingKingStudios::Tools::Toolbelt.instance
93
+ end # method tools
94
+ end # class
95
+ end # module
@@ -0,0 +1,37 @@
1
+ # lib/sleeping_king_studios/tasks/task_group.rb
2
+
3
+ require 'thor'
4
+
5
+ require 'sleeping_king_studios/tasks'
6
+
7
+ module SleepingKingStudios::Tasks
8
+ # Exposes a group of encapsulated tasks with a shared namespace to Thor.
9
+ class TaskGroup < ::Thor
10
+ module ClassMethods # rubocop:disable Style/Documentation
11
+ # Adds a task definition to the task group. The task name, description,
12
+ # and method options (if any) are resolved from the task class, and a
13
+ # wrapper method is defined for calling the task.
14
+ def task definition, options = {}
15
+ task_name = options.fetch(:as, definition.task_name)
16
+
17
+ desc(task_name, definition.description)
18
+
19
+ definition.options.each do |option_name, option_params|
20
+ method_option option_name, option_params
21
+ end # each
22
+
23
+ define_method(task_name) do |*args|
24
+ definition.new(self.options).call(*args)
25
+ end # define_method
26
+ end # class method task
27
+
28
+ # @return [Boolean] True.
29
+ def exit_on_failure?
30
+ # :nocov:
31
+ true
32
+ # :nocov:
33
+ end # class method exit_on_failure?
34
+ end # module
35
+ extend ClassMethods
36
+ end # class
37
+ end # module
@@ -0,0 +1,58 @@
1
+ # lib/sleeping_king_studios/tasks/version.rb
2
+
3
+ module SleepingKingStudios
4
+ module Tasks
5
+ # @api private
6
+ #
7
+ # The current version of the gem.
8
+ #
9
+ # @see http://semver.org/
10
+ module Version
11
+ # Major version.
12
+ MAJOR = 0
13
+ # Minor version.
14
+ MINOR = 1
15
+ # Patch version.
16
+ PATCH = 0
17
+ # Prerelease version.
18
+ PRERELEASE = :rc
19
+ # Build metadata.
20
+ BUILD = 0
21
+
22
+ class << self
23
+ # Generates the gem version string from the Version constants.
24
+ #
25
+ # Inlined here because dependencies may not be loaded when processing a
26
+ # gemspec, which results in the user being unable to install the gem for
27
+ # the first time.
28
+ #
29
+ # @see SleepingKingStudios::Tools::SemanticVersion#to_gem_version
30
+ def to_gem_version
31
+ str = "#{MAJOR}.#{MINOR}.#{PATCH}"
32
+
33
+ prerelease = value_of(:PRERELEASE)
34
+ str << ".#{prerelease}" if prerelease
35
+
36
+ build = value_of(:BUILD)
37
+ str << ".#{build}" if build
38
+
39
+ str
40
+ end # class method to_version
41
+
42
+ private
43
+
44
+ def value_of constant
45
+ return nil unless const_defined?(constant)
46
+
47
+ value = const_get(constant)
48
+
49
+ return nil if value.respond_to?(:empty?) && value.empty?
50
+
51
+ value
52
+ end # method value_of
53
+ end # eigenclass
54
+ end # module
55
+
56
+ VERSION = Version.to_gem_version
57
+ end # module
58
+ end # module
metadata ADDED
@@ -0,0 +1,271 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sleeping_king_studios-tasks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.rc.0
5
+ platform: ruby
6
+ authors:
7
+ - Rob "Merlin" Smith
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-06-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '12.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '12.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.19'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.19.4
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '0.19'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.19.4
47
+ - !ruby/object:Gem::Dependency
48
+ name: sleeping_king_studios-tools
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 0.7.1
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 0.7.1
61
+ - !ruby/object:Gem::Dependency
62
+ name: erubi
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.6'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.6'
75
+ - !ruby/object:Gem::Dependency
76
+ name: byebug
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '9.0'
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 9.0.6
85
+ type: :development
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '9.0'
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 9.0.6
95
+ - !ruby/object:Gem::Dependency
96
+ name: rspec
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '3.5'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: '3.5'
109
+ - !ruby/object:Gem::Dependency
110
+ name: rspec-sleeping_king_studios
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: '2.2'
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: 2.2.3
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '2.2'
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: 2.2.3
129
+ - !ruby/object:Gem::Dependency
130
+ name: rubocop
131
+ requirement: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - "~>"
134
+ - !ruby/object:Gem::Version
135
+ version: 0.47.0
136
+ type: :development
137
+ prerelease: false
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - "~>"
141
+ - !ruby/object:Gem::Version
142
+ version: 0.47.0
143
+ - !ruby/object:Gem::Dependency
144
+ name: cucumber
145
+ requirement: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - "~>"
148
+ - !ruby/object:Gem::Version
149
+ version: '2.4'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - "~>"
155
+ - !ruby/object:Gem::Version
156
+ version: '2.4'
157
+ - !ruby/object:Gem::Dependency
158
+ name: simplecov
159
+ requirement: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - "~>"
162
+ - !ruby/object:Gem::Version
163
+ version: '0.14'
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: 0.14.1
167
+ type: :development
168
+ prerelease: false
169
+ version_requirements: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '0.14'
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: 0.14.1
177
+ - !ruby/object:Gem::Dependency
178
+ name: simplecov-json
179
+ requirement: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - "~>"
182
+ - !ruby/object:Gem::Version
183
+ version: '0.2'
184
+ type: :development
185
+ prerelease: false
186
+ version_requirements: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - "~>"
189
+ - !ruby/object:Gem::Version
190
+ version: '0.2'
191
+ description: Toolkit providing an encapsulation layer around the Thor CLI library,
192
+ with predefined tasks for development and continuous integration.
193
+ email:
194
+ - merlin@sleepingkingstudios.com
195
+ executables: []
196
+ extensions: []
197
+ extra_rdoc_files: []
198
+ files:
199
+ - CHANGELOG.md
200
+ - DEVELOPMENT.md
201
+ - LICENSE
202
+ - README.md
203
+ - lib/sleeping_king_studios/tasks.rb
204
+ - lib/sleeping_king_studios/tasks/apps.rb
205
+ - lib/sleeping_king_studios/tasks/apps/app_configuration.rb
206
+ - lib/sleeping_king_studios/tasks/apps/applications_task.rb
207
+ - lib/sleeping_king_studios/tasks/apps/bundle.rb
208
+ - lib/sleeping_king_studios/tasks/apps/bundle/install_runner.rb
209
+ - lib/sleeping_king_studios/tasks/apps/bundle/install_task.rb
210
+ - lib/sleeping_king_studios/tasks/apps/bundle/update_runner.rb
211
+ - lib/sleeping_king_studios/tasks/apps/bundle/update_task.rb
212
+ - lib/sleeping_king_studios/tasks/apps/ci.rb
213
+ - lib/sleeping_king_studios/tasks/apps/ci/results_reporter.rb
214
+ - lib/sleeping_king_studios/tasks/apps/ci/rspec_task.rb
215
+ - lib/sleeping_king_studios/tasks/apps/ci/rspec_wrapper.rb
216
+ - lib/sleeping_king_studios/tasks/apps/ci/rubocop_task.rb
217
+ - lib/sleeping_king_studios/tasks/apps/ci/rubocop_wrapper.rb
218
+ - lib/sleeping_king_studios/tasks/apps/ci/simplecov_task.rb
219
+ - lib/sleeping_king_studios/tasks/apps/ci/step_wrapper.rb
220
+ - lib/sleeping_king_studios/tasks/apps/ci/steps_runner.rb
221
+ - lib/sleeping_king_studios/tasks/apps/ci/steps_task.rb
222
+ - lib/sleeping_king_studios/tasks/ci.rb
223
+ - lib/sleeping_king_studios/tasks/ci/cucumber_parser.rb
224
+ - lib/sleeping_king_studios/tasks/ci/cucumber_results.rb
225
+ - lib/sleeping_king_studios/tasks/ci/cucumber_runner.rb
226
+ - lib/sleeping_king_studios/tasks/ci/cucumber_task.rb
227
+ - lib/sleeping_king_studios/tasks/ci/results_helpers.rb
228
+ - lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb
229
+ - lib/sleeping_king_studios/tasks/ci/rspec_each_task.rb
230
+ - lib/sleeping_king_studios/tasks/ci/rspec_results.rb
231
+ - lib/sleeping_king_studios/tasks/ci/rspec_runner.rb
232
+ - lib/sleeping_king_studios/tasks/ci/rspec_task.rb
233
+ - lib/sleeping_king_studios/tasks/ci/rubocop_results.rb
234
+ - lib/sleeping_king_studios/tasks/ci/rubocop_runner.rb
235
+ - lib/sleeping_king_studios/tasks/ci/rubocop_task.rb
236
+ - lib/sleeping_king_studios/tasks/ci/simplecov_results.rb
237
+ - lib/sleeping_king_studios/tasks/ci/simplecov_task.rb
238
+ - lib/sleeping_king_studios/tasks/ci/steps_runner.rb
239
+ - lib/sleeping_king_studios/tasks/ci/steps_task.rb
240
+ - lib/sleeping_king_studios/tasks/configuration.rb
241
+ - lib/sleeping_king_studios/tasks/file.rb
242
+ - lib/sleeping_king_studios/tasks/file/new_task.rb
243
+ - lib/sleeping_king_studios/tasks/process_runner.rb
244
+ - lib/sleeping_king_studios/tasks/task.rb
245
+ - lib/sleeping_king_studios/tasks/task_group.rb
246
+ - lib/sleeping_king_studios/tasks/version.rb
247
+ homepage: http://sleepingkingstudios.com
248
+ licenses:
249
+ - MIT
250
+ metadata: {}
251
+ post_install_message:
252
+ rdoc_options: []
253
+ require_paths:
254
+ - lib
255
+ required_ruby_version: !ruby/object:Gem::Requirement
256
+ requirements:
257
+ - - ">="
258
+ - !ruby/object:Gem::Version
259
+ version: '0'
260
+ required_rubygems_version: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - ">"
263
+ - !ruby/object:Gem::Version
264
+ version: 1.3.1
265
+ requirements: []
266
+ rubyforge_project:
267
+ rubygems_version: 2.6.11
268
+ signing_key:
269
+ specification_version: 4
270
+ summary: A tasks toolkit for rapid development.
271
+ test_files: []