k_manager 0.0.13 → 0.0.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/Gemfile +23 -0
  4. data/Rakefile +2 -0
  5. data/docs/flow.drawio +16 -0
  6. data/exe/k_manager +19 -0
  7. data/hooks/update-version +1 -1
  8. data/k_manager.gemspec +9 -0
  9. data/lib/k_manager/area.rb +49 -0
  10. data/lib/k_manager/cli/base_command.rb +23 -0
  11. data/lib/k_manager/cli/commands.rb +25 -0
  12. data/lib/k_manager/cli/info.rb +81 -0
  13. data/lib/k_manager/cli/new.rb +130 -0
  14. data/lib/k_manager/cli/version.rb +15 -0
  15. data/lib/k_manager/cli/watch.rb +65 -0
  16. data/lib/k_manager/document_factory.rb +81 -0
  17. data/lib/k_manager/manager.rb +158 -0
  18. data/lib/k_manager/overview/dashboard.rb +197 -0
  19. data/lib/k_manager/overview/dump_json.rb +35 -0
  20. data/lib/k_manager/overview/models.rb +76 -0
  21. data/lib/k_manager/overview/queries.rb +53 -0
  22. data/lib/k_manager/resources/base_resource.rb +203 -52
  23. data/lib/k_manager/resources/file_resource.rb +81 -58
  24. data/lib/k_manager/resources/{ruby_file_resource.rb → file_resources/ruby_file_resource.rb} +0 -0
  25. data/lib/k_manager/resources/{unknown_file_resource.rb → file_resources/unknown_file_resource.rb} +0 -0
  26. data/lib/k_manager/resources/mem_resource.rb +17 -0
  27. data/lib/k_manager/resources/resource_document_factory.rb +123 -0
  28. data/lib/k_manager/resources/resource_factory.rb +28 -0
  29. data/lib/k_manager/resources/resource_manager.rb +201 -0
  30. data/lib/k_manager/resources/resource_set.rb +90 -0
  31. data/lib/k_manager/resources/web_resource.rb +113 -0
  32. data/lib/k_manager/version.rb +1 -1
  33. data/lib/k_manager/watcher.rb +113 -0
  34. data/lib/k_manager/{x_project.rb → x_resource_documents/x_project.rb} +0 -0
  35. data/lib/k_manager/{x_project_manager.rb → x_resource_documents/x_project_manager.rb} +0 -0
  36. data/lib/k_manager/{x_register.rb → x_resource_documents/x_register.rb} +0 -0
  37. data/lib/k_manager.rb +111 -24
  38. data/tasks/watch.rake +18 -0
  39. metadata +118 -25
  40. data/Assessment1.md +0 -127
  41. data/Assessment2.md +0 -88
  42. data/lib/k_manager/configuration/project_config.rb +0 -14
  43. data/lib/k_manager/create_document.rb +0 -31
  44. data/lib/k_manager/documents/basic_document.rb +0 -21
  45. data/lib/k_manager/documents/builder_document.rb +0 -18
  46. data/lib/k_manager/documents/document_taggable.rb +0 -94
  47. data/lib/k_manager/documents/model_document.rb +0 -19
  48. data/lib/k_manager/project.rb +0 -50
  49. data/lib/k_manager/resources/csv_file_resource.rb +0 -27
  50. data/lib/k_manager/resources/factories/document_factory.rb +0 -52
  51. data/lib/k_manager/resources/json_file_resource.rb +0 -22
  52. data/lib/k_manager/resources/yaml_file_resource.rb +0 -21
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module KManager
4
- require 'handlebars/helpers/string_formatting/dasherize'
5
-
6
- # A project represents all the DSL and Data resources that are available, it keeps a track of
7
- # the in memory state of the resources, are they loaded into memory or not.
8
- class Project
9
- # Project name
10
- attr_reader :name
11
-
12
- # Project namespace, aka namespace root
13
- attr_reader :namespace
14
-
15
- # Configuration for this project
16
- attr_reader :config
17
-
18
- # List of resources attached to this project
19
- attr_reader :resources
20
-
21
- def initialize(name, config = nil, **opts)
22
- raise KType::Error, 'Provide a project name' unless name.is_a?(String) || name.is_a?(Symbol)
23
-
24
- @name = name
25
- @config = config || KManager::Configuration::ProjectConfig.new
26
- @resources = []
27
-
28
- initialize_opts(opts)
29
- end
30
-
31
- def add_resource(resource)
32
- # Need to check if this and resource.attach_project need to delegate to each other
33
- # Need to check that resources can't be added twice
34
- # Tests are required
35
- @resources << resource
36
- end
37
-
38
- # Infer key is the project name stored in dash-case
39
- def infer_key
40
- Handlebars::Helpers::StringFormatting::Dasherize.new.parse(name.to_s.gsub('_', '-'))
41
- end
42
-
43
- private
44
-
45
- def initialize_opts(opts)
46
- # project name is often a good default for the namespace
47
- @namespace = opts[:namespace] || name
48
- end
49
- end
50
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'csv'
4
-
5
- module KManager
6
- module Resources
7
- # Represents a CSV file resource.
8
- class CsvFileResource < KManager::Resources::FileResource
9
- def initialize(**opts)
10
- super(**opts)
11
- @type = :csv
12
- end
13
-
14
- def load_document
15
- data = []
16
- CSV.parse(content, headers: true, header_converters: :symbol).each do |row|
17
- data << row.to_h
18
- end
19
- document.data = data
20
- end
21
-
22
- # def debug
23
- # tp self.document.data, self.document.data.first.to_h.keys
24
- # end
25
- end
26
- end
27
- end
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
- # # frozen_string_literal: true
3
- # require 'csv'
4
-
5
- # module KDsl
6
- # module Resources
7
- # module Factories
8
- # # Base factory for creationg resource_documents
9
- # # Tightly coupled to the resource using polymorphic composition
10
- # # Something WRONG, should this be a module include instead of a Forwardable Class?
11
- # class DocumentFactory
12
- # extend Forwardable
13
-
14
- # attr_reader :resource
15
-
16
- # def_delegator :resource, :project
17
- # def_delegator :resource, :content
18
- # def_delegator :resource, :documents
19
- # def_delegator :resource, :new_document
20
- # def_delegator :resource, :add_document
21
- # def_delegator :resource, :infer_document_key
22
- # def_delegator :resource, :infer_document_type
23
- # def_delegator :resource, :infer_document_namespace
24
-
25
- # def initialize(resource, resource_type)
26
- # @resource = resource
27
- # resource.resource_type = resource_type
28
- # end
29
-
30
- # def self.instance(resource, source, file)
31
- # if source === KDsl::Resources::Resource::SOURCE_FILE
32
- # extension = File.extname(file).downcase
33
-
34
- # case extension
35
- # when '.rb'
36
- # return KDsl::Resources::Factories::RubyDocumentFactory.new(resource)
37
- # when '.csv'
38
- # return KDsl::Resources::Factories::CsvDocumentFactory.new(resource)
39
- # when '.json'
40
- # return KDsl::Resources::Factories::JsonDocumentFactory.new(resource)
41
- # when '.yaml'
42
- # return KDsl::Resources::Factories::YamlDocumentFactory.new(resource)
43
- # end
44
- # end
45
-
46
- # return KDsl::Resources::Factories::UnknownDocumentFactory.new(resource)
47
- # end
48
-
49
- # end
50
- # end
51
- # end
52
- # end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module KManager
4
- module Resources
5
- # Represents a JSON file resource.
6
- class JsonFileResource < KManager::Resources::FileResource
7
- def initialize(**opts)
8
- super(**opts)
9
- @type = :json
10
- end
11
-
12
- def load_document
13
- data = JSON.parse(content)
14
- document.data = data
15
- end
16
-
17
- # def debug
18
- # L.ostruct(KDsl::Util.data.to_struct(self.document.data))
19
- # end
20
- end
21
- end
22
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module KManager
4
- module Resources
5
- # Represents a YAML file resource.
6
- class YamlFileResource < KManager::Resources::FileResource
7
- def initialize(**opts)
8
- super(**opts)
9
- @type = :yaml
10
- end
11
-
12
- def load_document
13
- data = YAML.safe_load(content)
14
- document.data = data
15
- end
16
- # def debug
17
- # L.ostruct(KDsl::Util.data.to_struct(self.document.data))
18
- # end
19
- end
20
- end
21
- end