runfile-tasks 0.5.7 → 1.0.0.rc2

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: 8540927e81a00c9ae4943ba8b22348105018c6471940616d869f13e28f43ff4d
4
- data.tar.gz: 64ab85feb969c969c90ee7d1d498c3459b388b856c54f2f59556872e91b2d53b
3
+ metadata.gz: 5a52180fe4c5515417c8d824ff37b289e5fe0cded7ec37e9e20ae1bc60eebde9
4
+ data.tar.gz: b7f3ace97f01eab2b9cdf6c1884ca5c53ea20efed7196ce4c9bce2451a124598
5
5
  SHA512:
6
- metadata.gz: 24ea3544b9293dcaee7fc14e9b0a5da597b34e0a5dd51cb31830740731b75f714d69da5858e8a1450c4e0ee43cb95222c66972356acca8de3743e7d36280bbbf
7
- data.tar.gz: fb4067ccfd42e876718b3c66eee95a6e4feb64b904ee0f3763e08992c1648aaa3ea89c249c03de1ccbef1fe874c1413a209aefd68efb8e504ac7d0f73ac19134
6
+ metadata.gz: bfaa1e699ce30ec6b129b1282c776fa4964035e7a5c029760769b7b326a9070107f22fc9a9e43146d29e10492a6b000c0606c3bfaa642b8432b5244e6398f896
7
+ data.tar.gz: ce63acc919c87660f7cf43df2f981995bce7195ae9cdd3a1eb9db05c90757f17fc9d8cd2f33627268b42fb501f4083ec84277a1b0828b26acf750069bdc1d6b6
data/README.md CHANGED
@@ -1,213 +1,43 @@
1
1
  # Runfile Tasks
2
2
 
3
- A library of tasks ready to be included in your [Runfile]
3
+ A library of tasks ready to be included in your [Runfile].
4
4
 
5
- ## Install
6
-
7
- Install the gem or require it in your Gemfile:
8
-
9
- ```ruby
10
- gem 'runfile-tasks'
11
- ```
12
-
13
- In your Runfile, you can include either all tasks:
14
-
15
- ```ruby
16
- require 'runfile-tasks'
17
- ```
18
-
19
- Or pick and choose from the various task categories:
20
-
21
- ```ruby
22
- require 'runfile-tasks/testing'
23
- ```
24
-
25
-
26
- Requiring the task packs does not make them available in your Runfile
27
- immediately. You need to activate any of the tasks you want as described
28
- below.
29
-
30
-
31
- ## Usage
32
-
33
- Include any of the tasks you need in your Runfile like this:
34
-
35
- ```ruby
36
- require 'runfile-tasks'
5
+ Note that this version of the gem is intended for Runfile version >= 1.0.
37
6
 
38
- name "Greeter"
39
- summary "A sample Runfile"
40
- version "0.1.0"
41
-
42
- # Include rdoc tasks and rspec tasks
43
- RunfileTasks::Docs.rdoc
44
- RunfileTasks::Testing.rspec
45
-
46
- # The rest of your Runfile goes here
47
- action :hello do
48
- puts "world"
49
- end
50
-
51
- ```
52
-
53
-
54
- ## Task Index
55
-
56
- ### Testing Tasks
57
-
58
- Require all testing tasks:
59
-
60
- ```ruby
61
- require 'runfile-tasks/testing'
62
- ```
63
-
64
- #### Testing with RSpec
65
-
66
- Commands Added:
67
-
68
- - `run spec [NAME] [TAG]` - Run all specs, a single spec file, or all specs
69
- matching a tag.
7
+ If you are using an older version of Runfile, you will also need to lock the
8
+ runfile-tasks version.
70
9
 
71
10
  ```ruby
72
- # Only require the rspec tasks
73
- require 'runfile-tasks/testing/rspec'
74
-
75
- # Include the rspec tasks with default configuration
76
- RunfileTasks::Testing.rspec
77
-
78
- # Set the Runfile action to 'test' instead of the default 'spec'
79
- RunfileTasks::Testing.rspec 'test'
80
-
81
- # Change the default options with a hash (these are the defaults)
82
- RunfileTasks::rspec action: 'spec',
83
- pattern: './spec/**/*_spec.rb', command: 'rspec'
84
-
11
+ gem 'runfile-tasks', '< 1.0'
85
12
  ```
86
13
 
14
+ ## Install
87
15
 
88
- #### Testing with Minitest
89
-
90
- Commands Added:
91
-
92
- - `test [NAME]` - Run all tests or a single test file.
93
-
94
- ```ruby
95
- # Only require the minitest tasks
96
- require 'runfile-tasks/testing/minitest'
97
-
98
- # Include the minitest tasks with default configuration
99
- RunfileTasks::Testing.minitest
100
-
101
- # Set the file pattern to look for (this is the default)
102
- RunfileTasks::Testing.minitest './test/*_test.rb'
103
-
104
- ```
105
-
106
- #### Testing with Cucumber
107
-
108
- Commands Added:
109
-
110
- - `(feature|features) [<tag_or_file> --list --fast]` - Run cucumber feature
111
- tests or show list of available features.
112
- - `stepdefs` - Generate a markdown document from the step definitions
113
-
114
- ```ruby
115
- # Only require the cucumber tasks
116
- require 'runfile-tasks/testing/cucumber'
117
-
118
- # Include the cucumber tasks with default configuration
119
- RunfileTasks::Testing.cucumber
120
-
121
- # Include the step definitions markdown generator
122
- RunfileTasks::Testing.cucumber_stepdefs
123
- ```
124
-
125
-
126
- ### Gem Authoring Tasks
127
-
128
- Commands Added:
129
-
130
- - `build [--install]` - Build gem from gemspec and move it to 'gems' folder.
131
- Use --install to also install it.
132
- - `install [--remote]` - Install gem from local gem file or from rubygems
133
- (--remote).
134
- - `publish` - Publish gem to rubygems. Make sure to 'run gem build' before
135
- you publish.
136
- - `yank [VERSION]` - Yank gem from rubygems.
137
-
138
-
139
- ```ruby
140
- require 'runfile-tasks/rubygems'
141
-
142
- # Include the tasks with default configuration. Pass in your gem name.
143
- RunfileTasks::RubyGems.all 'my-gem'
144
-
145
- # Set the folder where gems are copied after they are built (default)
146
- RunfileTasks::RubyGems.all 'my-gem', 'gems'
147
-
148
- # Include only the `build` and `install` tasks
149
- RunfileTasks::RubyGems.build 'my-gem'
16
+ Manually:
150
17
 
151
- # Include only the `publish` and `yank` tasks
152
- RunfileTasks::RubyGems.publish 'my-gem'
18
+ ```shell
19
+ $ gem install runfile-tasks
153
20
  ```
154
21
 
155
-
156
- ### Documentation Tasks
157
-
158
- Commands Added:
159
-
160
- - `rdoc [-- OPTIONS...]` - Generate documentation using the rdoc command
161
- line tool. To pass arguments to rdoc, place them after '--'.
162
-
22
+ With bundler:
163
23
 
164
24
  ```ruby
165
- require 'runfile-tasks/docs'
166
-
167
- # Include the tasks with default configuration.
168
- RunfileTasks::Docs.rdoc
169
-
170
- # Set the files to be considered (default below)
171
- RunfileTasks::Docs.rdoc '**/*.{rb,md}'
172
-
173
- # Pass any additional option directly to rdoc (defaults below)
174
- RunfileTasks::Docs.rdoc '**/*.{rb,md}', ["--main README.md", "--all",]
25
+ gem 'runfile-tasks'
175
26
  ```
176
27
 
28
+ ## Usage
177
29
 
178
- ### Docker Tasks
179
-
180
- Commands Added:
181
-
182
- - `docker build`
183
- - `docker test`
184
- - `docker push`
30
+ In your Runfile, use the `import_gem` directive to require any of the runfiles:
185
31
 
186
32
  ```ruby
187
- require 'runfile-tasks/docker'
188
-
189
- # Provide an image name and version
190
- RunfileTasks::Docker.all "dannyben/runfile", "0.1.0"
191
- ```
192
-
193
-
194
- ### Changelog Tasks
33
+ title 'My Runfile'
195
34
 
196
- This command requires that you have [github_changelog_generator] in your Gemfile.
197
-
198
- Commands Added:
199
-
200
- - `changelog [--commit]` - Generates a changelog and optionally commits it to the git repository.
201
-
202
-
203
- ```ruby
204
- require 'runfile-tasks/changelog'
35
+ # commands for building and publishing your gem
36
+ import_gem 'runfile-tasks/gem', gemname: 'my-gem'
205
37
 
206
- # Include the task and provide your github user/repo
207
- RunfileTasks::Changelog.generator "DannyBen/runfile"
38
+ # commands for building and publishing your Dockerfile
39
+ import_gem 'runfile-tasks/docker', image: 'my/image', version: '1.2.3'
208
40
  ```
209
41
 
210
42
  ---
211
43
  [Runfile]: https://github.com/DannyBen/runfile
212
- [random cat]: http://thecatapi.com/api/images/get
213
- [github_changelog_generator]: https://github.com/github-changelog-generator/github-changelog-generator
data/docker.runfile ADDED
@@ -0,0 +1,48 @@
1
+ title 'Docker image commands'
2
+ summary 'Add docker building and publishing commands to your project'
3
+
4
+ require_context :image
5
+ require_context :version
6
+
7
+ help 'Build the docker image'
8
+ action :build, :b do
9
+ say "g`Building docker image #{image}`"
10
+ run "docker build -t #{image} ."
11
+ run "docker tag #{image} #{image}:#{version}"
12
+ run "docker images | grep #{image}"
13
+ end
14
+
15
+ help 'Run the image with --version and compare it with the provided version'
16
+ action :test, :t do |_args|
17
+ docker_version = `docker run --rm #{image} --version`.chomp
18
+ if docker_version == version
19
+ say "g`PASS: docker version is #{docker_version}`"
20
+ else
21
+ say "r`FAIL: docker version is #{docker_version}, expected #{version}`"
22
+ 1
23
+ end
24
+ end
25
+
26
+ help 'Push the docker image to Docker Hub'
27
+ action :push, :p do
28
+ say "g`Pushing docker image #{image}`"
29
+ run "docker push #{image}"
30
+
31
+ say "g`Pushing docker image #{image}:#{version}`"
32
+ run "docker push #{image}:#{version}"
33
+ end
34
+
35
+ helpers do
36
+ def image
37
+ context[:image]
38
+ end
39
+
40
+ def version
41
+ context[:version]
42
+ end
43
+
44
+ def run(cmd)
45
+ say "$ m`#{cmd}`"
46
+ system cmd unless ENV['DRY_RUN']
47
+ end
48
+ end
data/gem.runfile ADDED
@@ -0,0 +1,65 @@
1
+ require 'fileutils'
2
+
3
+ title 'Gem management commands'
4
+ summary 'Add gem building and publishing to your gem project'
5
+
6
+ require_context :gemname
7
+
8
+ help 'Build and optionally install the gem'
9
+ usage '(build | b) [--install]'
10
+ option '--install, -i', 'Install after building'
11
+ action :build, :b do |args|
12
+ say "g`Building #{gemname}`"
13
+ run "gem build #{gemname}.gemspec --output #{gemfile}"
14
+ install_gem if args['--install']
15
+ end
16
+
17
+ help 'Install the last built gem'
18
+ action :install, :i do
19
+ need_gemfile
20
+ install_gem
21
+ end
22
+
23
+ help 'Publish gem to rubygems'
24
+ action :publish, :p do
25
+ need_gemfile
26
+ say 'g`Publishing gem`'
27
+ run "gem push #{gemfile}"
28
+ end
29
+
30
+ usage 'yank VERSION'
31
+ help 'Yank gem from rubygems'
32
+ action :yank do |args|
33
+ version = args['VERSION']
34
+ say 'rib` Yanking gem ` Are you sure?'
35
+ 10.downto(0) do |i|
36
+ say "Yanking in #{i} seconds - Ctrl-C to abort ", replace: true
37
+ sleep 1
38
+ end
39
+ say 'g`Yanking gem`', replace: true
40
+ run "gem yank #{gemname} -v #{version}"
41
+ end
42
+
43
+ helpers do
44
+ def gemname
45
+ context[:gemname]
46
+ end
47
+
48
+ def gemfile
49
+ "/tmp/#{gemname}.gem"
50
+ end
51
+
52
+ def run(cmd)
53
+ say "$ m`#{cmd}`"
54
+ system cmd unless ENV['DRY_RUN']
55
+ end
56
+
57
+ def install_gem
58
+ say "g`Installing #{gemname}`"
59
+ run "gem install --local #{gemfile}"
60
+ end
61
+
62
+ def need_gemfile
63
+ raise UserError, "File not found #{gemfile}" unless File.exist? gemfile
64
+ end
65
+ end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runfile-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7
4
+ version: 1.0.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-08 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: runfile
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.5'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '0.5'
11
+ date: 2023-01-26 00:00:00.000000000 Z
12
+ dependencies: []
27
13
  description: A collection of tasks for Runfile
28
14
  email: db@dannyben.com
29
15
  executables: []
@@ -31,29 +17,13 @@ extensions: []
31
17
  extra_rdoc_files: []
32
18
  files:
33
19
  - README.md
34
- - lib/runfile-tasks.rb
35
- - lib/runfile-tasks/all.rb
36
- - lib/runfile-tasks/changelog.rb
37
- - lib/runfile-tasks/docker.rb
38
- - lib/runfile-tasks/docker/all.rb
39
- - lib/runfile-tasks/docker/docker.rb
40
- - lib/runfile-tasks/docs.rb
41
- - lib/runfile-tasks/docs/all.rb
42
- - lib/runfile-tasks/docs/rdoc.rb
43
- - lib/runfile-tasks/refinements.rb
44
- - lib/runfile-tasks/rubygems.rb
45
- - lib/runfile-tasks/rubygems/all.rb
46
- - lib/runfile-tasks/rubygems/rubygems.rb
47
- - lib/runfile-tasks/testing.rb
48
- - lib/runfile-tasks/testing/all.rb
49
- - lib/runfile-tasks/testing/cucumber.rb
50
- - lib/runfile-tasks/testing/minitest.rb
51
- - lib/runfile-tasks/testing/rspec.rb
52
- - lib/runfile-tasks/version.rb
20
+ - docker.runfile
21
+ - gem.runfile
53
22
  homepage: https://github.com/DannyBen/runfile-tasks
54
23
  licenses:
55
24
  - MIT
56
- metadata: {}
25
+ metadata:
26
+ rubygems_mfa_required: 'true'
57
27
  post_install_message:
58
28
  rdoc_options: []
59
29
  require_paths:
@@ -62,14 +32,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
62
32
  requirements:
63
33
  - - ">="
64
34
  - !ruby/object:Gem::Version
65
- version: '0'
35
+ version: '2.7'
66
36
  required_rubygems_version: !ruby/object:Gem::Requirement
67
37
  requirements:
68
- - - ">="
38
+ - - ">"
69
39
  - !ruby/object:Gem::Version
70
- version: '0'
40
+ version: 1.3.1
71
41
  requirements: []
72
- rubygems_version: 3.3.26
42
+ rubygems_version: 3.4.5
73
43
  signing_key:
74
44
  specification_version: 4
75
45
  summary: Runfile tasks collection
@@ -1,7 +0,0 @@
1
- require "runfile-tasks/version"
2
-
3
- require "runfile-tasks/rubygems"
4
- require "runfile-tasks/docs"
5
- require "runfile-tasks/testing"
6
- require "runfile-tasks/changelog"
7
- require "runfile-tasks/docker"
@@ -1,18 +0,0 @@
1
- module RunfileTasks
2
- module Changelog
3
- extend self
4
-
5
- def generator(repo)
6
- usage "changelog [--commit]"
7
- help "Generate changelog"
8
- option "-c, --commit", "Also commit CHANGELOG.md"
9
- action :changelog do |args|
10
- user, project = repo.split "/"
11
- commit = args['--commit'] || args['--push']
12
-
13
- run "github_changelog_generator --project #{project} --user #{user}"
14
- run "git add CHANGELOG.md && git commit -m changelog CHANGELOG.md" if commit
15
- end
16
- end
17
- end
18
- end
@@ -1 +0,0 @@
1
- require 'runfile-tasks/docker/docker'
@@ -1,63 +0,0 @@
1
- require 'runfile-tasks/refinements'
2
-
3
- module RunfileTasks
4
- module Docker
5
- extend self
6
- using Refinements
7
-
8
- def all(image_name, image_version)
9
- build image_name, image_version
10
- test image_name, image_version
11
- push image_name, image_version
12
- end
13
-
14
- def build(image_name, image_version)
15
- command "docker"
16
-
17
- help "Build the docker image"
18
- action :build, :b do |args|
19
- puts "g`Building docker image #{image_name}`".in_color
20
- system "docker build -t #{image_name} ."
21
- system "docker tag #{image_name} #{image_name}:#{image_version}"
22
- system "docker images | grep #{image_name}"
23
- end
24
-
25
- endcommand
26
- end
27
-
28
- def test(image_name, image_version)
29
- command "docker"
30
-
31
- help "Test the --version flag in the dockerized version"
32
- action :test, :t do |args|
33
- docker_version = `docker run --rm #{image_name} --version`.chomp
34
- if docker_version != image_version
35
- puts "r`FAIL: docker version is #{docker_version}, expected #{image_version}`".in_color
36
- exit 1
37
- else
38
- puts "g`PASS: docker version is #{docker_version}`".in_color
39
- end
40
- end
41
-
42
- endcommand
43
- end
44
-
45
- def push(image_name, image_version)
46
- command "docker"
47
-
48
- help "Build the docker image"
49
- action :push, :p do |args|
50
- puts "g`Pushing docker image #{image_name}`".in_color
51
- system "docker push #{image_name}"
52
-
53
- puts "g`Pushing docker image #{image_name}:#{image_version}`".in_color
54
- system "docker push #{image_name}:#{image_version}"
55
- end
56
-
57
- endcommand
58
- end
59
-
60
-
61
- end
62
-
63
- end
@@ -1 +0,0 @@
1
- require 'runfile-tasks/docker/all'
@@ -1 +0,0 @@
1
- require 'runfile-tasks/docs/rdoc'
@@ -1,28 +0,0 @@
1
- require 'runfile-tasks/refinements'
2
-
3
- module RunfileTasks
4
- module Docs
5
- extend self
6
- using Refinements
7
-
8
- @@default_rdoc_options = [
9
- "--main README.md",
10
- "--all",
11
- ]
12
-
13
- def rdoc(files=nil, options=@@default_rdoc_options)
14
- files or files = Dir['**/*.{rb,md}']
15
- files = "'" + files.join("' '") + "'"
16
- usage "rdoc [-- OPTIONS...]"
17
- help "Generate documentation using the rdoc command line tool. To pass arguments to rdoc, place them after '--'."
18
- action :rdoc do |args|
19
- inopts = args['OPTIONS']
20
- options = inopts unless inopts.empty?
21
- options = options.join(' ')
22
- cmd = "rdoc #{options} #{files}"
23
- puts "g`Running:` p`#{cmd}`".in_color
24
- system cmd
25
- end
26
- end
27
- end
28
- end
@@ -1 +0,0 @@
1
- require 'runfile-tasks/docs/all'
@@ -1,18 +0,0 @@
1
- module RunfileTasks
2
- module Refinements
3
- refine String do
4
- def ansi_colors
5
- {
6
- r: "\e[31m", g: "\e[32m", y: "\e[33m",
7
- b: "\e[34m", p: "\e[35m", c: "\e[36m", n: "\e[0m"
8
- }
9
- end
10
-
11
- def in_color
12
- gsub /(r|g|y|b|p|c|n)\`([^\`]*)\`/ do |code, subtext|
13
- "#{ansi_colors[$1.to_sym]}#{$2}#{ansi_colors[:n]}"
14
- end
15
- end
16
- end
17
- end
18
- end
@@ -1 +0,0 @@
1
- require 'runfile-tasks/rubygems/rubygems'
@@ -1,83 +0,0 @@
1
- require 'fileutils'
2
- require 'runfile-tasks/refinements'
3
-
4
- module RunfileTasks
5
- module RubyGems
6
- extend self
7
- using Refinements
8
-
9
- def all(gemname, gemdir="gems")
10
- build gemname, gemdir
11
- publish gemname, gemdir
12
- end
13
-
14
- def build(gemname, gemdir="gems")
15
- gemver = get_gemver gemname
16
-
17
- command "gem"
18
-
19
- usage "build [--install]"
20
- help "Build gem from gemspec and move it to '#{gemdir}' folder.\nUse --install to also install it."
21
- action :build do |args|
22
- puts "g`Building gem`".in_color
23
- cmd = "gem build #{gemname}.gemspec"
24
- puts "g`Running:` p`#{cmd}`".in_color
25
- system cmd
26
- puts "g`Moving gem file to #{gemdir}`".in_color
27
- files = Dir["*.gem"]
28
- Dir.exist? gemdir or FileUtils.mkdir gemdir
29
- files.each {|f| FileUtils.mv f, gemdir }
30
- args['--install'] and execute "gem install"
31
- end
32
-
33
- usage "install [--remote]"
34
- help "Install gem from local gem file or from rubygems (--remote)."
35
- action :install do |args|
36
- if args['--remote']
37
- cmd = "gem install #{gemname}"
38
- else
39
- gemfile = "gems/#{gemname}-#{gemver}.gem"
40
- cmd = "gem install --local #{gemfile}"
41
- end
42
- puts "g`Running:` p`#{cmd}`".in_color
43
- system cmd
44
- end
45
-
46
- endcommand
47
- end
48
-
49
- def publish(gemname, gemdir="gems")
50
- gemver = get_gemver gemname
51
-
52
- command "gem"
53
-
54
- help "Publish gem to rubygems. Make sure to 'run gem build' before you publish."
55
- action :publish do
56
- gemfile = "gems/#{gemname}-#{gemver}.gem"
57
- File.exist? gemfile or abort "File not found #{gemfile}"
58
- cmd = "gem push #{gemfile}"
59
- puts "g`Running:` p`#{cmd}`".in_color
60
- system cmd
61
- end
62
-
63
- usage "yank [VERSION]"
64
- help "Yank gem from rubygems."
65
- action :yank do |args|
66
- ver = args['VERSION'] || gemver
67
- cmd = "gem yank #{gemname} -v #{ver}"
68
- puts "g`Running:` p`#{cmd}`".in_color
69
- system cmd
70
- end
71
-
72
- endcommand
73
- end
74
-
75
- def get_gemver(gemname)
76
- spec = Gem::Specification::load "#{gemname}.gemspec"
77
- spec or abort "Error loading #{gemname}.gemspec"
78
- spec.version.to_s
79
- end
80
-
81
- end
82
-
83
- end
@@ -1 +0,0 @@
1
- require 'runfile-tasks/rubygems/all'
@@ -1,3 +0,0 @@
1
- require 'runfile-tasks/testing/minitest'
2
- require 'runfile-tasks/testing/rspec'
3
- require 'runfile-tasks/testing/cucumber'
@@ -1,78 +0,0 @@
1
- require 'runfile-tasks/refinements'
2
-
3
- module RunfileTasks
4
- module Testing
5
- extend self
6
- using Refinements
7
-
8
- def cucumber
9
- usage "(feature|features) [TAG_OR_FILE --list --fast]"
10
- help "Run cucumber feature tests. Optionally, specify a tag or a filename to run. Tags should be prefixed with @."
11
- option "--list", "Show list of available features"
12
- option "--fast", "Abort on first failure"
13
- action :feature, :features do |args|
14
- if args['--list']
15
- show_cucumber_features
16
- else
17
- run_cucumber_features args['TAG_OR_FILE'], args['--fast']
18
- end
19
- end
20
- end
21
-
22
- def cucumber_stepdefs(filename='stepdefs.md')
23
- usage "stepdefs"
24
- help "Generate step definitions markdown document.\n" +
25
- "Comments in the step definition file that start with two or " +
26
- "more # characters, will also be added to the output " +
27
- "document, as captions."
28
- action :stepdefs do
29
- step = /^(Given|When|Then)\((\/.*\/)\) do.*$/
30
- caption = /^(\#{2,6} .*)$/
31
- files = Dir['features/step_definitions/**/*.rb']
32
- doc = []
33
- doc << "# Cucumber Step Definitions Summary\n"
34
- doc << "Generated by `run stepdefs`."
35
- files.each do |file|
36
- doc << "\n## #{File.basename(file, '.rb')}\n"
37
- File.readlines(file).each do |line|
38
- if matches = step.match(line)
39
- clause = matches.captures[0]
40
- definition = matches.captures[1] # .gsub /(".*?")/, '`__\1__`'
41
- doc << "- __`#{clause}`__ `#{definition}`"
42
- end
43
- if matches = caption.match(line)
44
- title = matches.captures[0]
45
- doc << "\n#{title}\n"
46
- end
47
- end
48
- end
49
- doc = doc.join "\n"
50
- File.write filename, doc
51
- puts "Generated #{filename}"
52
- end
53
- end
54
-
55
- def show_cucumber_features
56
- puts "g`Available Features:`".in_color
57
- Dir['features/**/*.feature'].each do |file|
58
- puts "- " + File.basename("#{file}", '.feature')
59
- end
60
- end
61
-
62
- def run_cucumber_features(tag_or_file, fast=false)
63
- cmd = "cucumber"
64
- if tag_or_file
65
- if tag_or_file[0] == '@'
66
- puts "g`Running features tagged #{tag_or_file}`".in_color
67
- cmd = "#{cmd} --tags #{tag_or_file}"
68
- else
69
- puts "g`Running #{tag_or_file} features`".in_color
70
- cmd = "#{cmd} 'features/#{tag_or_file}.feature'"
71
- end
72
- end
73
- cmd = "#{cmd} --fail-fast" if fast
74
- exec cmd
75
- end
76
-
77
- end
78
- end
@@ -1,26 +0,0 @@
1
- require 'runfile-tasks/refinements'
2
-
3
- module RunfileTasks
4
- module Testing
5
- extend self
6
- using Refinements
7
-
8
- def minitest(pattern="./test/*_test.rb")
9
- usage "test [NAME]"
10
- help "Run all tests or a single test file."
11
- action :test do |args|
12
- if args['NAME']
13
- file = pattern.sub "*", args['NAME']
14
- puts "g`Using:` p`#{file}`".in_color
15
- require file
16
- else
17
- Dir[pattern].each do |file|
18
- puts "g`Using:` p`#{file}`".in_color
19
- require file
20
- end
21
- end
22
- end
23
- end
24
-
25
- end
26
- end
@@ -1,52 +0,0 @@
1
- require 'runfile-tasks/refinements'
2
-
3
- module RunfileTasks
4
- module Testing
5
- extend self
6
- using Refinements
7
-
8
- def rspec(opts={})
9
- opts = { action: opts } if opts.is_a? String
10
-
11
- opts = {
12
- action: 'spec',
13
- pattern: './spec/**/*_spec.rb',
14
- command: 'rspec'
15
- }.merge opts
16
-
17
- usage_text = "[NAME] [TAG] [--next]"
18
- usage opts[:action] == :global ? usage_text : "#{opts[:action]} #{usage_text}"
19
- help "Run all specs or a single spec file matching a regex. You can provide a tag to run only specific tests. If you wish to provide a tag only, without a file pattern, simply prefix the tag with a colon, like 'run spec :focus'"
20
- option "-n --next", "Run with --next-failure"
21
- action opts[:action].to_sym do |args|
22
- file = args['NAME']
23
- tag = args['TAG']
24
- next_failure = args['--next']
25
-
26
- if file and file[0] == ':'
27
- tag = file
28
- file = nil
29
- end
30
-
31
- if tag and tag[0] == ':'
32
- tag = tag[1..-1]
33
- end
34
-
35
- if file
36
- files = Dir[opts[:pattern]]
37
- files.select! { |f| f =~ /#{file}/i }
38
- abort "Cannot find a matching spec file with #{opts[:pattern]}" if files.empty?
39
- file = files.first
40
- cmd = "#{opts[:command]} \"#{file}\""
41
- else
42
- cmd = "#{opts[:command]}"
43
- end
44
- cmd = "#{cmd} --tag #{tag}" if tag
45
- cmd = "#{cmd} --next-failure" if next_failure
46
- puts "g`Running:` p`#{cmd}`".in_color
47
- exec cmd
48
- end
49
- end
50
- end
51
-
52
- end
@@ -1 +0,0 @@
1
- require "runfile-tasks/testing/all"
@@ -1,3 +0,0 @@
1
- module RunfileTasks
2
- VERSION = "0.5.7"
3
- end
data/lib/runfile-tasks.rb DELETED
@@ -1 +0,0 @@
1
- require "runfile-tasks/all"