k_manager 0.0.24 → 0.0.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.builders/_.rb +1 -0
- data/.builders/boot.rb +66 -0
- data/.builders/generators/01-bootstrap.rb +90 -0
- data/.builders/generators/02-draw-chart.rb +37 -0
- data/.builders/graph/test.drawio +202 -0
- data/.builders/graph/xmen.drawio +10 -0
- data/.builders/graph/xmen.txt +10 -0
- data/.rubocop.yml +7 -1
- data/Gemfile +6 -1
- data/docs/flow.drawio +1 -16
- data/docs/shapes +75 -0
- data/hooks/update-version +1 -1
- data/k_manager.gemspec +4 -0
- data/lib/k_manager/area.rb +1 -1
- data/lib/k_manager/cli/new.rb +93 -21
- data/lib/k_manager/cli/watch.rb +20 -4
- data/lib/k_manager/manager.rb +60 -15
- data/lib/k_manager/overview/dashboard.rb +29 -1
- data/lib/k_manager/overview/models.rb +4 -1
- data/lib/k_manager/overview/queries.rb +1 -0
- data/lib/k_manager/resources/base_resource.rb +37 -11
- data/lib/k_manager/resources/resource_document_factory.rb +2 -0
- data/lib/k_manager/resources/resource_manager.rb +33 -0
- data/lib/k_manager/version.rb +1 -1
- data/lib/k_manager/watcher.rb +35 -11
- data/lib/k_manager.rb +16 -9
- data/tasks/watch.rake +0 -91
- metadata +52 -3
- data/lib/k_manager/configuration/project_config.rb +0 -14
data/lib/k_manager/watcher.rb
CHANGED
@@ -20,41 +20,65 @@ module KManager
|
|
20
20
|
# process_updated_file(filename) if event == :updated # || event == :created
|
21
21
|
# process_deleted_file(filename) if event == :deleted
|
22
22
|
|
23
|
-
# rubocop:disable Lint/RescueException, Metrics/AbcSize
|
23
|
+
# rubocop:disable Lint/RescueException, Metrics/AbcSize, Metrics/MethodLength
|
24
24
|
def start
|
25
25
|
boot_up
|
26
26
|
|
27
27
|
update_dashboard
|
28
28
|
|
29
|
-
Filewatcher.new(watch_folder)
|
30
|
-
changes.each do |filename, event|
|
31
|
-
clear_screen
|
29
|
+
watcher = Filewatcher.new(watch_folder)
|
32
30
|
|
33
|
-
|
31
|
+
watcher.watch do |changes|
|
32
|
+
watcher.pause
|
33
|
+
if changes.length > 1
|
34
|
+
log.kv 'HOW MANY CHANGES', changes.length
|
35
|
+
log.block changes
|
36
|
+
end
|
34
37
|
|
35
|
-
|
38
|
+
changes.each do |filename, event|
|
39
|
+
# NOTE: KManager will not support space in file name, but this will at least deal with file copies, where " copy" is added to a file name.
|
36
40
|
filename = filename.gsub(' ', '%20')
|
37
41
|
|
38
|
-
|
42
|
+
log_file_event(event, filename)
|
39
43
|
|
40
44
|
uri = URI::File.build(host: nil, path: filename)
|
45
|
+
|
46
|
+
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
41
47
|
KManager.resource_changed(uri, event)
|
48
|
+
finish_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
49
|
+
time_taken = finish_time - start_time
|
42
50
|
|
43
51
|
sleep KManager.opts.sleep if KManager.opts.sleep.positive?
|
44
52
|
|
53
|
+
clear_screen
|
54
|
+
|
55
|
+
log_file_event(event, filename)
|
56
|
+
log.kv 'Time Taken', time_taken.to_d.round(3, :truncate).to_f if KManager.opts.show.time_taken
|
57
|
+
|
45
58
|
update_dashboard
|
46
|
-
|
59
|
+
|
60
|
+
puts KManager.opts.show.finished_message if KManager.opts.show.finished
|
47
61
|
end
|
62
|
+
watcher.resume
|
48
63
|
end
|
64
|
+
rescue Interrupt, SystemExit
|
65
|
+
raise
|
49
66
|
rescue Exception => e
|
50
|
-
# TODO: Make style a setting: :message, :short, (whatever the last one is)
|
51
|
-
log.exception(e, style: KManager.opts.exception_style)
|
52
67
|
log.exception(e)
|
53
68
|
end
|
54
|
-
# rubocop:enable Lint/RescueException, Metrics/AbcSize
|
69
|
+
# rubocop:enable Lint/RescueException, Metrics/AbcSize, Metrics/MethodLength
|
55
70
|
|
56
71
|
private
|
57
72
|
|
73
|
+
def log_file_event(event, filename)
|
74
|
+
current = Time.now.strftime('%H:%M:%S')
|
75
|
+
output = "#{current} - #{event}: #{filename}"
|
76
|
+
|
77
|
+
log.warn(output) if event == :updated
|
78
|
+
log.error(output) if event == :deleted
|
79
|
+
log.info(output) if event == :created
|
80
|
+
end
|
81
|
+
|
58
82
|
def boot_up
|
59
83
|
clear_screen
|
60
84
|
|
data/lib/k_manager.rb
CHANGED
@@ -4,17 +4,20 @@ require 'csv'
|
|
4
4
|
require 'dry-struct'
|
5
5
|
require 'forwardable'
|
6
6
|
require 'k_log'
|
7
|
+
require 'k_config'
|
7
8
|
require 'k_doc'
|
9
|
+
require 'k_domain'
|
10
|
+
require 'k_director'
|
8
11
|
require 'k_fileset'
|
9
12
|
require 'k_builder'
|
10
13
|
require 'k_ext/github'
|
14
|
+
require 'drawio_dsl'
|
11
15
|
|
12
16
|
# IS THIS NEEDED? this was used for infer_key
|
13
17
|
require 'handlebars/helpers/string_formatting/dasherize'
|
14
18
|
require 'handlebars/helpers/string_formatting/snake'
|
15
19
|
|
16
20
|
require 'k_manager/version'
|
17
|
-
require 'k_manager/configuration/project_config'
|
18
21
|
require 'k_manager/overview/models'
|
19
22
|
require 'k_manager/overview/queries'
|
20
23
|
require 'k_manager/overview/dump_json'
|
@@ -96,7 +99,18 @@ module KManager
|
|
96
99
|
@manager = Manager.new
|
97
100
|
end
|
98
101
|
|
99
|
-
def_delegators
|
102
|
+
def_delegators :manager,
|
103
|
+
:opts,
|
104
|
+
:areas,
|
105
|
+
:area_resources,
|
106
|
+
:area_documents,
|
107
|
+
:add_area,
|
108
|
+
:find_document,
|
109
|
+
:fire_actions,
|
110
|
+
:resource_changed,
|
111
|
+
:boot,
|
112
|
+
:reboot,
|
113
|
+
:debug
|
100
114
|
|
101
115
|
# ----------------------------------------------------------------------
|
102
116
|
# Document factory facade methods
|
@@ -108,13 +122,6 @@ module KManager
|
|
108
122
|
|
109
123
|
def_delegators :document_factory, :action, :model, :csv, :json, :yaml
|
110
124
|
|
111
|
-
# TODO: DEPRECATE or REFACTOR
|
112
|
-
def new_project_config(&block)
|
113
|
-
config = KManager::Configuration::ProjectConfig.new
|
114
|
-
block.call(config) if block_given?
|
115
|
-
config
|
116
|
-
end
|
117
|
-
|
118
125
|
# ----------------------------------------------------------------------
|
119
126
|
# Utilities
|
120
127
|
# ----------------------------------------------------------------------
|
data/tasks/watch.rake
CHANGED
@@ -16,94 +16,3 @@ namespace :k_manager do
|
|
16
16
|
watcher.start
|
17
17
|
end
|
18
18
|
end
|
19
|
-
|
20
|
-
# require 'pry'
|
21
|
-
# require 'k_manager'
|
22
|
-
# require 'filewatcher'
|
23
|
-
# require 'io/console'
|
24
|
-
|
25
|
-
# class Watcher
|
26
|
-
# include KLog::Logging
|
27
|
-
|
28
|
-
# attr_reader :watch_folder
|
29
|
-
# attr_reader :boot_file
|
30
|
-
|
31
|
-
# def initialize(watch_folder, boot_file)
|
32
|
-
# @watch_folder = watch_folder
|
33
|
-
# @boot_file = boot_file
|
34
|
-
# end
|
35
|
-
|
36
|
-
#
|
37
|
-
# def start
|
38
|
-
# boot(boot_file)
|
39
|
-
# update_dashboard
|
40
|
-
|
41
|
-
# Filewatcher.new(watch_folder).watch do |changes|
|
42
|
-
# changes.each do |filename, event|
|
43
|
-
# $stdout.clear_screen
|
44
|
-
# puts "File #{event}: #{filename}"
|
45
|
-
|
46
|
-
# uri = URI::File.build(host: nil, path: filename)
|
47
|
-
# KManager.resource_changed(uri, event)
|
48
|
-
|
49
|
-
# # process_created_file(filename) if event == :created
|
50
|
-
# # process_updated_file(filename) if event == :updated # || event == :created
|
51
|
-
# # process_deleted_file(filename) if event == :deleted
|
52
|
-
# update_dashboard
|
53
|
-
# end
|
54
|
-
# end
|
55
|
-
# rescue Exception => e
|
56
|
-
# # TODO: Make style a setting: :message, :short, (whatever the last one is)
|
57
|
-
# log.exception(e, style: :short)
|
58
|
-
# end
|
59
|
-
# # private
|
60
|
-
|
61
|
-
# def boot(boot_file)
|
62
|
-
# clear_screen
|
63
|
-
|
64
|
-
# content = File.read(boot_file)
|
65
|
-
# Object.class_eval(content, boot_file)
|
66
|
-
# end
|
67
|
-
|
68
|
-
#
|
69
|
-
# def process_updated_file(filename)
|
70
|
-
# clear_screen
|
71
|
-
# update_load_path(filename)
|
72
|
-
|
73
|
-
# puts "File updated: #{filename}"
|
74
|
-
# rescue Exception => e
|
75
|
-
# # TODO: Make style a setting: :message, :short, (whatever the last one is)
|
76
|
-
# log.exception(e, style: :short)
|
77
|
-
# end
|
78
|
-
|
79
|
-
# def process_updated_file_old(filename)
|
80
|
-
# clear_screen
|
81
|
-
# update_load_path(filename)
|
82
|
-
|
83
|
-
# puts "File updated: #{filename}"
|
84
|
-
|
85
|
-
# content = File.read(filename)
|
86
|
-
# Object.class_eval(content, filename)
|
87
|
-
# rescue Exception => e
|
88
|
-
# # TODO: Make style a setting: :message, :short, (whatever the last one is)
|
89
|
-
# log.exception(e, style: :short)
|
90
|
-
# end
|
91
|
-
# # def update_dashboard
|
92
|
-
# dashboard = KManager::Overview::Dashboard.new(KManager.manager)
|
93
|
-
# dashboard.areas
|
94
|
-
# dashboard.resources
|
95
|
-
# dashboard.documents
|
96
|
-
# end
|
97
|
-
|
98
|
-
# def update_load_path(filename)
|
99
|
-
# dirname = File.dirname(filename)
|
100
|
-
|
101
|
-
# # This needs to be in detailed logging
|
102
|
-
# $LOAD_PATH.unshift(dirname) unless $LOAD_PATH.find { |path| path.start_with?(dirname) }
|
103
|
-
# end
|
104
|
-
|
105
|
-
# def clear_screen
|
106
|
-
# puts "\n" * 70
|
107
|
-
# $stdout.clear_screen
|
108
|
-
# end
|
109
|
-
# end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: k_manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.32
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: drawio_dsl
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.1'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: dry-struct
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +66,20 @@ dependencies:
|
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: 0.0.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: k_director
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.1'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.1'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: k_doc
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +94,20 @@ dependencies:
|
|
66
94
|
- - "~>"
|
67
95
|
- !ruby/object:Gem::Version
|
68
96
|
version: 0.0.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: k_domain
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.0.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.0.0
|
69
111
|
- !ruby/object:Gem::Dependency
|
70
112
|
name: k_ext-github
|
71
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,6 +173,13 @@ executables:
|
|
131
173
|
extensions: []
|
132
174
|
extra_rdoc_files: []
|
133
175
|
files:
|
176
|
+
- ".builders/_.rb"
|
177
|
+
- ".builders/boot.rb"
|
178
|
+
- ".builders/generators/01-bootstrap.rb"
|
179
|
+
- ".builders/generators/02-draw-chart.rb"
|
180
|
+
- ".builders/graph/test.drawio"
|
181
|
+
- ".builders/graph/xmen.drawio"
|
182
|
+
- ".builders/graph/xmen.txt"
|
134
183
|
- ".github/workflows/main.yml"
|
135
184
|
- ".gitignore"
|
136
185
|
- ".rspec"
|
@@ -150,6 +199,7 @@ files:
|
|
150
199
|
- bin/khotfix
|
151
200
|
- bin/setup
|
152
201
|
- docs/flow.drawio
|
202
|
+
- docs/shapes
|
153
203
|
- exe/k_manager
|
154
204
|
- hooks/pre-commit
|
155
205
|
- hooks/update-version
|
@@ -162,7 +212,6 @@ files:
|
|
162
212
|
- lib/k_manager/cli/new.rb
|
163
213
|
- lib/k_manager/cli/version.rb
|
164
214
|
- lib/k_manager/cli/watch.rb
|
165
|
-
- lib/k_manager/configuration/project_config.rb
|
166
215
|
- lib/k_manager/document_factory.rb
|
167
216
|
- lib/k_manager/manager.rb
|
168
217
|
- lib/k_manager/overview/dashboard.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module KManager
|
4
|
-
module Configuration
|
5
|
-
# Project configuration class for KManager
|
6
|
-
#
|
7
|
-
# This configuration contains template and target folders as used
|
8
|
-
# by all k_builders, it also has additional configuration that makes
|
9
|
-
# sense for a project, such as the GitHub repository configuration
|
10
|
-
class ProjectConfig < KBuilder::Configuration
|
11
|
-
attach_to(KExt::Github::Configuration, self, :github)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|