bake-toolkit 2.55.1 → 2.56.0
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 +4 -4
- data/bin/bake-format +15 -33
- data/bin/bake-rtext-service +48 -0
- data/lib/bake/config/loader.rb +1 -1
- data/lib/blocks/compile.rb +0 -1
- data/lib/common/version.rb +9 -1
- data/lib/format/bake_format.rb +13 -3
- data/lib/format/options/options.rb +70 -0
- data/lib/rtext-service/options/options.rb +47 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b349db524315468c4e87e7fb31f2800dba7dc4e0b6abf87e0df75452cd9955a6
|
4
|
+
data.tar.gz: 106926fa41e1664269b45f67775922c315af94a62293d9e63a63b1563dd23a6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 130090f2f6a60491f6f29e83487abd441ce3994e3642cdbd9fe9d344d08a81c6d3ce99a6fba348bfab90367a37345adcc73aed136a94fb52c6a1f54e9a2e8de5
|
7
|
+
data.tar.gz: 3c9dc04ee97cc6bd4abd2fbf01f88b2eaf5a4e79196a0ef0b59a3ae3d031a68b133bfeefaba0e7124fd7e94e4c7aae16c75b261cdffe374591fd4163558a5733
|
data/bin/bake-format
CHANGED
@@ -3,47 +3,29 @@
|
|
3
3
|
$:.unshift(File.dirname(__FILE__)+"/../lib")
|
4
4
|
|
5
5
|
require_relative '../lib/format/bake_format'
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
output = ARGV[1]
|
11
|
-
elsif ARGV.size == 3
|
12
|
-
indent = ARGV[0]
|
13
|
-
indent = indent.split('=')
|
14
|
-
raise 'indent must have =' unless indent.size == 2
|
15
|
-
raise 'indent must start with --indent' unless indent.first == '--indent'
|
16
|
-
indent = indent.last
|
17
|
-
input = ARGV[1]
|
18
|
-
output = ARGV[2]
|
19
|
-
else
|
20
|
-
raise 'cannot understand'
|
21
|
-
end
|
22
|
-
rescue
|
23
|
-
puts [
|
24
|
-
"Usage: #{__FILE__} [--indent=string] input output",
|
25
|
-
" --indent=string, indent defaults to two spaces.",
|
26
|
-
" Note, you can escape a tab in bash by ctrl-vTAB with sourrounding \" e.g. \"--input= \"",
|
27
|
-
" input, filename or '-' for stdin",
|
28
|
-
" output, filename, '-' for stdout, '--' for same as input file"
|
29
|
-
].join("\n")
|
30
|
-
exit 1
|
31
|
-
end
|
6
|
+
require_relative '../lib/format/options/options'
|
7
|
+
|
8
|
+
$options = Bake::BakeFormatOptions.new(ARGV)
|
9
|
+
$options.parse_options()
|
32
10
|
|
33
11
|
data =
|
34
|
-
if input == '-'
|
12
|
+
if $options.input == '-'
|
35
13
|
STDIN.read
|
36
14
|
else
|
37
|
-
File.read(input)
|
15
|
+
File.read($options.input)
|
38
16
|
end
|
39
17
|
|
40
18
|
out =
|
41
|
-
if output == '-'
|
19
|
+
if $options.output == '-'
|
42
20
|
STDOUT
|
43
|
-
elsif output == '--'
|
44
|
-
out = input ==
|
21
|
+
elsif $options.output == '--'
|
22
|
+
out = ($options.input == '-') ? STDOUT : File.open($options.input, 'w')
|
45
23
|
else
|
46
|
-
File.open(output, 'w')
|
24
|
+
File.open($options.output, 'w')
|
47
25
|
end
|
48
26
|
|
49
|
-
|
27
|
+
if ($options.start_line != nil) && ($options.end_line != nil)
|
28
|
+
bake_format_in_range(data, out, $options.indent, $options.start_line, $options.end_line)
|
29
|
+
else
|
30
|
+
bake_format(data, out, $options.indent)
|
31
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift(File.dirname(__FILE__)+"/../lib")
|
4
|
+
|
5
|
+
require 'logger'
|
6
|
+
|
7
|
+
require 'rtext/default_loader'
|
8
|
+
require 'rtext/default_service_provider'
|
9
|
+
require 'rtext/service'
|
10
|
+
require 'rgen/environment'
|
11
|
+
require 'rgen/fragment/fragmented_model'
|
12
|
+
|
13
|
+
require_relative '../lib/bake/model/language'
|
14
|
+
require_relative '../lib/bake/model/metamodel'
|
15
|
+
require_relative '../lib/rtext-service/options/options'
|
16
|
+
|
17
|
+
$options = Bake::BakeRtextServiceOptions.new(ARGV)
|
18
|
+
$options.parse_options()
|
19
|
+
|
20
|
+
model = RGen::Fragment::FragmentedModel.new(:env => @env)
|
21
|
+
patterns = $options.patterns.map { |dir| File.join(dir, "{Project,Adapt}.meta") }
|
22
|
+
|
23
|
+
loader = RText::DefaultLoader.new(
|
24
|
+
Bake::Language,
|
25
|
+
model,
|
26
|
+
:file_provider => proc { Dir.glob(patterns) })
|
27
|
+
|
28
|
+
bake_service_provider = RText::DefaultServiceProvider.new(Bake::Language, model, loader)
|
29
|
+
|
30
|
+
logger = Logger.new(STDOUT)
|
31
|
+
logger.level =
|
32
|
+
case $options.loglevel
|
33
|
+
when 'debug' then Logger::DEBUG
|
34
|
+
when 'info' then Logger::INFO
|
35
|
+
when 'warn' then Logger::WARN
|
36
|
+
when 'error' then Logger::ERROR
|
37
|
+
when 'fatal' then Logger::FATAL
|
38
|
+
else Logger::INFO
|
39
|
+
end
|
40
|
+
|
41
|
+
on_startup = -> {
|
42
|
+
Bake::Version.printBakeRtextServiceVersion
|
43
|
+
puts "Idle timeout #{$options.timeout} seconds, log level '#{$options.loglevel}'"
|
44
|
+
}
|
45
|
+
|
46
|
+
rtext_rervice = RText::Service.new(bake_service_provider,
|
47
|
+
{ :timeout => $options.timeout, :logger => logger, :on_startup => on_startup })
|
48
|
+
rtext_rervice.run()
|
data/lib/bake/config/loader.rb
CHANGED
@@ -117,7 +117,7 @@ module Bake
|
|
117
117
|
checkCondition = lambda {|name,value|
|
118
118
|
return true if adaptHash[name].empty?
|
119
119
|
if !configHash.has_key?(name)
|
120
|
-
return adaptHash[name].any?{|ah| ah.
|
120
|
+
return adaptHash[name].any?{|ah| ah.match("")}
|
121
121
|
end
|
122
122
|
adaptHash[name].any? { |ah| configHash[name].any?{|ch| ah.match(ch)}}
|
123
123
|
}
|
data/lib/blocks/compile.rb
CHANGED
@@ -249,7 +249,6 @@ module Bake
|
|
249
249
|
srcFilePath = File.join(@projectDir, srcFilePath)
|
250
250
|
cmdJson[source] = srcFilePath
|
251
251
|
end
|
252
|
-
puts cmdJson
|
253
252
|
cmdJson.gsub!("\"" , "\\\"")
|
254
253
|
Blocks::CC2J << { :directory => @projectDir, :command => cmdJson, :file => srcFilePath }
|
255
254
|
end
|
data/lib/common/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Bake
|
2
2
|
class Version
|
3
3
|
def self.number
|
4
|
-
"2.
|
4
|
+
"2.56.0"
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.printBakeVersion(ry = "")
|
@@ -19,6 +19,14 @@ module Bake
|
|
19
19
|
def self.printBakecleanVersion()
|
20
20
|
printBakeVersion("clean")
|
21
21
|
end
|
22
|
+
|
23
|
+
def self.printBakeRtextServiceVersion()
|
24
|
+
printBakeVersion("-rtext-service")
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.printBakeFormatVersion()
|
28
|
+
printBakeVersion("-format")
|
29
|
+
end
|
22
30
|
end
|
23
31
|
|
24
32
|
expectedRGen = "0.8.2"
|
data/lib/format/bake_format.rb
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
def bake_format(data, output, indent)
|
2
|
+
start_line = 0
|
3
|
+
end_line = data.lines.count
|
4
|
+
bake_format_in_range(data, output, indent, start_line, end_line)
|
5
|
+
end
|
6
|
+
|
7
|
+
def bake_format_in_range(data, output, indent, start_line, end_line)
|
2
8
|
indent_level = 0
|
3
|
-
data.each_line do |l|
|
4
|
-
l.strip!
|
9
|
+
data.each_line.with_index do |l, index|
|
5
10
|
opening = l.count('{')
|
6
11
|
closing = l.count('}')
|
7
12
|
old_indent_level = indent_level
|
@@ -13,7 +18,12 @@ def bake_format(data, output, indent)
|
|
13
18
|
else
|
14
19
|
indent * indent_level
|
15
20
|
end
|
16
|
-
|
21
|
+
|
22
|
+
if index.between?(start_line, end_line)
|
23
|
+
l = (prefix + l.strip).rstrip
|
24
|
+
end
|
25
|
+
|
26
|
+
output.puts(l)
|
17
27
|
end
|
18
28
|
output.close
|
19
29
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require_relative '../../common/options/parser'
|
2
|
+
require_relative '../../common/version'
|
3
|
+
|
4
|
+
module Bake
|
5
|
+
|
6
|
+
class BakeFormatOptions < Parser
|
7
|
+
attr_reader :indent, :input, :output # String
|
8
|
+
attr_reader :start_line, :end_line # Fixnum
|
9
|
+
|
10
|
+
def initialize(argv)
|
11
|
+
super(argv)
|
12
|
+
|
13
|
+
@input = '-'
|
14
|
+
@output = '-'
|
15
|
+
@start_line = nil
|
16
|
+
@end_line = nil
|
17
|
+
@indent = ' '
|
18
|
+
@index = 0
|
19
|
+
|
20
|
+
add_option(["" ], lambda { |x| collect_args(x) })
|
21
|
+
add_option(["--indent" ], lambda { |x| @indent = x })
|
22
|
+
add_option(["--lines" ], lambda { |x| set_lines(x) })
|
23
|
+
add_option(["-h", "--help" ], lambda { usage; ExitHelper.exit(0) })
|
24
|
+
add_option(["--version" ], lambda { Bake::Version.printBakeFormatVersion; ExitHelper.exit(0) })
|
25
|
+
end
|
26
|
+
|
27
|
+
def usage
|
28
|
+
puts [
|
29
|
+
"Usage: #{__FILE__} [--indent=string] [--lines=string] input output",
|
30
|
+
" --indent=string, indent defaults to two spaces.",
|
31
|
+
" Note, you can escape a tab in bash by ctrl-vTAB with sourrounding \" e.g. \"--input= \"",
|
32
|
+
" --lines=string, [start line]:[end line] - format a range of lines.",
|
33
|
+
" input, filename or '-' for stdin",
|
34
|
+
" output, filename, '-' for stdout, '--' for same as input file"
|
35
|
+
].join("\n")
|
36
|
+
end
|
37
|
+
|
38
|
+
def parse_options()
|
39
|
+
parse_internal(true)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def collect_args(x)
|
47
|
+
if @index == 0
|
48
|
+
@input = x
|
49
|
+
elsif @index == 1
|
50
|
+
@output = x
|
51
|
+
elsif
|
52
|
+
Bake.formatter.printError("Error: wrong number of the arguments")
|
53
|
+
ExitHelper.exit(1)
|
54
|
+
end
|
55
|
+
|
56
|
+
@index += 1
|
57
|
+
end
|
58
|
+
|
59
|
+
def set_lines(lines)
|
60
|
+
m = lines.match(/(?<start_line>\d*):(?<end_line>\d*)/)
|
61
|
+
|
62
|
+
if m == nil
|
63
|
+
Bake.formatter.printError("Error: \"#{line}\" has invalid format")
|
64
|
+
ExitHelper.exit(1)
|
65
|
+
end
|
66
|
+
|
67
|
+
@start_line = m[:start_line].to_i
|
68
|
+
@end_line = m[:end_line].to_i
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require_relative '../../common/options/parser'
|
2
|
+
require_relative '../../common/version'
|
3
|
+
|
4
|
+
module Bake
|
5
|
+
class BakeRtextServiceOptions < Parser
|
6
|
+
attr_reader :loglevel # String
|
7
|
+
attr_reader :patterns
|
8
|
+
attr_reader :timeout # Number
|
9
|
+
|
10
|
+
def initialize(argv)
|
11
|
+
super(argv)
|
12
|
+
|
13
|
+
@loglevel = 'info'
|
14
|
+
@patterns = []
|
15
|
+
@timeout = 3600
|
16
|
+
|
17
|
+
add_option(["" ], lambda { |x| @patterns.push(x) })
|
18
|
+
add_option(["-l", "--loglevel" ], lambda { |x| set_loglevel(x) })
|
19
|
+
add_option(["-t", "--timeout" ], lambda { |x| @timeout = x.to_i })
|
20
|
+
add_option(["-h", "--help" ], lambda { usage; ExitHelper.exit(0) })
|
21
|
+
add_option(["--version" ], lambda { Bake::Version.printBakeFormatVersion; ExitHelper.exit(0) })
|
22
|
+
end
|
23
|
+
|
24
|
+
def usage
|
25
|
+
puts [
|
26
|
+
"Usage: #{__FILE__} [options] <dir patterns>",
|
27
|
+
" -l, --loglevel [string], log level is one of [debug, info, warn, error, fatal].",
|
28
|
+
" -t, --timeout [number], idle timeout in seconds after which the service will shutdown. Default is 3600.",
|
29
|
+
" dir patterns, glob patterns."
|
30
|
+
].join("\n")
|
31
|
+
end
|
32
|
+
|
33
|
+
def parse_options()
|
34
|
+
parse_internal(true)
|
35
|
+
@patterns = ['./**'] unless @patterns.any?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def set_loglevel(level)
|
41
|
+
unless level.match(/^debug|info|warn|error|fatal$/)
|
42
|
+
Bake.formatter.printError("Error: \"#{level}\" is wrong log level type")
|
43
|
+
Bake::ExitHelper.exit(1)
|
44
|
+
end
|
45
|
+
|
46
|
+
@loglevel = level
|
47
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bake-toolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.56.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Schaal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rtext
|
@@ -145,6 +145,7 @@ executables:
|
|
145
145
|
- bakeqac
|
146
146
|
- bakeclean
|
147
147
|
- bake-format
|
148
|
+
- bake-rtext-service
|
148
149
|
extensions: []
|
149
150
|
extra_rdoc_files: []
|
150
151
|
files:
|
@@ -152,6 +153,7 @@ files:
|
|
152
153
|
- bin/bake
|
153
154
|
- bin/bake-doc
|
154
155
|
- bin/bake-format
|
156
|
+
- bin/bake-rtext-service
|
155
157
|
- bin/bakeclean
|
156
158
|
- bin/bakeqac
|
157
159
|
- bin/bakery
|
@@ -242,7 +244,9 @@ files:
|
|
242
244
|
- lib/common/utils.rb
|
243
245
|
- lib/common/version.rb
|
244
246
|
- lib/format/bake_format.rb
|
247
|
+
- lib/format/options/options.rb
|
245
248
|
- lib/multithread/job.rb
|
249
|
+
- lib/rtext-service/options/options.rb
|
246
250
|
- lib/tocxx.rb
|
247
251
|
- license.txt
|
248
252
|
homepage:
|