k_builder-watch 0.0.11 → 0.0.12

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: 877ec75e394602ed2e76d68471f91f8b0bc6ab3e999bb1f1efc1a65c31bd0d11
4
- data.tar.gz: f34786d2d37180d8b2e978df8aa21e524d76ce9cd4661e8891da0b854523b668
3
+ metadata.gz: 6404958f71123a099200477f721f4445c909e7f24d38e7b173e0403eed1a89c8
4
+ data.tar.gz: 871f0744ba82f69db71a6d4bcea21502237c702372d3668f8ad516f03fa42d16
5
5
  SHA512:
6
- metadata.gz: 87c57f82500f7f7818dd823153a973a65b2b3604e7d75b76cebcad3d8c565e15ff4dfa6c38e45c77d7b82cdb3b7dcb5b321309c98dc8a7e5f6613c000a76a0ef
7
- data.tar.gz: 96129025060ad6dbe86c266184e52d884bd05aaae2e0db6c816d472d6da96dbf21be765bc191956ed5ad7761e784f626fb38b9ddf1fc51fb5854e327de0f5f56
6
+ metadata.gz: 2067da17c014db133c885e9431ce23306346ff9d70645ee224fae07640c71e75e1887ac2b35809d2286a748aaf281fd43b807a0f9944ddc697505a1de728bf28
7
+ data.tar.gz: 4a016a9f28efa3f3fbd158c4d6f81ef9f7db163354e57d8aea158247d6923f8f95a5ce8b3f28bdd49746f2ee285cd93cd6248dfeff9d2be9085b5e64f7fde490
@@ -0,0 +1,16 @@
1
+ Handlebars::Helpers.configure do |config|
2
+ config_file = File.join(Gem.loaded_specs['handlebars-helpers'].full_gem_path, '.handlebars_helpers.json')
3
+ config.helper_config_file = config_file
4
+ end
5
+
6
+ KBuilder.reset
7
+ templates_ruby = '~/dev/kgems/k_dsl/_/.template/ruby-cmdlet'
8
+ target_root = '~/dev/kgems/k_builder-watch/'
9
+
10
+ KBuilder.configure do |config|
11
+ config.target_folders.add(:app , target_root)
12
+
13
+ config.template_folders.add(:global , File.join(templates_ruby , '.global_template'))
14
+ # config.template_folders.add(:app , File.join(template_root , '.app_template'))
15
+ end
16
+
@@ -0,0 +1,34 @@
1
+ # require '.builders/_initialize.rb'
2
+
3
+ $LOAD_PATH.unshift(File.join(Dir.pwd, '.builders'))
4
+ load 'x.rb'
5
+ puts 'fucit'
6
+ # load 'x.rb'
7
+ # puts JSON.pretty_generate(KBuilder.configuration.to_h)
8
+
9
+ # builder = KBuilder::BaseBuilder.init
10
+
11
+ # builder
12
+ # .add_file('main.rb', template_file: 'class.rb', name: 'main')
13
+ # .add_file('person.rb',
14
+ # template_file: 'model.rb',
15
+ # name: 'person',
16
+ # fields: %i[first_name last_name])
17
+ # .add_file('address.rb',
18
+ # template_file: 'model.rb',
19
+ # name: 'address',
20
+ # fields: %i[street1 street2 post_code state])
21
+ # .add_file('css/index.css',
22
+ # template: '{{#each colors}} .{{.}} { color: {{.}} } {{/each}}',
23
+ # colors: %w[red blue green],
24
+ # pretty: true)
25
+
26
+ # # /Users/davidcruwys/dev/xxx-watch
27
+ # # /Users/davidcruwys/dev/xxx-watch/basic.rb
28
+
29
+
30
+ # file = builder.target_file('main.rb')
31
+ # puts file
32
+ # puts File.exist?(file)
33
+ # system("code #{file}")
34
+ # puts 'basic'
data/.builders/x.rb ADDED
File without changes
@@ -2,6 +2,6 @@
2
2
 
3
3
  module KBuilder
4
4
  module Watch
5
- VERSION = '0.0.11'
5
+ VERSION = '0.0.12'
6
6
  end
7
7
  end
@@ -8,8 +8,9 @@ require 'io/console'
8
8
  # require 'handlebars/helpers/configuration'
9
9
 
10
10
  module KBuilder
11
+ # Watch supports any watch and execute processes for builders
11
12
  module Watch
12
- # Watch fo
13
+ # Watcher does the actual file watching and run the processor
13
14
  class Watcher
14
15
  attr_accessor :directory
15
16
 
@@ -21,6 +22,7 @@ module KBuilder
21
22
  # watch_file = File.join(directory, 'DOMAIN_INSTRUCTIONS.MD')
22
23
 
23
24
  def start
25
+ clear_screen
24
26
  puts 'Watching for file changes'
25
27
  puts "Directory: #{directory}"
26
28
  # puts "Watch File: #{watch_file}"
@@ -34,17 +36,25 @@ module KBuilder
34
36
  end
35
37
  end
36
38
 
39
+ # rubocop:disable Lint/RescueException
37
40
  def process_updated_file(filename)
38
- puts "\n" * 70
39
- $stdout.clear_screen
41
+ $LOAD_PATH.unshift(File.join(Dir.pwd, '.builders'))
42
+ # Can I set __FILE__ during class_eval
43
+
40
44
  puts "File updated: #{filename}"
41
45
 
42
46
  content = File.read(filename)
43
- Object.class_eval content
44
- rescue StandardError => e
47
+ Object.class_eval(content, __FILE__, __LINE__)
48
+ rescue Exception => e
45
49
  puts e.message
46
- puts e.backtrace.join("\n")
50
+ puts e.backtrace.select { |ex| ex.start_with?(filename) }.join("\n")
47
51
  end
52
+ # rubocop:enable Lint/RescueException
53
+ end
54
+
55
+ def clear_screen
56
+ puts "\n" * 70
57
+ $stdout.clear_screen
48
58
  end
49
59
  end
50
60
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k_builder-watch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
@@ -75,6 +75,9 @@ executables:
75
75
  extensions: []
76
76
  extra_rdoc_files: []
77
77
  files:
78
+ - ".builders/_initialize.rb"
79
+ - ".builders/basic.rb"
80
+ - ".builders/x.rb"
78
81
  - ".github/workflows/main.yml"
79
82
  - ".gitignore"
80
83
  - ".rspec"