k_builder 0.0.23 → 0.0.25

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: 1e1de8ff91bc3e273459d6970c8c1c136184e9c0990b0645fa426888317640eb
4
- data.tar.gz: b6a5856f4bbb628422968a80a212fc6fbb1515b19c2cc29160d9cf984faa2b40
3
+ metadata.gz: abc9118f3f615884f1f0176c77ecfffa90bdf5d198c2c4d554df2a4c524b2ea6
4
+ data.tar.gz: c40ea449aaad67a03c946b9fbe5e9e132917e7632138b9321c74b925c10f8560
5
5
  SHA512:
6
- metadata.gz: 62e85ea3f17a20cbc3bd180b74a057caab722d37de1bdb008353839f5f0159f564b69a4bcee9124857c7d24fe5b7b46afe967b86e52aaac7009960a663294886
7
- data.tar.gz: 51a3c0374b57f0cfebc099df6d86c7657b50815185ea60f71e37cc9f27c5edf4afbb1933e727c1e68b81b179b079f7666c89a9273e971d7aa72fdb74e0411942
6
+ metadata.gz: 0e1b1ff0f3c742e69305d1dbd3b6ec1a34a70c0b9bf0a4a2f9ab0e25451dfba4a873281b65fd13af217c9785a4e795cfc7eb766da395d8f14bcf1012ddb51a37
7
+ data.tar.gz: e7fd23e135807ebf5f491765ba854fb0fe8ac0fcec1e5f3963e974ae6c1d40d8344dc46685c270b2141279ab3dcf8a7ad4cc906a34a965f8106e22845711eff9
data/USAGE.md CHANGED
@@ -36,7 +36,7 @@ Example folder structure for this usecase before running the builder
36
36
 
37
37
  > Note: app-templates will take preference over global templates
38
38
 
39
- ![](_usage_folder_before.png)
39
+ ![](usage/_usage_folder_before.png)
40
40
 
41
41
  #### Run builder
42
42
 
@@ -81,24 +81,24 @@ builder
81
81
 
82
82
  Folder structure after running the builder
83
83
 
84
- ![](_usage_folder_after.png)
84
+ ![](usage/_usage_folder_after.png)
85
85
 
86
86
  #### main.rb
87
87
 
88
- ![main.rb](_out1.png)
88
+ ![main.rb](usage/_out1.png)
89
89
 
90
90
  #### person.rb
91
91
 
92
- ![](_out2.png)
92
+ ![](usage/_out2.png)
93
93
 
94
94
  #### address.rb
95
95
 
96
- ![person.rb](_out3.png)
96
+ ![person.rb](usage/_out3.png)
97
97
 
98
98
  #### configuration.log.txt
99
99
 
100
- ![configuration.log.txt](_out4.png)
100
+ ![configuration.log.txt](usage/_out4.png)
101
101
 
102
102
  #### css/index.css
103
103
 
104
- ![css/index.css](_out5.png)
104
+ ![css/index.css](usage/_out5.png)
@@ -3,104 +3,33 @@
3
3
  module KBuilder
4
4
  # Base configuration object for all k_builder* GEM
5
5
  class BaseConfiguration
6
- def to_hash
7
- hash = {}
8
- instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
9
- hash
10
- end
11
-
12
- def kv(name, value)
13
- puts "#{name.rjust(30)} : #{value}"
14
- end
15
-
16
- # All of this code should be extracted into a module
17
- #
18
- # The module should then be extracted out into a GEM so that
19
- # I can include it as needed. The GEM might be called
20
- # (dynamic attributes) and would allow a regular class to act like an OpenStruct
21
- # K-DSL uses data hash, while base configuration uses instance variables
22
-
23
- def respond_to_missing?(name, *_args, &_block)
24
- # puts 'respond_to_missing?'
25
- # puts "respond_to_missing: #{name}"
26
- n = name.to_s
27
- n = n[0..-2] if n.end_with?('=')
28
-
29
- if n.end_with?('?')
30
- super
31
- else
32
- # This has not been fully tested
33
- instance_variable_defined?("@#{n}") || super
6
+ def self.attach_to(klass_me, klass_target, accessor_name)
7
+ # Create a memoized getter to an instance of the attaching class (:klass_me)
8
+ #
9
+ # def third_party
10
+ # @third_party ||= KBuilder::ThirdPartyGem::Configuration.new
11
+ # end
12
+ klass_target.send(:define_method, accessor_name) do
13
+ return instance_variable_get("@#{accessor_name}") if instance_variable_defined?("@#{accessor_name}")
14
+
15
+ instance_variable_set("@#{accessor_name}", klass_me.new)
34
16
  end
35
17
  end
36
18
 
37
- def method_missing(name, *args, &_block)
38
- # puts "method_missing: #{name}"
39
- # puts "args.length : #{args.length}"
40
-
41
- add_getter_or_param_method(name)
42
- add_setter_method(name)
43
-
44
- send(name, args[0]) if args.length == 1 # name.end_with?('=')
45
-
46
- super unless self.class.method_defined?(name)
47
- end
48
-
49
- # Handles Getter method and method with single parameter
50
- # object.my_name
51
- # object.my_name('david')
52
- def add_getter_or_param_method(name)
53
- # L.progress(1, 'add_getter_or_param_method')
54
- self.class.class_eval do
55
- # L.progress(2, 'add_getter_or_param_method')
56
- name = name.to_s.gsub(/=$/, '')
57
- # L.progress(3, 'add_getter_or_param_method')
58
- # L.kv 'name', name
59
- define_method(name) do |*args|
60
- # L.progress(4, 'add_getter_or_param_method')
61
- # L.kv 'add_getter_or_param_method', name
62
- raise KBuilder::Error, 'Multiple setting values is not supported' if args.length > 1
19
+ def to_hash
20
+ hash = {}
21
+ instance_variables.each do |var|
22
+ value = instance_variable_get(var)
63
23
 
64
- if args.length.zero?
65
- get_value(name)
66
- else
67
- send("#{name}=", args[0])
68
- end
69
- end
70
- end
71
- end
24
+ value = value.to_hash if value.is_a?(KBuilder::BaseConfiguration)
72
25
 
73
- # Handles Setter method
74
- # object.my_name = 'david'
75
- def add_setter_method(name)
76
- # L.progress(1, 'add_setter_method')
77
- self.class.class_eval do
78
- # L.progress(2, 'add_setter_method')
79
- name = name.to_s.gsub(/=$/, '')
80
- # L.progress(3, 'add_setter_method')
81
- # L.kv 'add_setter_method', name
82
- define_method("#{name}=") do |value|
83
- # L.progress(4, 'add_setter_method')
84
- # L.kv 'name', name
85
- # L.kv 'value', value
86
- instance_variable_set("@#{name}", value)
87
- # my_data[name.to_s] = value
88
- end
26
+ hash[var.to_s.delete('@')] = value
89
27
  end
28
+ hash
90
29
  end
91
30
 
92
- def get_value(name)
93
- instance_variable_get("@#{name}")
31
+ def kv(name, value)
32
+ puts "#{name.rjust(30)} : #{value}"
94
33
  end
95
34
  end
96
-
97
- # class L
98
- # def self.progress(index, label)
99
- # puts "#{index} - #{label}"
100
- # end
101
-
102
- # def self.kv(name, value)
103
- # puts "#{name.rjust(30)} : #{value}"
104
- # end
105
- # end
106
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KBuilder
4
- VERSION = '0.0.23'
4
+ VERSION = '0.0.25'
5
5
  end
File without changes
File without changes
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
@@ -44,13 +44,6 @@ files:
44
44
  - Rakefile
45
45
  - STORIES.md
46
46
  - USAGE.md
47
- - _out1.png
48
- - _out2.png
49
- - _out3.png
50
- - _out4.png
51
- - _out5.png
52
- - _usage_folder_after.png
53
- - _usage_folder_before.png
54
47
  - bin/console
55
48
  - bin/k
56
49
  - bin/kgitsync
@@ -65,6 +58,13 @@ files:
65
58
  - lib/k_builder/builder.rb
66
59
  - lib/k_builder/configuration.rb
67
60
  - lib/k_builder/version.rb
61
+ - usage/_out1.png
62
+ - usage/_out2.png
63
+ - usage/_out3.png
64
+ - usage/_out4.png
65
+ - usage/_out5.png
66
+ - usage/_usage_folder_after.png
67
+ - usage/_usage_folder_before.png
68
68
  homepage: http://appydave.com
69
69
  licenses:
70
70
  - MIT