raka 0.3.4 → 0.3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 895e1c40801f38ff5168449c25333ee40e9aca718f6d082a90d8898a75513373
4
- data.tar.gz: 9d8228de56582ef7202f30d10f32a285ad96197599344bd9a471dabb1699bdd3
3
+ metadata.gz: a4f6977d2467ab97772b25f068dccc278aaf0934b6f2f22188ae56dfd8580272
4
+ data.tar.gz: '093165815fa89e1f144c79d9102fb08215229181141638d3b40da74bcbe5845a'
5
5
  SHA512:
6
- metadata.gz: 3fe0e6223cc75ebe754f353155a1c78c96d25ae55bbffc108a6d8485038d06ad0cebda5be8093d50d0cb24e12b670ed0335b07b880816f5913e1f2712675e30c
7
- data.tar.gz: 245dbe2ed2b8f0966b0b3a980af00dda5cf084838228d40144e020de2a1545e3b856d90ebe51ab0419c53ca5a93a41929023903eb5171500e22c65ca44e043b1
6
+ metadata.gz: 6e31fc8179a2b22dd05a1982bfbc5ffb5db96ab57f054365c062c956a617530481eec4c9f8485b775e0493496ad385b34e2fe54798137ce1b4f6a2330d647e12
7
+ data.tar.gz: 758e5dc96f9544df4546e7b2955181aa9bfa3c354a3d5f66fd7ece88f292e473d5379fa5e64c1c89fec5a704c28f272f6dc7277825374e8292d2b7cae3fc09b0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
1
+ 0.3.6
data/lib/raka/compile.rb CHANGED
@@ -131,6 +131,7 @@ class DSLCompiler
131
131
 
132
132
  # compile token = rhs to rake rule
133
133
  # rubocop:disable Style/MethodLength
134
+ # rubocop:disable Style/PerceivedComplexity
134
135
  def compile(lhs, rhs)
135
136
  unless @env.instance_of?(Object)
136
137
  raise "DSL compile error: seems not a valid @env of rake with class #{@env.class}"
@@ -170,10 +171,12 @@ class DSLCompiler
170
171
  end
171
172
 
172
173
  # We generate a rule for each possible input type
173
- @options.input_types.each do |ext|
174
+
175
+ (lhs._options_[:input_exts] || @options.input_types).each do |ext|
174
176
  # We find auto source from both THE scope and the root
175
177
  create_rule lhs, ext, actions, extra_deps, extra_tasks
176
178
  end
177
179
  end
178
180
  end
179
181
  # rubocop:enable Style/MethodLength
182
+ # rubocop:enable Style/PerceivedComplexity
data/lib/raka/protocol.rb CHANGED
@@ -86,11 +86,23 @@ end
86
86
  # helper functions to implement LanguageImpl
87
87
  def run_cmd(env, cmd)
88
88
  env.logger.debug(cmd)
89
- Open3.popen3(cmd) do |_stdin, stdout, stderr, _thread|
90
- env.logger.debug(stdout.read)
91
- err = stderr.read
92
- env.logger.info(err) unless err.empty?
89
+ out_r, out_w = IO.pipe
90
+ err_r, err_w = IO.pipe
91
+ if env.logger.level <= 0
92
+ pid = spawn(cmd, out: out_w)
93
+ Thread.new do
94
+ env.logger.debug(out_r.gets) until out_r.eof
95
+ end
96
+ elsif env.logger.level == 1
97
+ pid = spawn(cmd, out: out_w)
98
+ else
99
+ pid = spawn(cmd, out: out_w, err: err_w)
93
100
  end
101
+
102
+ Process.wait pid
103
+ out_w.close
104
+ err_w.close
105
+ err_r.close
94
106
  end
95
107
 
96
108
  def pick_kwargs(klass, kwargs)
data/lib/raka/token.rb CHANGED
@@ -29,11 +29,17 @@ end
29
29
  class Token
30
30
  attr_reader :chain
31
31
 
32
- def initialize(compiler, context, chain, inline_scope)
32
+ def initialize(compiler, context, chain, inline_scope, input_exts: nil)
33
33
  @compiler = compiler
34
34
  @context = context
35
35
  @chain = chain
36
36
  @inline_scope = inline_scope
37
+ @options = {}
38
+ @options[:input_exts] = input_exts
39
+ end
40
+
41
+ def _options_
42
+ @options
37
43
  end
38
44
 
39
45
  def _captures_(target)
@@ -74,7 +80,7 @@ class Token
74
80
 
75
81
  # attach a new item to the chain
76
82
  def _attach_(item)
77
- Token.new(@compiler, @context, @chain + [item], @inline_scope)
83
+ Token.new(@compiler, @context, @chain + [item], @inline_scope, @options)
78
84
  end
79
85
 
80
86
  # rubocop:disable Style/MissingRespondToMissing # for DSL not essential
data/lib/raka.rb CHANGED
@@ -25,7 +25,7 @@ class Raka
25
25
  env = @env
26
26
  options = @options
27
27
  scopes = @scopes
28
- @env.define_singleton_method(ext_alias || ext) do |*args|
28
+ @env.define_singleton_method(ext_alias || ext) do |*args, **kw|
29
29
  # Here the compiler are bound with @options so that when we change @options
30
30
  # using methods like scope in Rakefile, the subsequent rules defined will honor
31
31
  # the new settings
@@ -33,7 +33,7 @@ class Raka
33
33
  inline_scope_pattern = !args.empty? ? args[0] : nil
34
34
  Token.new(
35
35
  DSLCompiler.new(env, options), Context.new(ext, scopes.clone),
36
- [], inline_scope_pattern
36
+ [], inline_scope_pattern, **kw
37
37
  )
38
38
  end
39
39
  end
@@ -41,7 +41,7 @@ class Raka
41
41
  def initialize(env, options)
42
42
  @env = env
43
43
  defaults = {
44
- output_types: [:csv], input_types: [],
44
+ output_types: [:csv], input_types: nil,
45
45
  type_aliases: {},
46
46
  scopes: [],
47
47
  lang: ['lang/shell'],
@@ -51,7 +51,10 @@ class Raka
51
51
 
52
52
  create_logger options.log_level || (ENV['LOG_LEVEL'] || Logger::INFO).to_i
53
53
 
54
- @options.input_types |= @options.output_types # any output can be used as intermediate
54
+ # if input_types given, obey it, otherwise use all output types as possible input types
55
+ unless @options.input_types
56
+ @options.input_types = @options.output_types # any output can be used as intermediate
57
+ end
55
58
  # specify root of scopes in options, scopes will append to each root
56
59
  @scopes = options.scopes.empty? ? [] : [options.scopes]
57
60
  @options.lang.each { |path| load File::join(File::dirname(__FILE__), "raka/#{path}/impl.rb") }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - yarray
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-09 00:00:00.000000000 Z
11
+ date: 2022-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake