k_builder 0.0.69 → 0.0.70

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: 344376d8ceaffc96fb8ebc4c0add3456bc6a1ff97f7d1b017286a6f4ea523c09
4
- data.tar.gz: 51eb8ddb6f7e3b578442423f0dfd9c08759012caa33003d1ecec0849d435b342
3
+ metadata.gz: e7c5cc6d0fcd0e80c90e29334a8971a78d167e84a49bb7caa008d7c043c15255
4
+ data.tar.gz: 3e2d0ba7259f8612a803b9b9ec78d102268cd9754a3370ae222c9e0ea380a5d3
5
5
  SHA512:
6
- metadata.gz: 0dde58c5926b4ecdf4952ee40b4babc4111cf8e9578ee2bacb29f6f6a14915e954631b4ef1c09d4148002357640f7323879325ac61cc7da9c8e5d40bb0168971
7
- data.tar.gz: 1a6b81315dd4a09c7bd48e83e5f3fb3b35a2b179a3fdd4a79d1d6e87e9645d86ae054ecc1332eed8a5e24e4628117b53c30b445264975ad93dc03e8f9d6daf8e
6
+ metadata.gz: 208c369a889e974c9ecdaa0a99aa5e3d3d902642498209e8264120c9e0ad459c29d615c8a9b501d5718b7c80c536daef07f46c934c686c55944801cec31d01f3
7
+ data.tar.gz: ccd298159362a0bf2eb626f4a4c50abe2acab54db1399fe99a06ee3776e7991756c839678c02bd9b2fe371f1f38045f9fa55c11979223c2a496d21e33c0ceac6
File without changes
File without changes
File without changes
File without changes
File without changes
data/hooks/pre-commit CHANGED
@@ -8,8 +8,8 @@ require 'English'
8
8
 
9
9
  exit 0 if ARGV.include?('--no-verify')
10
10
 
11
- warning_keywords = %w[console.log]
12
- keywords = %w[binding.pry console.dir byebug debugger]
11
+ warning_keywords = %w[]
12
+ keywords = %w[binding.pry console.dir byebug]
13
13
  files_changed = `git diff-index --name-only HEAD --`.split
14
14
 
15
15
  # puts '----------------------------------------------------------------------'
@@ -146,6 +146,8 @@ module KBuilder
146
146
  run_prettier file if opts.key?(:pretty)
147
147
  # TODO: Add test
148
148
  run_cop(full_file, fix_safe: true) if opts.key?(:cop) || opts.key?(:ruby_cop)
149
+ # TODO: Add test
150
+ run_command(file) if opts.key?(:run)
149
151
 
150
152
  # Need support for rubocop -a
151
153
  open_file(last_output_file) if opts.key?(:open)
@@ -164,6 +166,12 @@ module KBuilder
164
166
  end
165
167
 
166
168
  def play_action(action)
169
+ run_action(action)
170
+ action[:played] = true
171
+ end
172
+
173
+ # certain actions (e.g. set_current_folder) will run independently to play
174
+ def run_action(action)
167
175
  case action[:action]
168
176
  when :add_file
169
177
  add_file(action[:file], action[:opts])
@@ -177,11 +185,11 @@ module KBuilder
177
185
  set_current_folder(action[:folder_key])
178
186
  when :run_command
179
187
  run_command(action[:command])
188
+ when :run_script
189
+ run_script(action[:script])
180
190
  else
181
191
  log.error "Unknown action: #{action[:action]}"
182
192
  end
183
-
184
- action[:played] = true
185
193
  end
186
194
 
187
195
  alias touch add_file # it is expected that you would not supply any options, just a file name
@@ -529,6 +537,11 @@ module KBuilder
529
537
  # need to support the fork process options as I was not able to run
530
538
  # k_builder_watch -n because it hid all the following output
531
539
  system(build_command)
540
+
541
+ # FROM k_dsl
542
+ # system "/usr/local/bin/zsh #{output_file}" if execution_context == :system
543
+ # fork { exec("/usr/local/bin/zsh #{output_file}") } if execution_context == :fork
544
+
532
545
  end
533
546
  alias rc run_command
534
547
 
@@ -540,6 +553,34 @@ module KBuilder
540
553
  }
541
554
  end
542
555
 
556
+ # NOT TESTED, and not working with opts, this code needs rewrite
557
+ def run_script(script)
558
+ # Deep path create if needed
559
+ tf = target_folder
560
+
561
+ mkdir_p(tf)
562
+
563
+ Dir.chdir(tf) do
564
+ output, status = Open3.capture2(script) # , **opts)
565
+
566
+ unless status.success?
567
+ log.error("Script failed")
568
+ puts script
569
+ return nil
570
+ end
571
+
572
+ return output
573
+ end
574
+ end
575
+
576
+ def run_script_action(script)
577
+ {
578
+ action: :run_script,
579
+ played: false,
580
+ script: script
581
+ }
582
+ end
583
+
543
584
  def file_write(file, content, on_exist: :skip)
544
585
  self.last_output_file = file # if file not found, we still want to record this as the last_output_file
545
586
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KBuilder
4
- VERSION = '0.0.69'
4
+ VERSION = '0.0.70'
5
5
  end
data/lib/k_builder.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rubocop'
4
+ require "open3"
4
5
 
5
6
  require 'k_log'
6
7
  require 'k_util'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.69
4
+ version: 0.0.70
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-10 00:00:00.000000000 Z
11
+ date: 2022-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: handlebars-helpers
@@ -103,6 +103,11 @@ files:
103
103
  - Sample.drawio
104
104
  - Sample.xml
105
105
  - USAGE.md
106
+ - assets/a.html
107
+ - assets/b.html
108
+ - assets/highlight.min.js
109
+ - assets/highlight_css
110
+ - assets/ruby.min.js
106
111
  - bin/console
107
112
  - bin/k
108
113
  - bin/kgitsync
@@ -112,11 +117,6 @@ files:
112
117
  - hooks/update-version
113
118
  - k_builder.gemspec
114
119
  - lib/k_builder.rb
115
- - lib/k_builder/assets/a.html
116
- - lib/k_builder/assets/b.html
117
- - lib/k_builder/assets/highlight.min.js
118
- - lib/k_builder/assets/highlight_css
119
- - lib/k_builder/assets/ruby.min.js
120
120
  - lib/k_builder/base_builder.rb
121
121
  - lib/k_builder/base_configuration.rb
122
122
  - lib/k_builder/commands/base_command.rb