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 +4 -4
- data/.builders/_initialize.rb +16 -0
- data/.builders/basic.rb +34 -0
- data/.builders/x.rb +0 -0
- data/lib/k_builder/watch/version.rb +1 -1
- data/lib/k_builder/watch/watcher.rb +16 -6
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6404958f71123a099200477f721f4445c909e7f24d38e7b173e0403eed1a89c8
|
4
|
+
data.tar.gz: 871f0744ba82f69db71a6d4bcea21502237c702372d3668f8ad516f03fa42d16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
+
|
data/.builders/basic.rb
ADDED
@@ -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
|
@@ -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
|
-
#
|
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
|
-
|
39
|
-
|
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
|
44
|
-
rescue
|
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.
|
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"
|