runfile-tasks 0.5.7 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -188
- data/docker.runfile +48 -0
- data/gem.runfile +68 -0
- metadata +9 -39
- data/lib/runfile-tasks/all.rb +0 -7
- data/lib/runfile-tasks/changelog.rb +0 -18
- data/lib/runfile-tasks/docker/all.rb +0 -1
- data/lib/runfile-tasks/docker/docker.rb +0 -63
- data/lib/runfile-tasks/docker.rb +0 -1
- data/lib/runfile-tasks/docs/all.rb +0 -1
- data/lib/runfile-tasks/docs/rdoc.rb +0 -28
- data/lib/runfile-tasks/docs.rb +0 -1
- data/lib/runfile-tasks/refinements.rb +0 -18
- data/lib/runfile-tasks/rubygems/all.rb +0 -1
- data/lib/runfile-tasks/rubygems/rubygems.rb +0 -83
- data/lib/runfile-tasks/rubygems.rb +0 -1
- data/lib/runfile-tasks/testing/all.rb +0 -3
- data/lib/runfile-tasks/testing/cucumber.rb +0 -78
- data/lib/runfile-tasks/testing/minitest.rb +0 -26
- data/lib/runfile-tasks/testing/rspec.rb +0 -52
- data/lib/runfile-tasks/testing.rb +0 -1
- data/lib/runfile-tasks/version.rb +0 -3
- data/lib/runfile-tasks.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67f6533fc2c505ad0a6446287e3a260ad74a6c83a8b31ae5c7a78728fb4fd7f2
|
4
|
+
data.tar.gz: b1f4822b7dac241adb5e055ac3b01ae73d4d6a20ee1301b23191da636e0f9a58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caf4ee112f5d01340c26d391156ee61ea08257625a8356f618ee882486488f589c52e84ca1c290b353d37f529b0ba3857acee6d1325a0768979b4056f3b8c4cf
|
7
|
+
data.tar.gz: 237bf631a951e5c52b7d546761ce42edc1fc0352a935da2a87d699c7d1d3709860ac90408e944b95d84e3033587879ffd26302bf03ce40dce9e65cd3749ec74d
|
data/README.md
CHANGED
@@ -1,213 +1,45 @@
|
|
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
|
-
|
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
|
-
|
39
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
152
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
197
|
-
|
198
|
-
|
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'
|
37
|
+
# or without publish/yank actions
|
38
|
+
import_gem 'runfile-tasks/gem', gemname: 'my-gem', private: true
|
205
39
|
|
206
|
-
#
|
207
|
-
|
40
|
+
# commands for building and publishing your Dockerfile
|
41
|
+
import_gem 'runfile-tasks/docker', image: 'my/image', version: '1.2.3'
|
208
42
|
```
|
209
43
|
|
210
44
|
---
|
211
45
|
[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 'Ddocker building and publishing commands'
|
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,68 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
title 'Gem management commands'
|
4
|
+
summary 'Gem building and publishing commands'
|
5
|
+
|
6
|
+
require_context :gemname
|
7
|
+
require_context :private, default: false
|
8
|
+
|
9
|
+
help 'Build and optionally install the gem'
|
10
|
+
usage '(build | b) [--install]'
|
11
|
+
option '--install, -i', 'Install after building'
|
12
|
+
action :build, :b do |args|
|
13
|
+
say "g`Building #{gemname}`"
|
14
|
+
run "gem build #{gemname}.gemspec --output #{gemfile}"
|
15
|
+
install_gem if args['--install']
|
16
|
+
end
|
17
|
+
|
18
|
+
help 'Install the last built gem'
|
19
|
+
action :install, :i do
|
20
|
+
need_gemfile
|
21
|
+
install_gem
|
22
|
+
end
|
23
|
+
|
24
|
+
unless context[:private]
|
25
|
+
help 'Publish gem to rubygems'
|
26
|
+
action :publish, :p do
|
27
|
+
need_gemfile
|
28
|
+
say 'g`Publishing gem`'
|
29
|
+
run "gem push #{gemfile}"
|
30
|
+
end
|
31
|
+
|
32
|
+
usage 'yank VERSION'
|
33
|
+
help 'Yank gem from rubygems'
|
34
|
+
action :yank do |args|
|
35
|
+
version = args['VERSION']
|
36
|
+
say "rib` Yank #{gemname} #{version} ` Are you sure?"
|
37
|
+
10.downto(0) do |i|
|
38
|
+
say "Yanking in #{i} seconds - Ctrl-C to abort ", replace: true
|
39
|
+
sleep 1
|
40
|
+
end
|
41
|
+
say 'g`Yanking gem`', replace: true
|
42
|
+
run "gem yank #{gemname} -v #{version}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
helpers do
|
47
|
+
def gemname
|
48
|
+
context[:gemname]
|
49
|
+
end
|
50
|
+
|
51
|
+
def gemfile
|
52
|
+
"/tmp/#{gemname}.gem"
|
53
|
+
end
|
54
|
+
|
55
|
+
def run(cmd)
|
56
|
+
say "$ m`#{cmd}`"
|
57
|
+
system cmd unless ENV['DRY_RUN']
|
58
|
+
end
|
59
|
+
|
60
|
+
def install_gem
|
61
|
+
say "g`Installing #{gemname}`"
|
62
|
+
run "gem install --local #{gemfile}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def need_gemfile
|
66
|
+
raise UserError, "File not found #{gemfile}" unless File.exist? gemfile
|
67
|
+
end
|
68
|
+
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.
|
4
|
+
version: 1.0.0
|
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:
|
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-02-01 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
|
-
-
|
35
|
-
-
|
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: '
|
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
40
|
version: '0'
|
71
41
|
requirements: []
|
72
|
-
rubygems_version: 3.
|
42
|
+
rubygems_version: 3.4.5
|
73
43
|
signing_key:
|
74
44
|
specification_version: 4
|
75
45
|
summary: Runfile tasks collection
|
data/lib/runfile-tasks/all.rb
DELETED
@@ -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
|
data/lib/runfile-tasks/docker.rb
DELETED
@@ -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
|
data/lib/runfile-tasks/docs.rb
DELETED
@@ -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,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"
|
data/lib/runfile-tasks.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "runfile-tasks/all"
|