run_tasks 1.3.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/src/run/markdown/abstract_tag.rb +44 -0
- data/src/run/markdown/bold_tag.rb +18 -0
- data/src/run/markdown/code_tag.rb +18 -0
- data/src/run/markdown/engine.rb +22 -0
- data/src/run/markdown/italic_tag.rb +18 -0
- data/src/run.rb +25 -27
- metadata +9 -4
- data/src/run/markdown.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3f8a01e9cf83e14af770fdf07028b7eeef28e5a2
|
4
|
+
data.tar.gz: 6298e13d2b841b1e66f3c095538fd99ea486346c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 840a4dea8f6978e7a4b48d48afe7148707a127a8d619698ffc7ffe11854996422b1aefe1c52be023728e9f8faf4e2fd61f0034b9821a03c43cecef7d20dec637
|
7
|
+
data.tar.gz: 0d3d3b5d42de907bf85acd67f14698231756af2c08c5c767aa6bd762aa2085cf83b770bdbc60f58ad8e9790710a4e9f167d8837c63ecd8f10b8fa6add574ff27
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Markdown
|
2
|
+
module AbstractTag
|
3
|
+
def initialize(value)
|
4
|
+
case value
|
5
|
+
when String
|
6
|
+
@string = value
|
7
|
+
when AbstractTag
|
8
|
+
@tag = value
|
9
|
+
else
|
10
|
+
raise "Invalid value of '#{value.class.name}' class"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_ansi
|
15
|
+
string = @string || @tag.to_ansi
|
16
|
+
pattern = Regexp.new(
|
17
|
+
"(^|.+?)" \
|
18
|
+
"(?:#{tokens.map{ |token| "\\" + token.chars.join("\\") }.join('|')})" \
|
19
|
+
"(.+?)" \
|
20
|
+
"(?:#{tokens.map{ |token| "\\" + token.chars.join("\\") }.join('|')})" \
|
21
|
+
"($|.+)"
|
22
|
+
)
|
23
|
+
|
24
|
+
loop do
|
25
|
+
string = string.sub(pattern) do
|
26
|
+
Regexp.last_match[1] + replace_by(Regexp.last_match[2]) + Regexp.last_match[3]
|
27
|
+
end
|
28
|
+
break if !Regexp.last_match
|
29
|
+
end
|
30
|
+
|
31
|
+
string
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
def tokens
|
37
|
+
raise "Not implemented"
|
38
|
+
end
|
39
|
+
|
40
|
+
def replace_by(string)
|
41
|
+
raise "Not implemented"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative "./bold_tag"
|
2
|
+
require_relative "./code_tag"
|
3
|
+
require_relative "./italic_tag"
|
4
|
+
|
5
|
+
module Markdown
|
6
|
+
class Engine
|
7
|
+
def initialize(string)
|
8
|
+
@string = string
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_ansi
|
12
|
+
# The tags are ordered by priority.
|
13
|
+
# E.g. `Bold` should run before `Italic`.
|
14
|
+
tag = Code.new(
|
15
|
+
Italic.new(
|
16
|
+
Bold.new(@string)
|
17
|
+
)
|
18
|
+
)
|
19
|
+
tag.to_ansi
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/src/run.rb
CHANGED
@@ -9,8 +9,8 @@ require "securerandom"
|
|
9
9
|
|
10
10
|
##########################################################################################
|
11
11
|
|
12
|
-
require_relative "#{__dir__}/run/markdown"
|
13
12
|
require_relative "#{__dir__}/run/string"
|
13
|
+
require_relative "#{__dir__}/run/markdown/engine"
|
14
14
|
|
15
15
|
##########################################################################################
|
16
16
|
|
@@ -34,19 +34,17 @@ def task(name, help = "", &block)
|
|
34
34
|
if !name.is_a?(Symbol)
|
35
35
|
puts
|
36
36
|
puts "First task parameter must be a symbol".red
|
37
|
-
puts
|
38
37
|
exit 6
|
39
38
|
end
|
40
39
|
if !help.is_a?(String)
|
41
40
|
puts
|
42
41
|
puts "Second task parameter must be a string".red
|
43
|
-
puts
|
44
42
|
exit 6
|
45
43
|
end
|
46
44
|
@tasks.store(
|
47
45
|
name,
|
48
46
|
{
|
49
|
-
:help => Markdown.new(help).to_ansi,
|
47
|
+
:help => Markdown::Engine.new(help).to_ansi,
|
50
48
|
:block => block
|
51
49
|
}
|
52
50
|
)
|
@@ -89,7 +87,6 @@ rescue => error
|
|
89
87
|
puts
|
90
88
|
puts "Unable to load #{uri}:".red
|
91
89
|
puts "#{error.class}: #{error.message}".red
|
92
|
-
puts
|
93
90
|
exit 8
|
94
91
|
end
|
95
92
|
|
@@ -106,7 +103,6 @@ RUNFILE = "Runfile.rb"
|
|
106
103
|
if !File.exists?(RUNFILE)
|
107
104
|
puts
|
108
105
|
puts "#{RUNFILE} does not exist".red
|
109
|
-
puts
|
110
106
|
exit 7
|
111
107
|
end
|
112
108
|
|
@@ -116,7 +112,6 @@ rescue SyntaxError => error
|
|
116
112
|
puts
|
117
113
|
puts "The Runfile contains a syntax error:".red
|
118
114
|
puts error.message.red
|
119
|
-
puts
|
120
115
|
exit 5
|
121
116
|
end
|
122
117
|
|
@@ -146,25 +141,27 @@ end
|
|
146
141
|
# Verify the latest release version.
|
147
142
|
if VERSION && HOMEPAGE
|
148
143
|
Thread.new do
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
144
|
+
begin
|
145
|
+
contents = URI.parse("#{HOMEPAGE}/master/run.gemspec")
|
146
|
+
.open
|
147
|
+
.read
|
148
|
+
version = /^\s*s.version\s*=\s*"(.+?)"\s*$/.match(contents)
|
149
|
+
if !version.nil?
|
150
|
+
next if File.exists?("/tmp/run_dismiss_#{version}")
|
151
|
+
current = VERSION.split "."
|
152
|
+
latest = version[1].split "."
|
153
|
+
if current[0].to_i < latest[0].to_i ||
|
154
|
+
current[1].to_i < latest[1].to_i ||
|
155
|
+
current[2].to_i < latest[2].to_i
|
156
|
+
puts "New ".cyan + version[1].yellow + " version released!".cyan
|
157
|
+
puts
|
158
|
+
puts "You can upgrade with:".cyan + "gem update run_tasks".yellow
|
159
|
+
puts
|
160
|
+
File.write "/tmp/run_dismiss_#{version}", ""
|
161
|
+
end
|
165
162
|
end
|
163
|
+
rescue
|
166
164
|
end
|
167
|
-
rescue
|
168
165
|
end
|
169
166
|
end
|
170
167
|
|
@@ -173,14 +170,15 @@ name = ARGV[0].gsub('-', '_').to_sym # Auto-fix hyphens to underscores.
|
|
173
170
|
if !@tasks.include?(name)
|
174
171
|
puts
|
175
172
|
puts "Unknown '#{name}' task".red
|
176
|
-
puts
|
177
173
|
exit 2
|
178
174
|
end
|
179
175
|
begin
|
180
|
-
run(name, *ARGV.slice(1
|
176
|
+
run(name, *ARGV.slice(Range.new(1, ARGV.size - 1)))
|
181
177
|
rescue Interrupt
|
182
178
|
exit 3
|
183
179
|
rescue => error
|
184
|
-
puts
|
180
|
+
puts
|
181
|
+
puts "· #{error.message}".red
|
182
|
+
puts "· #{error.backtrace.first}".red
|
185
183
|
exit 4
|
186
184
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: run_tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aurélien Delogu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: aurelien.delogu@gmail.com
|
@@ -19,7 +19,11 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- bin/run
|
21
21
|
- src/run.rb
|
22
|
-
- src/run/markdown.rb
|
22
|
+
- src/run/markdown/abstract_tag.rb
|
23
|
+
- src/run/markdown/bold_tag.rb
|
24
|
+
- src/run/markdown/code_tag.rb
|
25
|
+
- src/run/markdown/engine.rb
|
26
|
+
- src/run/markdown/italic_tag.rb
|
23
27
|
- src/run/string.rb
|
24
28
|
homepage: https://github.com/pyrsmk/run
|
25
29
|
licenses:
|
@@ -40,7 +44,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
44
|
- !ruby/object:Gem::Version
|
41
45
|
version: '0'
|
42
46
|
requirements: []
|
43
|
-
|
47
|
+
rubyforge_project:
|
48
|
+
rubygems_version: 2.5.2
|
44
49
|
signing_key:
|
45
50
|
specification_version: 4
|
46
51
|
summary: Run project tasks with ease
|
data/src/run/markdown.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require_relative "./string"
|
2
|
-
|
3
|
-
class Markdown
|
4
|
-
def initialize(string)
|
5
|
-
@string = string
|
6
|
-
end
|
7
|
-
|
8
|
-
def to_ansi
|
9
|
-
# Apply private methods onto string.
|
10
|
-
private_methods(false).reject{ |name| name == :initialize }
|
11
|
-
.reduce(@string) do |string, method|
|
12
|
-
send(method, string)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def bold(string)
|
19
|
-
string.gsub(/([^*_]|^)[*_]{2}([^*_]+)[*_]{2}([^*_]|$)/) do
|
20
|
-
Regexp.last_match[1] + Regexp.last_match[2].bold + Regexp.last_match[3]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def code(string)
|
25
|
-
string.gsub(/([^`]|^)`([^*_]+)`([^`]|$)/) do
|
26
|
-
Regexp.last_match[1] + Regexp.last_match[2].cyan + Regexp.last_match[3]
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def italic(string)
|
31
|
-
string.gsub(/([^*_]|^)[*_]{1}([^*_]+)[*_]{1}([^*_]|$)/) do
|
32
|
-
Regexp.last_match[1] + Regexp.last_match[2].italic + Regexp.last_match[3]
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|