runfile-tasks 0.5.2 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +213 -202
- data/lib/runfile-tasks/all.rb +7 -6
- data/lib/runfile-tasks/docker/all.rb +1 -0
- data/lib/runfile-tasks/docker/docker.rb +63 -0
- data/lib/runfile-tasks/docker.rb +1 -0
- data/lib/runfile-tasks/docs/rdoc.rb +27 -24
- data/lib/runfile-tasks/refinements.rb +18 -0
- data/lib/runfile-tasks/rubygems/rubygems.rb +8 -6
- data/lib/runfile-tasks/testing/cucumber.rb +78 -75
- data/lib/runfile-tasks/testing/minitest.rb +25 -22
- data/lib/runfile-tasks/testing/rspec.rb +5 -2
- data/lib/runfile-tasks/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a5fad61f13a335cf1230f07c8d9a3f5e9184de8ff31b73c3cf2491c86201c58
|
4
|
+
data.tar.gz: 8f86100db2424cc7e91c77de8a9246901725b6892d94ca69a52576d99db3b708
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56fb6589a54059c054e532f398e7626852d29302e50656d208e39b3de8a26d896fc062156679daf559592de1d3467daf4cb3ace37e4f345ae9872d303f4e8db7
|
7
|
+
data.tar.gz: 56915a3b25bd9e6eb8262f624f28aedc434e0dfa72f651017734399cddec43e67a42412a8d9bb1740652234d611e17ea364dcf6d1b059b278fd9037454f4720c
|
data/README.md
CHANGED
@@ -1,202 +1,213 @@
|
|
1
|
-
Runfile Tasks
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
```
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
```
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
```
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
#
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
[
|
201
|
-
|
202
|
-
|
1
|
+
# Runfile Tasks
|
2
|
+
|
3
|
+
A library of tasks ready to be included in your [Runfile]
|
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'
|
37
|
+
|
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.
|
70
|
+
|
71
|
+
```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
|
+
|
85
|
+
```
|
86
|
+
|
87
|
+
|
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'
|
150
|
+
|
151
|
+
# Include only the `publish` and `yank` tasks
|
152
|
+
RunfileTasks::RubyGems.publish 'my-gem'
|
153
|
+
```
|
154
|
+
|
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
|
+
|
163
|
+
|
164
|
+
```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",]
|
175
|
+
```
|
176
|
+
|
177
|
+
|
178
|
+
### Docker Tasks
|
179
|
+
|
180
|
+
Commands Added:
|
181
|
+
|
182
|
+
- `docker build`
|
183
|
+
- `docker test`
|
184
|
+
- `docker push`
|
185
|
+
|
186
|
+
```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
|
195
|
+
|
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'
|
205
|
+
|
206
|
+
# Include the task and provide your github user/repo
|
207
|
+
RunfileTasks::Changelog.generator "DannyBen/runfile"
|
208
|
+
```
|
209
|
+
|
210
|
+
---
|
211
|
+
[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/lib/runfile-tasks/all.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
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"
|
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"
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'runfile-tasks/docker/docker'
|
@@ -0,0 +1,63 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'runfile-tasks/docker/all'
|
@@ -1,25 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
25
28
|
end
|
@@ -0,0 +1,18 @@
|
|
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,8 +1,10 @@
|
|
1
1
|
require 'fileutils'
|
2
|
+
require 'runfile-tasks/refinements'
|
2
3
|
|
3
4
|
module RunfileTasks
|
4
5
|
module RubyGems
|
5
6
|
extend self
|
7
|
+
using Refinements
|
6
8
|
|
7
9
|
def all(gemname, gemdir="gems")
|
8
10
|
build gemname, gemdir
|
@@ -17,11 +19,11 @@ module RunfileTasks
|
|
17
19
|
usage "build [--install]"
|
18
20
|
help "Build gem from gemspec and move it to '#{gemdir}' folder.\nUse --install to also install it."
|
19
21
|
action :build do |args|
|
20
|
-
|
22
|
+
puts "g`Building gem`".in_color
|
21
23
|
cmd = "gem build #{gemname}.gemspec"
|
22
|
-
|
24
|
+
puts "g`Running:` p`#{cmd}`".in_color
|
23
25
|
system cmd
|
24
|
-
|
26
|
+
puts "g`Moving gem file to #{gemdir}`".in_color
|
25
27
|
files = Dir["*.gem"]
|
26
28
|
Dir.exist? gemdir or FileUtils.mkdir gemdir
|
27
29
|
files.each {|f| FileUtils.mv f, gemdir }
|
@@ -37,7 +39,7 @@ module RunfileTasks
|
|
37
39
|
gemfile = "gems/#{gemname}-#{gemver}.gem"
|
38
40
|
cmd = "gem install #{gemfile}"
|
39
41
|
end
|
40
|
-
|
42
|
+
puts "g`Running:` p`#{cmd}`".in_color
|
41
43
|
system cmd
|
42
44
|
end
|
43
45
|
|
@@ -54,7 +56,7 @@ module RunfileTasks
|
|
54
56
|
gemfile = "gems/#{gemname}-#{gemver}.gem"
|
55
57
|
File.exist? gemfile or abort "File not found #{gemfile}"
|
56
58
|
cmd = "gem push #{gemfile}"
|
57
|
-
|
59
|
+
puts "g`Running:` p`#{cmd}`".in_color
|
58
60
|
system cmd
|
59
61
|
end
|
60
62
|
|
@@ -63,7 +65,7 @@ module RunfileTasks
|
|
63
65
|
action :yank do |args|
|
64
66
|
ver = args['VERSION'] || gemver
|
65
67
|
cmd = "gem yank #{gemname} -v #{ver}"
|
66
|
-
|
68
|
+
puts "g`Running:` p`#{cmd}`".in_color
|
67
69
|
system cmd
|
68
70
|
end
|
69
71
|
|
@@ -1,75 +1,78 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
cmd = "#{cmd}
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
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,23 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
23
26
|
end
|
@@ -1,6 +1,9 @@
|
|
1
|
+
require 'runfile-tasks/refinements'
|
2
|
+
|
1
3
|
module RunfileTasks
|
2
4
|
module Testing
|
3
5
|
extend self
|
6
|
+
using Refinements
|
4
7
|
|
5
8
|
def rspec(opts={})
|
6
9
|
opts = { action: opts } if opts.is_a? String
|
@@ -11,7 +14,7 @@ module RunfileTasks
|
|
11
14
|
command: 'rspec'
|
12
15
|
}.merge opts
|
13
16
|
|
14
|
-
usage "#{opts[:action]} [NAME] [TAG]"
|
17
|
+
usage opts[:action] == :global ? "[NAME] [TAG]" : "#{opts[:action]} [NAME] [TAG]"
|
15
18
|
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'"
|
16
19
|
action opts[:action].to_sym do |args|
|
17
20
|
file = args['NAME']
|
@@ -36,7 +39,7 @@ module RunfileTasks
|
|
36
39
|
cmd = "#{opts[:command]}"
|
37
40
|
end
|
38
41
|
cmd = "#{cmd} --tag #{tag}" if tag
|
39
|
-
|
42
|
+
puts "g`Running:` p`#{cmd}`".in_color
|
40
43
|
exec cmd
|
41
44
|
end
|
42
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runfile-tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
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:
|
11
|
+
date: 2022-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: runfile
|
@@ -34,9 +34,13 @@ files:
|
|
34
34
|
- lib/runfile-tasks.rb
|
35
35
|
- lib/runfile-tasks/all.rb
|
36
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
|
37
40
|
- lib/runfile-tasks/docs.rb
|
38
41
|
- lib/runfile-tasks/docs/all.rb
|
39
42
|
- lib/runfile-tasks/docs/rdoc.rb
|
43
|
+
- lib/runfile-tasks/refinements.rb
|
40
44
|
- lib/runfile-tasks/rubygems.rb
|
41
45
|
- lib/runfile-tasks/rubygems/all.rb
|
42
46
|
- lib/runfile-tasks/rubygems/rubygems.rb
|
@@ -65,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
69
|
- !ruby/object:Gem::Version
|
66
70
|
version: '0'
|
67
71
|
requirements: []
|
68
|
-
rubygems_version: 3.
|
72
|
+
rubygems_version: 3.3.3
|
69
73
|
signing_key:
|
70
74
|
specification_version: 4
|
71
75
|
summary: Runfile tasks collection
|