raka 0.3.4 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 895e1c40801f38ff5168449c25333ee40e9aca718f6d082a90d8898a75513373
4
- data.tar.gz: 9d8228de56582ef7202f30d10f32a285ad96197599344bd9a471dabb1699bdd3
3
+ metadata.gz: 011d4dda2d79391c732fb51b383a015ee6f0e6b10f4bd1eb8e976af16100bdf5
4
+ data.tar.gz: 3e83d92014c4360dd0180db04e4d7abed90973e35a986dfa9b7afd25c16a1b86
5
5
  SHA512:
6
- metadata.gz: 3fe0e6223cc75ebe754f353155a1c78c96d25ae55bbffc108a6d8485038d06ad0cebda5be8093d50d0cb24e12b670ed0335b07b880816f5913e1f2712675e30c
7
- data.tar.gz: 245dbe2ed2b8f0966b0b3a980af00dda5cf084838228d40144e020de2a1545e3b856d90ebe51ab0419c53ca5a93a41929023903eb5171500e22c65ca44e043b1
6
+ metadata.gz: 8fa7be1a0d0e86851c36cb6a57a1638a10eb52a15f03ebc73819dbf1e6984524ecf909ddbad754d72542f800a6ff10bdd80d6feb7e5f4dbe56b9b53d86f26f04
7
+ data.tar.gz: f77dbe680509b21ceac1f13c1abe583c96d91ba6156efa88afc94519c4a837b220361851b5e4f56c7d2002eda79d6022c4cebcab6c341eea6af582d92ce919b8
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
1
+ 0.3.8
data/bin/raka CHANGED
@@ -62,22 +62,18 @@ cmd = ''
62
62
  opt_str = "-f #{entry}"
63
63
  opt_str += " -m -j #{options[:jobs]}" if options.key?(:jobs)
64
64
  cmd += "#{env}rake #{opt_str} #{extra_args} #{targets}"
65
+ dry_cmd = 'RUBYOPT="-W0" ' + cmd + ' --dry-run'
66
+ _, dry_msg, status = Open3.capture3(dry_cmd)
67
+ exit(status) if status != 0
68
+ unless (dry_msg.lines.first.chomp =~ /^.*\(.*not_needed.*\)$/).nil?
69
+ puts 'All targets are up to date'
70
+ exit(0)
71
+ end
65
72
  puts cmd
66
- output = []
67
- ro, out = IO.pipe
68
- re, err = IO.pipe
69
73
  pid = fork do
70
- status = system(cmd, out: out, err: err)
74
+ status = system(cmd)
71
75
  puts 'Error: rake returns the following information:' unless status
72
76
  exit($CHILD_STATUS.exitstatus)
73
77
  end
74
- out.close
75
- err.close
76
- ro.each_line do |l|
77
- puts l
78
- output << l.chomp
79
- end
80
- re.each_line { |l| puts l; }
81
78
 
82
79
  Process.wait(pid)
83
- puts 'All targets are up to date' if output.empty? && $CHILD_STATUS.exitstatus == 0
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.8
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