runfile 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +6 -4
- data/bin/run! +6 -6
- data/lib/runfile/docopt_helper.rb +13 -14
- data/lib/runfile/dsl.rb +6 -6
- data/lib/runfile/runfile_helper.rb +1 -1
- data/lib/runfile/runner.rb +4 -4
- data/lib/runfile/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6ac7c4520f522bf476eb1695a9ba65ecf74c4c6cba3a11c0c9a0189ca1a7654c
|
4
|
+
data.tar.gz: 9dd1ed9ce6ead6c5caddb3b08bb502ad1fa540ed26de5468f1da710037430528
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f47d18eede3e26554ea5fedc930a9ab7fb18d90b139fdcef6274836bddbd8fc103ace14f301cb67b279807122a538155359601a94e1f68078c72bade248289f0
|
7
|
+
data.tar.gz: d6c1947eb47ad475ba18ace7d037fd2b819d8231f06a9c817e7d3c1f82941201d55b1f6f7245b2a4d186b4e00e6f4ed2a6f29ce1e3a29b33368f3315d0949a5b
|
data/README.md
CHANGED
@@ -2,10 +2,12 @@ Runfile - If Rake and Docopt had a baby
|
|
2
2
|
==================================================
|
3
3
|
|
4
4
|
[![Gem](https://img.shields.io/gem/v/runfile.svg?style=flat-square)](https://rubygems.org/gems/runfile)
|
5
|
-
[![
|
6
|
-
[![
|
7
|
-
[![
|
8
|
-
[![
|
5
|
+
[![Downloads](https://img.shields.io/gem/dt/runfile.svg?style=flat-square)](https://rubygems.org/gems/runfile)
|
6
|
+
[![Build](https://img.shields.io/travis/DannyBen/runfile.svg?style=flat-square)](https://travis-ci.org/DannyBen/runfile)
|
7
|
+
[![Dependencies](https://img.shields.io/gemnasium/DannyBen/runfile.svg?style=flat-square)](https://gemnasium.com/DannyBen/runfile)
|
8
|
+
[![Code Quality](https://img.shields.io/codacy/grade/55cf6df171234931b1781db7921ff68e.svg?style=flat-square)](https://www.codacy.com/app/db/runfile)
|
9
|
+
[![Maintainability](https://img.shields.io/codeclimate/maintainability/DannyBen/runfile.svg?style=flat-square)](https://codeclimate.com/github/DannyBen/runfile)
|
10
|
+
[![Issues](https://img.shields.io/codeclimate/issues/github/DannyBen/runfile.svg?style=flat-square)](https://codeclimate.com/github/DannyBen/runfile)
|
9
11
|
|
10
12
|
---
|
11
13
|
|
data/bin/run!
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
# This is needed in cases when you are running "run!" from a folder
|
4
|
+
# that contains a Gemfile on a machine with RVM.
|
5
|
+
# It will disable attempting to run in the current context
|
6
|
+
# Source: https://rvm.io/integration/bundler
|
7
|
+
ENV['NOEXEC_DISABLE'] = '1'
|
8
|
+
|
3
9
|
require 'runfile'
|
4
10
|
|
5
11
|
# for dev
|
@@ -8,10 +14,4 @@ require 'runfile'
|
|
8
14
|
include Colsole
|
9
15
|
include Runfile::DSL
|
10
16
|
|
11
|
-
# This is needed in cases when you are running "run!" from a folder
|
12
|
-
# that contains a Gemfile on a machine with RVM.
|
13
|
-
# It will disable attempting to run in the current context
|
14
|
-
# Source: https://rvm.io/integration/bundler
|
15
|
-
ENV['NOEXEC_DISABLE'] = '1'
|
16
|
-
|
17
17
|
Runfile::Runner.instance.execute ARGV, false
|
@@ -9,20 +9,20 @@ module Runfile
|
|
9
9
|
class DocoptHelper
|
10
10
|
include Colsole
|
11
11
|
|
12
|
-
# The constructor expects to
|
13
|
-
# needed to generate a docopt document (name, version,
|
12
|
+
# The constructor expects to an object that responds to all the
|
13
|
+
# textual details needed to generate a docopt document (name, version,
|
14
14
|
# summary, options) and an array of Action objects.
|
15
15
|
# The superspace argument will be the name of runfile, in case we
|
16
16
|
# are running a named.runfile. It is only needed to generate the
|
17
17
|
# proper `run superspace (-h|--help|--version)` line
|
18
|
-
def initialize(
|
19
|
-
@superspace = superspace
|
20
|
-
@name = name
|
21
|
-
@version = version
|
22
|
-
@summary = summary
|
23
|
-
@actions = actions
|
24
|
-
@options = options
|
25
|
-
@examples = examples
|
18
|
+
def initialize(options)
|
19
|
+
@superspace = options.superspace
|
20
|
+
@name = options.name
|
21
|
+
@version = options.version
|
22
|
+
@summary = options.summary
|
23
|
+
@actions = options.actions
|
24
|
+
@options = options.options
|
25
|
+
@examples = options.examples
|
26
26
|
end
|
27
27
|
|
28
28
|
# Generate a document based on all the actions, help messages
|
@@ -42,7 +42,7 @@ module Runfile
|
|
42
42
|
# Return all docopt lines for the 'Usage' section
|
43
43
|
def docopt_usage
|
44
44
|
doc = ["\nUsage:"];
|
45
|
-
@actions.each do |
|
45
|
+
@actions.each do |_name, action|
|
46
46
|
doc << " run #{action.usage}" unless action.usage == false
|
47
47
|
end
|
48
48
|
basic_flags = @version ? "(-h|--help|--version)" : "(-h|--help)"
|
@@ -58,7 +58,7 @@ module Runfile
|
|
58
58
|
def docopt_commands(width)
|
59
59
|
doc = []
|
60
60
|
caption_printed = false
|
61
|
-
@actions.each do |
|
61
|
+
@actions.each do |_name, action|
|
62
62
|
action.help or next
|
63
63
|
doc << "Commands:" unless caption_printed
|
64
64
|
caption_printed = true
|
@@ -101,11 +101,10 @@ module Runfile
|
|
101
101
|
doc
|
102
102
|
end
|
103
103
|
|
104
|
-
|
105
104
|
# Call the docopt handler, which will either return a parsed
|
106
105
|
# arguments list, or halt execution and show usage.
|
107
106
|
def args(argv)
|
108
|
-
Docopt
|
107
|
+
Docopt.docopt(docopt, version: @version, argv:argv)
|
109
108
|
end
|
110
109
|
end
|
111
110
|
end
|
data/lib/runfile/dsl.rb
CHANGED
@@ -74,27 +74,27 @@ module Runfile
|
|
74
74
|
# Run a command, wait until it is done and continue
|
75
75
|
# run 'rails server'
|
76
76
|
def run(*args)
|
77
|
-
ExecHandler.instance.run
|
77
|
+
ExecHandler.instance.run(*args)
|
78
78
|
end
|
79
79
|
|
80
80
|
# Run a command, wait until it is done, then exit
|
81
81
|
# run! 'rails server'
|
82
82
|
def run!(*args)
|
83
|
-
ExecHandler.instance.run!
|
83
|
+
ExecHandler.instance.run!(*args)
|
84
84
|
end
|
85
85
|
|
86
86
|
# Run a command in the background, optionally log to a log file and save
|
87
87
|
# the process ID in a pid file
|
88
88
|
# run_bg 'rails server', pid: 'rails', log: 'tmp/log.log'
|
89
89
|
def run_bg(*args)
|
90
|
-
ExecHandler.instance.run_bg
|
90
|
+
ExecHandler.instance.run_bg(*args)
|
91
91
|
end
|
92
92
|
|
93
93
|
# Stop a command started with 'run_bg'. Provide the name of he pid file you
|
94
94
|
# used in 'run_bg'
|
95
95
|
# stop_bg 'rails'
|
96
96
|
def stop_bg(*args)
|
97
|
-
ExecHandler.instance.stop_bg
|
97
|
+
ExecHandler.instance.stop_bg(*args)
|
98
98
|
end
|
99
99
|
|
100
100
|
# Set a block to be called before each run. The block should return
|
@@ -105,7 +105,7 @@ module Runfile
|
|
105
105
|
# command
|
106
106
|
# end
|
107
107
|
def before_run(&block)
|
108
|
-
ExecHandler.instance.before_run
|
108
|
+
ExecHandler.instance.before_run(&block)
|
109
109
|
end
|
110
110
|
|
111
111
|
# Set a block to be called after each run
|
@@ -113,7 +113,7 @@ module Runfile
|
|
113
113
|
# puts "AFTER #{command}"
|
114
114
|
# end
|
115
115
|
def after_run(&block)
|
116
|
-
ExecHandler.instance.after_run
|
116
|
+
ExecHandler.instance.after_run(&block)
|
117
117
|
end
|
118
118
|
|
119
119
|
# Also allow to use 'endcommand' instead of 'command' to end
|
@@ -110,7 +110,7 @@ module Runfile
|
|
110
110
|
def say_runfile_list(runfiles)
|
111
111
|
runfile_paths = runfiles.map { |f| File.dirname f }
|
112
112
|
max = runfile_paths.max_by(&:length).size
|
113
|
-
width
|
113
|
+
width = detect_terminal_size[0]
|
114
114
|
runfiles.each do |f|
|
115
115
|
f[/([^\/]+).runfile$/]
|
116
116
|
command = "run #{$1}"
|
data/lib/runfile/runner.rb
CHANGED
@@ -13,7 +13,7 @@ module Runfile
|
|
13
13
|
include SettingsMixin
|
14
14
|
|
15
15
|
attr_accessor :last_usage, :last_help, :name, :version,
|
16
|
-
:summary, :namespace, :superspace
|
16
|
+
:summary, :namespace, :superspace, :actions, :examples, :options
|
17
17
|
|
18
18
|
# Initialize all variables to sensible defaults.
|
19
19
|
def initialize
|
@@ -41,7 +41,7 @@ module Runfile
|
|
41
41
|
rescue => ex
|
42
42
|
abort "Runfile error:\n#{ex.message}\n#{ex.backtrace[0]}"
|
43
43
|
end
|
44
|
-
run
|
44
|
+
run(*argv)
|
45
45
|
end
|
46
46
|
|
47
47
|
# Add an action to the @actions array, and use the last known
|
@@ -92,7 +92,7 @@ module Runfile
|
|
92
92
|
# function. Expects to get a single string that looks as if
|
93
93
|
# it was typed in the command prompt.
|
94
94
|
def cross_call(command_string)
|
95
|
-
argv = command_string.split
|
95
|
+
argv = command_string.split(/\s(?=(?:[^"]|"[^"]*")*$)/)
|
96
96
|
begin
|
97
97
|
docopt_exec argv
|
98
98
|
rescue Docopt::Exit => ex
|
@@ -108,7 +108,7 @@ module Runfile
|
|
108
108
|
# This should always be called in a begin...rescue block and
|
109
109
|
# you should handle the Docopt::Exit exception.
|
110
110
|
def docopt_exec(argv)
|
111
|
-
helper = DocoptHelper.new(
|
111
|
+
helper = DocoptHelper.new(self)
|
112
112
|
args = helper.args argv
|
113
113
|
action = find_action argv
|
114
114
|
action or abort "Runfile error: Action not found"
|
data/lib/runfile/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runfile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
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: 2018-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '3.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '3.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec-expectations
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '5.1'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '5.1'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: similar_text
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
165
|
version: '0'
|
166
166
|
requirements: []
|
167
167
|
rubyforge_project:
|
168
|
-
rubygems_version: 2.
|
168
|
+
rubygems_version: 2.7.6
|
169
169
|
signing_key:
|
170
170
|
specification_version: 4
|
171
171
|
summary: If Rake and Docopt had a baby
|