wile 0.9.261203
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.version +1 -0
- data/CREDITS.md +20 -0
- data/README.md +253 -0
- data/bin/wile +102 -0
- data/cache/.bin/pane +99 -0
- data/cache/.bin/panes +54 -0
- data/cache/.config.fish +2 -0
- data/cache/.dictionary +0 -0
- data/cache/.gemignore +16 -0
- data/cache/.gitignore +9 -0
- data/cache/.greeting.erb +1 -0
- data/cache/.irbrc +30 -0
- data/cache/.lexicon +0 -0
- data/cache/.prompt.erb +1 -0
- data/cache/.reek-strict.yml +1 -0
- data/cache/.reek.yml +1 -0
- data/cache/.rubocop-strict.yml +4 -0
- data/cache/.rubocop.yml +4 -0
- data/cache/.ruby-version-floor +1 -0
- data/cache/.ruby-version.erb +1 -0
- data/cache/.solargraph.yml +21 -0
- data/cache/.title.erb +1 -0
- data/cache/.version +1 -0
- data/cache/.wile/example.rb +56 -0
- data/cache/.wileignore +3 -0
- data/cache/CREDITS.md +10 -0
- data/cache/Gemfile +5 -0
- data/cache/Gemfile.lock +1 -0
- data/cache/History.txt +0 -0
- data/cache/README.md.erb +54 -0
- data/cache/TODO.md +3 -0
- data/cache/bin/project.erb +12 -0
- data/cache/cucumber.yml +1 -0
- data/cache/examples/README.md +3 -0
- data/cache/features/help.feature.erb +30 -0
- data/cache/features/step_definitions/command_steps.rb +171 -0
- data/cache/features/support/env.rb +11 -0
- data/cache/features/version.feature.erb +19 -0
- data/cache/git/hooks/pre-commit +93 -0
- data/cache/lib/project.rb.erb +4 -0
- data/cache/man/project.md.erb +24 -0
- data/cache/pkg/README.md +3 -0
- data/cache/test/cons.gz +0 -0
- data/cache/test/tc_comments +216 -0
- data/cache/test/tc_cucumber_slow +67 -0
- data/cache/test/tc_dependency_scrapes +126 -0
- data/cache/test/tc_dictionary +51 -0
- data/cache/test/tc_encoding +53 -0
- data/cache/test/tc_lexicon +34 -0
- data/cache/test/tc_lib_tests +37 -0
- data/cache/test/tc_lints +71 -0
- data/cache/test/tc_readme_rocket_check +128 -0
- data/cache/test/tc_reek +20 -0
- data/cache/test/tc_rubocop +20 -0
- data/cache/test/tc_ruby_syntax +28 -0
- data/cache/test/tc_tags +32 -0
- data/cache/test/tc_tasks_test +31 -0
- data/cache/test/tc_version +97 -0
- data/cache/test/tc_weird_filenames +23 -0
- data/cache/test/test_helper.rb +230 -0
- data/cache/tmp/README.md +8 -0
- data/data/command_version.tsv +281 -0
- data/dependencies.txt +70 -0
- data/lib/wile/autoloads/cache.rb +123 -0
- data/lib/wile/autoloads/code_content.rb +225 -0
- data/lib/wile/autoloads/code_data.rb +153 -0
- data/lib/wile/autoloads/code_data_function.rb +79 -0
- data/lib/wile/autoloads/code_data_valuation.rb +60 -0
- data/lib/wile/autoloads/code_stats.rb +185 -0
- data/lib/wile/autoloads/command_version.rb +119 -0
- data/lib/wile/autoloads/content.rb +196 -0
- data/lib/wile/autoloads/dependencies.rb +170 -0
- data/lib/wile/autoloads/gem_utils.rb +69 -0
- data/lib/wile/autoloads/gemspec.rb +163 -0
- data/lib/wile/autoloads/git.rb +59 -0
- data/lib/wile/autoloads/info.rb +91 -0
- data/lib/wile/autoloads/manpage.rb +44 -0
- data/lib/wile/autoloads/methods.rb +130 -0
- data/lib/wile/autoloads/nvim_files.rb +54 -0
- data/lib/wile/autoloads/options_dictionary.rb +345 -0
- data/lib/wile/autoloads/order_optimizer.rb +185 -0
- data/lib/wile/autoloads/project.rb +60 -0
- data/lib/wile/autoloads/readme.rb +137 -0
- data/lib/wile/autoloads/receivers.rb +101 -0
- data/lib/wile/autoloads/responds.rb +36 -0
- data/lib/wile/autoloads/test.rb +78 -0
- data/lib/wile/autoloads/thread_pool.rb +64 -0
- data/lib/wile/help.rb +41 -0
- data/lib/wile/requires.rb +7 -0
- data/lib/wile/run.rb +108 -0
- data/lib/wile/sysexits.rb +43 -0
- data/lib/wile/tasks/build.rb +46 -0
- data/lib/wile/tasks/bump.rb +61 -0
- data/lib/wile/tasks/compare.rb +139 -0
- data/lib/wile/tasks/content.rb +44 -0
- data/lib/wile/tasks/cp.rb +52 -0
- data/lib/wile/tasks/dependencies.rb +58 -0
- data/lib/wile/tasks/dictionary.rb +59 -0
- data/lib/wile/tasks/gemcheck.rb +142 -0
- data/lib/wile/tasks/gemfile.rb +60 -0
- data/lib/wile/tasks/help.rb +29 -0
- data/lib/wile/tasks/info.rb +77 -0
- data/lib/wile/tasks/install.rb +53 -0
- data/lib/wile/tasks/lexicon.rb +59 -0
- data/lib/wile/tasks/list.rb +97 -0
- data/lib/wile/tasks/methods.rb +154 -0
- data/lib/wile/tasks/mkdir.rb +19 -0
- data/lib/wile/tasks/note.rb +49 -0
- data/lib/wile/tasks/nvim.rb +60 -0
- data/lib/wile/tasks/order.rb +93 -0
- data/lib/wile/tasks/oscheck.rb +49 -0
- data/lib/wile/tasks/publish.rb +67 -0
- data/lib/wile/tasks/receivers.rb +34 -0
- data/lib/wile/tasks/review.rb +157 -0
- data/lib/wile/tasks/ruby.rb +38 -0
- data/lib/wile/tasks/tc.rb +114 -0
- data/lib/wile/tasks/test.rb +57 -0
- data/lib/wile/tasks/todo.rb +55 -0
- data/lib/wile/tasks/update.rb +67 -0
- data/lib/wile/tasks.rb +34 -0
- data/lib/wile/usage.rb +56 -0
- data/lib/wile/usage_error.rb +18 -0
- data/lib/wile/utilities.rb +283 -0
- data/lib/wile/utilities_refinements.rb +41 -0
- data/lib/wile/wile_refinements.rb +137 -0
- data/lib/wile.rb +39 -0
- data/man/wile.1 +1121 -0
- data/man/wile.md +786 -0
- data/pkg/README.md +3 -0
- metadata +399 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# ## wile example ##
|
|
4
|
+
# Demonstrates how to create custom project tasks in .wile/.
|
|
5
|
+
# Custom tasks dynamically extend Wile by reopening Wile::Tasks.
|
|
6
|
+
#
|
|
7
|
+
# Options:
|
|
8
|
+
# --detailed Display options metadata
|
|
9
|
+
# --limit=INTEGER Repeat message INTEGER times
|
|
10
|
+
# --reverse Reverse the greeting text
|
|
11
|
+
# Usage:
|
|
12
|
+
# wile example [<name>] [--detailed] [--limit=N] [--reverse] # demo task
|
|
13
|
+
module Wile
|
|
14
|
+
# Reopen Wile::Tasks to define the custom task method.
|
|
15
|
+
# The method name must match the file basename (example.rb -> :example).
|
|
16
|
+
class Tasks
|
|
17
|
+
# Define argument and option constraints for Wile::Usage.
|
|
18
|
+
# Format: [error_prefix, validator, ..., Set[allowed_options]]
|
|
19
|
+
#
|
|
20
|
+
# Validators can be:
|
|
21
|
+
# * Range (e.g. 0..1) or Integer (exact argument count)
|
|
22
|
+
# * Regexp (matches positional arguments)
|
|
23
|
+
# * Set (whitelists allowed options from bin/wile reserved list)
|
|
24
|
+
EXAMPLE_USAGE = [
|
|
25
|
+
'Accepts at most one name, and flags: detailed, limit, reverse.',
|
|
26
|
+
(0..1),
|
|
27
|
+
Set['detailed', 'limit', 'reverse']
|
|
28
|
+
].freeze
|
|
29
|
+
|
|
30
|
+
# Entry point called by Wile when running: wile example
|
|
31
|
+
# Receives a HelpParser options object with .args and flag accessors.
|
|
32
|
+
# :reek:FeatureEnvy :reek:TooManyStatements
|
|
33
|
+
def example(options)
|
|
34
|
+
args = Usage.new(options, *EXAMPLE_USAGE).args
|
|
35
|
+
name = args&.first || 'World'
|
|
36
|
+
limit = options.limit || 1
|
|
37
|
+
greeting = "Hello, #{name}!"
|
|
38
|
+
greeting = greeting.reverse if options.reverse?
|
|
39
|
+
|
|
40
|
+
limit.times { puts greeting.green }
|
|
41
|
+
print_details(name, limit, options) if options.detailed?
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
# Helper methods in Tasks that do not reference instance variables
|
|
47
|
+
# use :reek:UtilityFunction to satisfy Reek quality gates.
|
|
48
|
+
# :reek:UtilityFunction
|
|
49
|
+
def print_details(name, limit, options)
|
|
50
|
+
puts "\nDetails:".blue
|
|
51
|
+
puts " Target: #{name}"
|
|
52
|
+
puts " Limit: #{limit}"
|
|
53
|
+
puts " Reverse: #{options.reverse?}"
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
data/cache/.wileignore
ADDED
data/cache/CREDITS.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Credits
|
|
2
|
+
|
|
3
|
+
We want to credit where credit is due.
|
|
4
|
+
This project owes thanks to the authors of this repository (see their commits),
|
|
5
|
+
the third-party libraries we rely on (check the dependencies),
|
|
6
|
+
and the diffuse pool of ideas and inspirations that shaped it.
|
|
7
|
+
|
|
8
|
+
We welcome contributions to this list!
|
|
9
|
+
If you feel someone or something is missing,
|
|
10
|
+
please submit a pull request with the suggested addition.
|
data/cache/Gemfile
ADDED
data/cache/Gemfile.lock
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# TODO: use `bundle lock` to generate this file
|
data/cache/History.txt
ADDED
|
File without changes
|
data/cache/README.md.erb
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# <%=@module%>
|
|
2
|
+
|
|
3
|
+
* [VERSION 0.0.0](https://github.com/<%=@username.downcase%>/<%=@project%>/releases)
|
|
4
|
+
* [github](https://www.github.com/<%=@username.downcase%>/<%=@project%>)
|
|
5
|
+
* [rubygems](https://rubygems.org/<%=@project%>)
|
|
6
|
+
|
|
7
|
+
## DESCRIPTION
|
|
8
|
+
|
|
9
|
+
TODO: short summary
|
|
10
|
+
|
|
11
|
+
TODO: more...
|
|
12
|
+
|
|
13
|
+
## INSTALL
|
|
14
|
+
```console
|
|
15
|
+
$ gem install <%=@project%>
|
|
16
|
+
```
|
|
17
|
+
* Required Ruby version: `>= <%=RUBY_VERSION.split('.').first(2).join('.')%>`
|
|
18
|
+
|
|
19
|
+
## SYNOPSIS
|
|
20
|
+
```ruby
|
|
21
|
+
require '<%=@project%>' # TODO: exemplar use of lib
|
|
22
|
+
```
|
|
23
|
+
## HELP
|
|
24
|
+
```console
|
|
25
|
+
$ <%=@project%> --help #>>
|
|
26
|
+
TODO: the help's output
|
|
27
|
+
```
|
|
28
|
+
## LICENSE
|
|
29
|
+
|
|
30
|
+
Copyright (c) <%=@year%> <%=@username%>
|
|
31
|
+
|
|
32
|
+
Permission is hereby granted, free of charge,
|
|
33
|
+
to any person obtaining a copy of this software and
|
|
34
|
+
associated documentation files (the "Software"),
|
|
35
|
+
to deal in the Software without restriction,
|
|
36
|
+
including without limitation the rights
|
|
37
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
38
|
+
copies of the Software, and
|
|
39
|
+
to permit persons to whom the Software is furnished to do so,
|
|
40
|
+
subject to the following conditions:
|
|
41
|
+
|
|
42
|
+
The above copyright notice and this permission notice
|
|
43
|
+
shall be included in all copies or substantial portions of the Software.
|
|
44
|
+
|
|
45
|
+
THE SOFTWARE IS PROVIDED "AS IS",
|
|
46
|
+
WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
47
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
48
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
49
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
50
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
51
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
|
|
52
|
+
THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
53
|
+
|
|
54
|
+
## [CREDITS](CREDITS.md)
|
data/cache/TODO.md
ADDED
data/cache/cucumber.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
default: --publish-quiet
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
@help
|
|
2
|
+
Feature: Testing <%=@project%> help option
|
|
3
|
+
|
|
4
|
+
Background:
|
|
5
|
+
* Given command "./bin/<%=@project%>"
|
|
6
|
+
|
|
7
|
+
Scenario: --help
|
|
8
|
+
* Given option "--help"
|
|
9
|
+
* When we run command
|
|
10
|
+
* Then exit status is "0"
|
|
11
|
+
* Then stderr is ""
|
|
12
|
+
* Then header is "## <%=@project%> ##"
|
|
13
|
+
* Then stdout includes "Usage:"
|
|
14
|
+
|
|
15
|
+
Scenario: -h
|
|
16
|
+
* Given option "-h"
|
|
17
|
+
* When we run command
|
|
18
|
+
* Then exit status is "0"
|
|
19
|
+
* Then stderr is ""
|
|
20
|
+
* Then header is "## <%=@project%> ##"
|
|
21
|
+
* Then stdout includes "Usage:"
|
|
22
|
+
|
|
23
|
+
# Setting both -h and --help triggers HelpParser's validation
|
|
24
|
+
Scenario: -h --help
|
|
25
|
+
* Given option "-h --help"
|
|
26
|
+
* When we run command
|
|
27
|
+
* Then exit status is "0"
|
|
28
|
+
* Then stderr is ""
|
|
29
|
+
* Then header is "## <%=@project%> ##"
|
|
30
|
+
* Then stdout includes "Usage:"
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# wile: os `diff`
|
|
4
|
+
|
|
5
|
+
# Given command "<command>"
|
|
6
|
+
Given(/(?:Given )?command "([^"]*)"/) do |command|
|
|
7
|
+
@command = command
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Given option "<options>"
|
|
11
|
+
Given(/(?:Given )?options? "([^"]*)"/) do |options|
|
|
12
|
+
@options = options
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Given fixture link "<target>"
|
|
16
|
+
Given(/(?:Given )?fixture link "([^"]*)"/) do |target|
|
|
17
|
+
fixture = "features/fixtures/#{target}"
|
|
18
|
+
if !File.exist?(target) && !File.symlink?(target)
|
|
19
|
+
File.symlink(fixture, target)
|
|
20
|
+
@temp_symlinks ||= []
|
|
21
|
+
@temp_symlinks << target
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# When we run command
|
|
26
|
+
When(/(?:When )?we run command/) do
|
|
27
|
+
run = -> { Open3.capture3("#{@command} #{@options}") }
|
|
28
|
+
@stdout, @stderr, @status =
|
|
29
|
+
defined?(Bundler) ? Bundler.with_unbundled_env(&run) : run.call
|
|
30
|
+
[@stdout, @stderr].each(&:chomp!)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Then exit status is "<status>"
|
|
34
|
+
Then(/(?:Then )?exit status is "(\d+)"/) do |status|
|
|
35
|
+
unless @status.exitstatus == status.to_i
|
|
36
|
+
raise "Got exit status #{@status.exitstatus} instead of #{status}"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Then stdout is '<string>'
|
|
41
|
+
Then(/(?:Then )?stdout is '([^']*)'/) do |string|
|
|
42
|
+
unless @stdout == string
|
|
43
|
+
raise "stdout: Expected '#{string}'. Got '#{@stdout}'"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Then stdout is "<inspect>"
|
|
48
|
+
Then(/(?:Then )?stdout is ("[^"]*")/) do |string|
|
|
49
|
+
unless @stdout.inspect == string
|
|
50
|
+
raise "stdout: Expected '#{string}'. Got '#{@stdout}'"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Then stdout is fixture '<filename>'
|
|
55
|
+
Then(/(?:Then )?stdout is fixture ['"]([^'"]*)['"]/) do |filename|
|
|
56
|
+
path = File.file?(filename) ? filename : "features/fixtures/#{filename}"
|
|
57
|
+
raise "Fixture not found: #{filename}" unless File.file?(path)
|
|
58
|
+
|
|
59
|
+
expected = File.read(path).chomp
|
|
60
|
+
unless @stdout == expected
|
|
61
|
+
FileUtils.mkdir_p('tmp')
|
|
62
|
+
tmp_path = File.join('tmp', File.basename(filename))
|
|
63
|
+
File.write(tmp_path, "#{@stdout}\n")
|
|
64
|
+
diff = IO.popen(['diff', '-u', '-d', path, tmp_path], &:read)
|
|
65
|
+
raise "stdout differs from fixture '#{filename}':\n#{diff}"
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Then stderr is "<string>"
|
|
70
|
+
Then(/(?:Then )?stderr is "([^"]*)"/) do |string|
|
|
71
|
+
unless @stderr == string
|
|
72
|
+
raise "stderr: Expected '#{string}'. Got '#{@stderr}'"
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Then stderr is '<string>'
|
|
77
|
+
Then(/(?:Then )?stderr is '([^']*)'/) do |string|
|
|
78
|
+
unless @stderr == string
|
|
79
|
+
raise "stderr: Expected '#{string}'. Got '#{@stderr}'"
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Then stdout includes "<string>"
|
|
84
|
+
Then(/(?:Then )?stdout includes "([^"]*)"/) do |string|
|
|
85
|
+
raise "Stdout did not include '#{string}'" unless @stdout.include?(string)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Then stdout does not include "<string>"
|
|
89
|
+
Then(/(?:Then )?stdout (?:not|does not) includes? "([^"]*)"/) do |string|
|
|
90
|
+
raise "Stdout included '#{string}'" if @stdout.include?(string)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Then stderr includes "<string>"
|
|
94
|
+
Then(/(?:Then )?stderr includes "([^"]*)"/) do |string|
|
|
95
|
+
raise "Stderr did not include '#{string}'" unless @stderr.include?(string)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Then stderr does not include "<string>"
|
|
99
|
+
Then(/(?:Then )?stderr (?:not|does not) includes? "([^"]*)"/) do |string|
|
|
100
|
+
raise "Stderr included '#{string}'" if @stderr.include?(string)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Then stdout matches /<pattern>/
|
|
104
|
+
Then %r{(?:Then )?stdout matches /([^/]*)/} do |string|
|
|
105
|
+
unless Regexp.new(string).match?(@stdout)
|
|
106
|
+
raise "Stdout did not match '#{string}'"
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Then stdout does not match /<pattern>/
|
|
111
|
+
Then %r{(?:Then )?stdout (?:not|does not) match(?:es)? /([^/]*)/} do |string|
|
|
112
|
+
raise "Stdout matched '#{string}'" if Regexp.new(string).match?(@stdout)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Then stderr matches /<pattern>/
|
|
116
|
+
Then %r{(?:Then )?stderr matches /([^/]*)/} do |string|
|
|
117
|
+
unless Regexp.new(string).match?(@stderr)
|
|
118
|
+
raise "Stderr did not match '#{string}'"
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Then stderr does not match /<pattern>/
|
|
123
|
+
Then %r{(?:Then )?stderr (?:not|does not) match(?:es)? /([^/]*)/} do |string|
|
|
124
|
+
raise "Stderr matched '#{string}'" if Regexp.new(string).match?(@stderr)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Then <key> => <value>
|
|
128
|
+
Then(/(?:Then )?(\w+) => (\S+)/) do |k, v|
|
|
129
|
+
h = JSON.parse @stdout
|
|
130
|
+
raise "#{k} is not #{v}, it's #{h[k]}" unless h[k] == v
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Then <key> maps to true
|
|
134
|
+
Then(/(?:Then )?(\w+) maps to true/) do |k|
|
|
135
|
+
h = JSON.parse @stdout
|
|
136
|
+
raise "#{k} is not true, it's #{h[k]}" unless h[k] == true
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Then <key> maps to nil
|
|
140
|
+
Then(/(?:Then )?(\w+) maps to nil/) do |k|
|
|
141
|
+
h = JSON.parse @stdout
|
|
142
|
+
raise "#{k} is not nil, it's #{h[k]}" unless h[k].nil?
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Then <key> is [<items>]
|
|
146
|
+
Then(/(?:Then )?(\w+) is \[(\S+)\]/) do |k, v|
|
|
147
|
+
h = JSON.parse @stdout
|
|
148
|
+
l = h[k].join(',')
|
|
149
|
+
raise "#{k} is not #{v}, it's #{l}" unless l == v
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Then header is "<string>"
|
|
153
|
+
Then(/(?:Then )?header is "(.*)"/) do |v|
|
|
154
|
+
header = @stdout.split("\n", 2).first
|
|
155
|
+
raise "Header is not #{v}, it's #{header}" unless header == v
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Then digest is "<md5>"
|
|
159
|
+
Then(/(?:Then )?digest is "(.*)"/) do |v|
|
|
160
|
+
# Ensure no changes to output occurred in future edits.
|
|
161
|
+
# Note that stdout was stripped, so adding newline back in,
|
|
162
|
+
# making the use of piped md5sum output possible.
|
|
163
|
+
digest = Digest::MD5.hexdigest("#{@stdout}\n")
|
|
164
|
+
raise "Digest is not #{v}, it's #{digest}" unless digest == v
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
After do
|
|
168
|
+
@temp_symlinks&.each do |symlink|
|
|
169
|
+
File.unlink(symlink) if File.symlink?(symlink)
|
|
170
|
+
end
|
|
171
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Load required libraries and stuff
|
|
4
|
+
require 'open3'
|
|
5
|
+
require 'json'
|
|
6
|
+
require 'digest'
|
|
7
|
+
require 'fileutils'
|
|
8
|
+
|
|
9
|
+
# Ensure lib is on RUBYLIB even when running under rbenv shims
|
|
10
|
+
paths = ENV['RUBYLIB'].to_s.split(':')
|
|
11
|
+
ENV['RUBYLIB'] = (['lib'] + paths).reject(&:empty?).uniq.join(':')
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
@version
|
|
2
|
+
Feature: Testing <%=@project%> version option
|
|
3
|
+
|
|
4
|
+
Background:
|
|
5
|
+
* Given command "./bin/<%=@project%>"
|
|
6
|
+
|
|
7
|
+
Scenario: --version
|
|
8
|
+
* Given option "--version"
|
|
9
|
+
* When we run command
|
|
10
|
+
* Then exit status is "0"
|
|
11
|
+
* Then stderr is ""
|
|
12
|
+
* Then stdout matches /\A\d+\.\d+\.\d+\z/
|
|
13
|
+
|
|
14
|
+
Scenario: -v
|
|
15
|
+
* Given option "-v"
|
|
16
|
+
* When we run command
|
|
17
|
+
* Then exit status is "0"
|
|
18
|
+
* Then stderr is ""
|
|
19
|
+
* Then stdout matches /\A\d+\.\d+\.\d+\z/
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# wile: os `git,ruby`
|
|
5
|
+
|
|
6
|
+
Encoding.default_external = Encoding::UTF_8
|
|
7
|
+
|
|
8
|
+
require 'English'
|
|
9
|
+
require 'find'
|
|
10
|
+
|
|
11
|
+
# ruby -c
|
|
12
|
+
dirs = %w[lib bin].select { File.directory?(it) }
|
|
13
|
+
dirs.each do |dir|
|
|
14
|
+
Find.find(dir) do |fn|
|
|
15
|
+
next unless File.file?(fn)
|
|
16
|
+
next unless fn.end_with?('.rb') || File.read(fn, 80).match?(/^#!.*\bruby/)
|
|
17
|
+
|
|
18
|
+
unless system('ruby', '-c', fn, out: File::NULL)
|
|
19
|
+
puts "Syntax error: #{fn}"
|
|
20
|
+
exit 1
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# VERSION
|
|
26
|
+
unless File.file?('.version')
|
|
27
|
+
puts 'Could not find .version file.'
|
|
28
|
+
exit 1
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
major, minor, build_ver = File.read('.version').chomp.split(/\D+/)
|
|
32
|
+
unless major && minor && build_ver
|
|
33
|
+
puts 'Could not get VERSION.'
|
|
34
|
+
exit 1
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# BUILD
|
|
38
|
+
dir_args = dirs.join(' ')
|
|
39
|
+
staged = `git diff --cached --name-only #{dir_args}`.strip
|
|
40
|
+
log = `git log -1 --pretty='%as' #{dir_args}`.strip.delete('-')
|
|
41
|
+
build = if staged.empty? && !log.empty?
|
|
42
|
+
log[2..]
|
|
43
|
+
else
|
|
44
|
+
Time.now.strftime('%y%m%d')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
unless build_ver.start_with?(build)
|
|
48
|
+
puts "Unexpected BUILD(#{build_ver}) !start_with?(#{build})"
|
|
49
|
+
exit 1
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Copyright
|
|
53
|
+
year = Time.now.year
|
|
54
|
+
readme = File.file?('README.md') ? File.read('README.md') : ''
|
|
55
|
+
unless readme.match?(/Copyright.*#{year}/i)
|
|
56
|
+
puts "Check README's copyright year."
|
|
57
|
+
exit 1
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# wile test
|
|
61
|
+
wile = 'bin/wile' if File.file?('bin/wile') && File.executable?('bin/wile')
|
|
62
|
+
wile ||= ENV.fetch('PATH', '').split(File::PATH_SEPARATOR)
|
|
63
|
+
.map { |dir| File.join(dir, 'wile') }
|
|
64
|
+
.find { |fn| File.file?(fn) && File.executable?(fn) }
|
|
65
|
+
exit 0 unless wile
|
|
66
|
+
|
|
67
|
+
if wile == 'bin/wile'
|
|
68
|
+
ENV['RUBYLIB'] = ['lib', ENV.fetch('RUBYLIB', nil)].compact
|
|
69
|
+
.join(File::PATH_SEPARATOR)
|
|
70
|
+
wile_cmd = %w[ruby -Ilib bin/wile]
|
|
71
|
+
else
|
|
72
|
+
wile_cmd = [wile]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
io = begin
|
|
76
|
+
File.open('/dev/tty', 'r+')
|
|
77
|
+
rescue StandardError
|
|
78
|
+
$stdin if $stdin.tty?
|
|
79
|
+
end
|
|
80
|
+
exit 0 unless io
|
|
81
|
+
|
|
82
|
+
io.print 'Run wile test? [y/N]: '
|
|
83
|
+
reply = io.gets
|
|
84
|
+
io.close if io.is_a?(File)
|
|
85
|
+
exit 0 unless reply&.strip&.match?(/^[Yy]([Ee][Ss])?$/)
|
|
86
|
+
|
|
87
|
+
git_env = { 'GIT_INDEX_FILE' => nil, 'GIT_DIR' => nil, 'GIT_WORK_TREE' => nil }
|
|
88
|
+
lines = IO.popen([git_env, *wile_cmd, 'test', '--batch'], # permit
|
|
89
|
+
err: %i[child out], &:readlines)
|
|
90
|
+
unless $CHILD_STATUS.success?
|
|
91
|
+
lines&.each { print it }
|
|
92
|
+
exit 1
|
|
93
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# <%=@project%>
|
|
2
|
+
|
|
3
|
+
## NAME
|
|
4
|
+
|
|
5
|
+
<%=@project%> -- <%=@module%> command-line interface
|
|
6
|
+
|
|
7
|
+
## SYNOPSIS
|
|
8
|
+
|
|
9
|
+
`<%=@project%> [:options+]`
|
|
10
|
+
|
|
11
|
+
## DESCRIPTION
|
|
12
|
+
|
|
13
|
+
**<%=@module%>** is a Ruby command-line tool.
|
|
14
|
+
|
|
15
|
+
TODO: Add project description here.
|
|
16
|
+
|
|
17
|
+
## OPTIONS
|
|
18
|
+
|
|
19
|
+
- `-h`, `--help`: Show help summary.
|
|
20
|
+
- `-v`, `--version`: Show version number.
|
|
21
|
+
|
|
22
|
+
## SEE ALSO
|
|
23
|
+
|
|
24
|
+
`ruby`(1)
|
data/cache/pkg/README.md
ADDED
data/cache/test/cons.gz
ADDED
|
Binary file
|