runfile 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/lib/runfile.rb +1 -1
- data/lib/runfile/docopt_helper.rb +1 -1
- data/lib/runfile/runfile_helper.rb +17 -12
- data/lib/runfile/runner.rb +6 -9
- data/lib/runfile/settings.rb +6 -3
- data/lib/runfile/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07eb84f262b49c776d311056be64345f415c94da
|
4
|
+
data.tar.gz: fc740fc871111c1bac8a30df994b4ce4778c1ecf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57b71aaad3c8bde5c96064abe7ab2662509903f327cbed5f8fb43caa6ffc104f5c0f437ae10f8c51ba71018c23fd5c3eb4b75dd5f05bd8c1a3f658f5fe7e4b44
|
7
|
+
data.tar.gz: f04af615efa538afc2f6fefe69aa65815ab87069e4281a446694d99e57d5dc966b7cf9da094c69699bdce77f28b504216d81ad0cd2dcaa4c290fa99f37802d42
|
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
Runfile - If Rake and Docopt had a baby
|
2
2
|
==================================================
|
3
3
|
|
4
|
-
[![Gem
|
5
|
-
[![
|
6
|
-
[![Code Climate](https://
|
7
|
-
[![
|
8
|
-
|
4
|
+
[![Gem](https://img.shields.io/gem/v/runfile.svg?style=flat-square)](https://rubygems.org/gems/runfile)
|
5
|
+
[![Travis](https://img.shields.io/travis/DannyBen/runfile.svg?style=flat-square)](https://travis-ci.org/DannyBen/runfile)
|
6
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/DannyBen/runfile.svg?style=flat-square)](https://codeclimate.com/github/DannyBen/runfile)
|
7
|
+
[![Gemnasium](https://img.shields.io/gemnasium/DannyBen/runfile.svg?style=flat-square)](https://gemnasium.com/DannyBen/runfile)
|
8
|
+
[![Gem](https://img.shields.io/gem/dt/runfile.svg?style=flat-square)](https://rubygems.org/gems/runfile)
|
9
9
|
|
10
10
|
---
|
11
11
|
|
data/lib/runfile.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'runfile/version'
|
2
|
+
require 'runfile/settings'
|
2
3
|
require 'runfile/docopt_helper'
|
3
4
|
require 'runfile/runfile_helper'
|
4
5
|
require 'runfile/action'
|
5
6
|
require 'runfile/runner'
|
6
7
|
require 'runfile/dsl'
|
7
8
|
require 'runfile/util'
|
8
|
-
require 'runfile/settings'
|
9
9
|
|
10
10
|
require 'runfile/extensions/exec'
|
@@ -29,7 +29,7 @@ module Runfile
|
|
29
29
|
# Generate a document based on all the actions, help messages
|
30
30
|
# and options we have collected from the Runfile DSL.
|
31
31
|
def docopt
|
32
|
-
width
|
32
|
+
width = detect_terminal_size[0]
|
33
33
|
doc = []
|
34
34
|
doc << (@version ? "#{@name} #{@version}" : "#{@name}")
|
35
35
|
doc << "#{@summary}" if @summary
|
@@ -8,6 +8,7 @@ module Runfile
|
|
8
8
|
# 2. Creating new runfiles (`run make`)
|
9
9
|
# 3. Showing a list of found system runfiles in a colorful help
|
10
10
|
class RunfileHelper
|
11
|
+
include SettingsMixin
|
11
12
|
|
12
13
|
# Handle the case when `run` is called without a Runfile
|
13
14
|
# present. We will let the user know they can type `run make`
|
@@ -79,7 +80,7 @@ module Runfile
|
|
79
80
|
say "\n!txtred!Runfile not found."
|
80
81
|
else
|
81
82
|
say ""
|
82
|
-
|
83
|
+
compact ? say_runfile_usage(runfiles) : say_runfile_list(runfiles)
|
83
84
|
end
|
84
85
|
end
|
85
86
|
|
@@ -106,26 +107,30 @@ module Runfile
|
|
106
107
|
end
|
107
108
|
|
108
109
|
# Output the list of available runfiles
|
109
|
-
def say_runfile_list(runfiles
|
110
|
+
def say_runfile_list(runfiles)
|
110
111
|
runfile_paths = runfiles.map { |f| File.dirname f }
|
111
112
|
max = runfile_paths.max_by(&:length).size
|
112
113
|
width, height = detect_terminal_size
|
113
114
|
runfiles.each do |f|
|
114
115
|
f[/([^\/]+).runfile$/]
|
115
116
|
command = "run #{$1}"
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
spacer_size = [1, spacer_size].max
|
121
|
-
spacer = '.' * spacer_size
|
122
|
-
say " !txtgrn!#{command}!txtrst! #{spacer} #{File.dirname f}"
|
123
|
-
end
|
117
|
+
spacer_size = width - max - command.size - 6
|
118
|
+
spacer_size = [1, spacer_size].max
|
119
|
+
spacer = '.' * spacer_size
|
120
|
+
say " !txtgrn!#{command}!txtrst! #{spacer} #{File.dirname f}"
|
124
121
|
end
|
125
122
|
end
|
126
123
|
|
127
|
-
|
128
|
-
|
124
|
+
# Output the list of available runfiles without filename
|
125
|
+
def say_runfile_usage(runfiles)
|
126
|
+
namelist = runfiles.map {|f| /([^\/]+).runfile$/.match(f)[1] }
|
127
|
+
width = detect_terminal_size[0]
|
128
|
+
max = namelist.max_by(&:length).length
|
129
|
+
message = " " + namelist.map {|f| f.ljust max+1 }.join(' ')
|
130
|
+
|
131
|
+
say "#{settings.intro}\n" if settings.intro
|
132
|
+
say "Usage: run <file>"
|
133
|
+
say word_wrap(message, width)
|
129
134
|
end
|
130
135
|
|
131
136
|
end
|
data/lib/runfile/runner.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
+
require 'singleton'
|
1
2
|
require 'docopt'
|
2
|
-
require 'pp'
|
3
3
|
|
4
4
|
module Runfile
|
5
5
|
|
@@ -9,11 +9,12 @@ module Runfile
|
|
9
9
|
# 1. DocoptHelper - for deeper docopt related actions
|
10
10
|
# 2. RunfileHelper - for Runfile creation and system wide search
|
11
11
|
class Runner
|
12
|
+
include Singleton
|
13
|
+
include SettingsMixin
|
14
|
+
|
12
15
|
attr_accessor :last_usage, :last_help, :name, :version,
|
13
16
|
:summary, :namespace, :superspace
|
14
17
|
|
15
|
-
@@instance = nil
|
16
|
-
|
17
18
|
# Initialize all variables to sensible defaults.
|
18
19
|
def initialize
|
19
20
|
@superspace = nil # used when filename != Runfile
|
@@ -28,21 +29,17 @@ module Runfile
|
|
28
29
|
@summary = false # dsl: summary
|
29
30
|
end
|
30
31
|
|
31
|
-
# Return a singleton Runner instance.
|
32
|
-
def self.instance
|
33
|
-
@@instance ||= self.new
|
34
|
-
end
|
35
|
-
|
36
32
|
# Load and execute a Runfile call.
|
37
33
|
def execute(argv, filename='Runfile')
|
38
34
|
@ignore_settings = !filename
|
39
35
|
filename and File.file?(filename) or handle_no_runfile argv
|
40
36
|
begin
|
37
|
+
load settings.helper if settings.helper
|
41
38
|
load filename
|
42
39
|
rescue => ex
|
43
40
|
abort "Runfile error:\n#{ex.message}\n#{ex.backtrace[0]}"
|
44
41
|
end
|
45
|
-
|
42
|
+
run *argv
|
46
43
|
end
|
47
44
|
|
48
45
|
# Add an action to the @actions array, and use the last known
|
data/lib/runfile/settings.rb
CHANGED
@@ -6,9 +6,6 @@ module Runfile
|
|
6
6
|
# The Settings class handles '.runfile' YAML config files.
|
7
7
|
# If found in the current directory, we will use their content.
|
8
8
|
class Settings
|
9
|
-
def initialize
|
10
|
-
end
|
11
|
-
|
12
9
|
def as_struct
|
13
10
|
OpenStruct.new settings
|
14
11
|
end
|
@@ -24,4 +21,10 @@ module Runfile
|
|
24
21
|
end
|
25
22
|
end
|
26
23
|
|
24
|
+
module SettingsMixin
|
25
|
+
def settings
|
26
|
+
@settings ||= Settings.new.as_struct
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
27
30
|
end
|
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.6.
|
4
|
+
version: 0.6.3
|
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: 2016-04-
|
11
|
+
date: 2016-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|