llmed 0.2.9 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e56269a5d76f8d9b16ed8df3781111195eb0ca47f591c594440335a45e8f50f9
4
- data.tar.gz: a094082f5e577cc92b3331ae108795b6c55604375ec9ef393991e32c6efc182d
3
+ metadata.gz: 8f0373ddc4cb49e5ddeffd7a31cc5e100f6130447f4789d58c2440e94f48605e
4
+ data.tar.gz: 2fe8f237cd784cd24a86408090b495e7eae0c1308e94188a79b33a9be01e3403
5
5
  SHA512:
6
- metadata.gz: bbc2eb0c14a528db3782e31069c0163a47483c1e443d802e3c915a4db1544a43d658b00d2a60b0df3b96c806161c3a05dfe942daef06a0146841790347a1dc30
7
- data.tar.gz: 38e432d45c95e24d221d7bd4486522eee8f336e57a0d3825a776540f78f930aa5ca4db6a0c9c3cb1ece3d93b9901664431ae9cbd13ffdc25afc4792951ddfb71
6
+ metadata.gz: 4d5204f34243a5e25ee09e8f2b54bbb0cd3b7ff683e3d720d4f8a8c16b921d99de694337156bd9ff0c3d2790802eb55efda2bd3adb5230e9b2c88cabf0dae389
7
+ data.tar.gz: 5398a611b114dd185b5b16b18b7022231e9cb36a41c624832b18c8cc8d7c5aaea012137cff2678f8e043004fbba0b9265b7c5a933d29dcaaf73b483a0abfd92e
@@ -83,10 +83,18 @@ class LLMed
83
83
  end
84
84
  end
85
85
 
86
- @logger.info("APPLICATION #{@name} PATCHING CONTEXT #{name} \n\tFROM #{digest}\n\tTO DIGEST #{new_digest}")
87
86
  release_source_code_content = release_source_code_content.sub(%r{(.*?)(<llmed-code context='#{name}' digest='.*?'>)(.+?)(</llmed-code>)(.*?)}m) do
88
87
  "#{::Regexp.last_match(1)}<llmed-code context='#{name}' digest='#{new_digest}'>#{new_code}#{::Regexp.last_match(4)}#{::Regexp.last_match(5)}"
89
88
  end
89
+
90
+ if release_contexts[name].nil?
91
+ @logger.info("APPLICATION #{@name} ADDING NEW CONTEXT #{name}")
92
+ release_source_code_content += "<llmed-code context='#{name}' digest='#{new_digest}'>
93
+ #{new_code}
94
+ #{code_comment}</llmed-code>"
95
+ else
96
+ @logger.info("APPLICATION #{@name} PATCHING CONTEXT #{name} \n\tFROM #{digest}\n\tTO DIGEST #{new_digest}")
97
+ end
90
98
  end
91
99
 
92
100
  output_content = release_source_code_content
@@ -110,7 +118,11 @@ class LLMed
110
118
  !digests_of_context_to_update.tap do |digests|
111
119
  digests.each do |digest|
112
120
  context_by_digest = release_contexts.invert
113
- @logger.info("APPLICATION #{@name} REBUILDING CONTEXT #{context_by_digest[digest]}")
121
+ if context_by_digest[digest].nil?
122
+ @logger.info("APPLICATION #{@name} ADDING CONTEXT #{user_contexts.invert[digest]}")
123
+ else
124
+ @logger.info("APPLICATION #{@name} REBUILDING CONTEXT #{context_by_digest[digest]}")
125
+ end
114
126
  end
115
127
  end.empty?
116
128
  end
@@ -141,6 +153,10 @@ class LLMed
141
153
 
142
154
  private
143
155
 
156
+ def code_comment
157
+ { ruby: '#' }.fetch(@language.to_sym)
158
+ end
159
+
144
160
  def digests_of_context_to_update
145
161
  update_context_digest = []
146
162
 
@@ -152,8 +168,15 @@ class LLMed
152
168
  update_rest = false
153
169
  @contexts.each do |ctx|
154
170
  release_context_digest = release_contexts[ctx.name]
155
- # maybe the context is not connected to the source code
156
- next if release_context_digest.nil?
171
+
172
+ # added new context
173
+ if release_context_digest.nil? and !user_contexts[ctx.name].nil?
174
+ update_context_digest << user_contexts[ctx.name]
175
+ next
176
+ elsif release_context_digest.nil?
177
+ # maybe the context is not connected to the source code
178
+ next
179
+ end
157
180
 
158
181
  if update_rest
159
182
  update_context_digest << release_context_digest
@@ -177,6 +200,12 @@ class LLMed
177
200
  Pathname.new(@release_dir) + "#{@output_file}.release"
178
201
  end
179
202
 
203
+ def user_contexts
204
+ @contexts.map do |ctx|
205
+ [ctx.name, ctx.digest]
206
+ end.to_h
207
+ end
208
+
180
209
  def release_contexts
181
210
  return {} unless @release
182
211
 
@@ -14,7 +14,7 @@ Always include the properly escaped comment: LLMED-COMPILED.
14
14
  You must only modify the following source code:
15
15
  {source_code}
16
16
 
17
- Only generate source code of the context who digest belongs to {update_context_digests}.
17
+ Only generate source code of the context who digest belongs to {update_context_digests} or a is a new context.
18
18
 
19
19
  Wrap with comment every code that belongs to the indicated context, example in ruby:
20
20
  #<llmed-code context='context name' digest='....'>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llmed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jovany Leandro G.C