baltix 0.1.1

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 +7 -0
  2. data/.github/workflows/ci.yml +44 -0
  3. data/.gitignore +10 -0
  4. data/Gemfile +8 -0
  5. data/LICENSE +8 -0
  6. data/README.md +60 -0
  7. data/Rakefile +8 -0
  8. data/TODO +84 -0
  9. data/baltix.gemspec +39 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/exe/baltix +4 -0
  13. data/lib/baltix/actor/copy.rb +19 -0
  14. data/lib/baltix/actor/link.rb +20 -0
  15. data/lib/baltix/actor/spec.rb +25 -0
  16. data/lib/baltix/actor/touch.rb +17 -0
  17. data/lib/baltix/actor.rb +75 -0
  18. data/lib/baltix/cli.rb +173 -0
  19. data/lib/baltix/deps.rb +280 -0
  20. data/lib/baltix/dsl.rb +311 -0
  21. data/lib/baltix/extensions.rb +536 -0
  22. data/lib/baltix/i18n.rb +64 -0
  23. data/lib/baltix/loader/cmake.rb +11 -0
  24. data/lib/baltix/loader/git-version-gen.rb +36 -0
  25. data/lib/baltix/loader/mast.rb +139 -0
  26. data/lib/baltix/loader/pom.rb +27 -0
  27. data/lib/baltix/loader/rookbook.rb +26 -0
  28. data/lib/baltix/loader/yaml.rb +18 -0
  29. data/lib/baltix/loader.rb +192 -0
  30. data/lib/baltix/log.rb +73 -0
  31. data/lib/baltix/rake.rb +57 -0
  32. data/lib/baltix/scheme.erb.yaml +20 -0
  33. data/lib/baltix/source/base.rb +438 -0
  34. data/lib/baltix/source/fake.rb +17 -0
  35. data/lib/baltix/source/gem.rb +407 -0
  36. data/lib/baltix/source/gemfile.rb +35 -0
  37. data/lib/baltix/source/rakefile.rb +24 -0
  38. data/lib/baltix/source.rb +57 -0
  39. data/lib/baltix/space/spec.rb +11 -0
  40. data/lib/baltix/space.rb +424 -0
  41. data/lib/baltix/spec/rpm/name.rb +155 -0
  42. data/lib/baltix/spec/rpm/parser.rb +412 -0
  43. data/lib/baltix/spec/rpm/secondary.rb +170 -0
  44. data/lib/baltix/spec/rpm/spec_core.rb +580 -0
  45. data/lib/baltix/spec/rpm.erb +188 -0
  46. data/lib/baltix/spec/rpm.rb +822 -0
  47. data/lib/baltix/spec.rb +48 -0
  48. data/lib/baltix/version.rb +3 -0
  49. data/lib/baltix.rb +19 -0
  50. data/locale/en_US.UTF-8.yaml +27 -0
  51. data/locale/ru_RU.UTF-8.yaml +23 -0
  52. metadata +216 -0
@@ -0,0 +1,536 @@
1
+ module Extensions
2
+ module Object
3
+ def self.const_get c, inherit = true
4
+ super
5
+ rescue Exception => e
6
+ begin
7
+ require c.to_s.downcase
8
+ rescue Exception => e
9
+ end
10
+
11
+ super
12
+ end
13
+
14
+ def blank?
15
+ case self
16
+ when ::NilClass, ::FalseClass
17
+ true
18
+ when ::TrueClass
19
+ false
20
+ when ::Hash, ::Array
21
+ !self.any?
22
+ else
23
+ self.to_s == ""
24
+ end
25
+ end
26
+
27
+ def to_os hash: false, array: false
28
+ value =
29
+ self.to_h.map do |(x, y_in)|
30
+ y =
31
+ if hash && y_in.is_a?(Hash) || array && y_in.is_a?(Array)
32
+ y_in.to_os(hash: hash, array: array)
33
+ else
34
+ y_in
35
+ end
36
+
37
+ [x.to_s, y]
38
+ end.to_h
39
+
40
+ ::OpenStruct.new(value)
41
+ end
42
+ end
43
+
44
+ module Array
45
+ # actjoin(array) => [<pre_match1>, <pre_match2>, <pre_match3>, <post_match>]; array = [match1, match2, match3]
46
+ #
47
+ def actjoin array
48
+ self.map.with_index { |x, i| [ x, array[i] ].compact }.flatten.join
49
+ end
50
+ end
51
+
52
+ module Hash
53
+ # def deep_merge other, options_in = {}
54
+ # return self if other.nil? or other.blank?
55
+ #
56
+ # options = { mode: :append }.merge(options_in)
57
+ #
58
+ # other_hash = other.is_a?(Hash) && other || { nil => other }
59
+ # common_keys = self.keys & other_hash.keys
60
+ # base_hash = (other_hash.keys - common_keys).reduce({}) do |res, key|
61
+ # res[key] = other_hash[key]
62
+ # res
63
+ # end
64
+ #
65
+ # self.reduce(base_hash) do |res, (key, value)|
66
+ # new =
67
+ # if common_keys.include?(key)
68
+ # case value
69
+ # when ::Hash, ::OpenStruct
70
+ # value.deep_merge(other_hash[key])
71
+ # when ::Array
72
+ # value.concat([ other_hash[key] ].compact.flatten(1))
73
+ # when ::NilClass
74
+ # other_hash[key]
75
+ # else
76
+ # value_out =
77
+ # if options[:mode] == :append
78
+ # [other_hash[key], value].compact.flatten(1)
79
+ # elsif options[:mode] == :prepend
80
+ # [value, other_hash[key]].compact.flatten(1)
81
+ # else
82
+ # value
83
+ # end
84
+ #
85
+ # if value_out.is_a?(Array) && options[:dedup]
86
+ # value_out.uniq
87
+ # else
88
+ # value_out
89
+ # end
90
+ # end
91
+ # else
92
+ # value
93
+ # end
94
+ #
95
+ # res[key] = new
96
+ # res
97
+ # end
98
+ # end
99
+ end
100
+
101
+ module OpenStruct
102
+ def to_os
103
+ self
104
+ end
105
+
106
+ def merge_to other
107
+ ::OpenStruct.new(other.to_h.deep_merge(self.to_h))
108
+ end
109
+
110
+ def merge other
111
+ ::OpenStruct.new(self.to_h.deep_merge(other.to_h))
112
+ end
113
+
114
+ def map *args, &block
115
+ res = self.class.new
116
+
117
+ self.each_pair do |key, value|
118
+ res[key] = block[key, value]
119
+ end
120
+
121
+ res
122
+ end
123
+
124
+ def select &block
125
+ res = self.class.new
126
+
127
+ self.each_pair do |key, value|
128
+ res[key] = value if block[key, value]
129
+ end
130
+
131
+ res
132
+ end
133
+
134
+ def compact
135
+ select { |_, value| !value.blank? }
136
+ end
137
+
138
+ def each *args, &block
139
+ self.each_pair(*args, &block)
140
+ end
141
+
142
+ def reduce default = nil, &block
143
+ res = default
144
+
145
+ self.each_pair do |key, value|
146
+ res = block[res, key, value]
147
+ end
148
+
149
+ res
150
+ end
151
+
152
+ def find &block
153
+ select(&block).first
154
+ end
155
+
156
+ def replace new_os
157
+ self.to_h.keys.each {|x| self[x] = nil }
158
+
159
+ new_os.to_os.each {|x, v| self[x] = v }
160
+
161
+ self
162
+ end
163
+
164
+ def deep_dup
165
+ self.reduce({}.to_os) do |r, x, y|
166
+ r[x] = y.respond_to?(:deep_dup) ? y.deep_dup : y.dup
167
+
168
+ r
169
+ end
170
+ end
171
+
172
+ # +deep_merge+ deeply merges the Open Struct hash structure with the +other_in+ enumerating it key by key.
173
+ # +options+ are the options to change behaviour of the method. It allows two keys: :mode, and :dedup
174
+ # :mode key can be :append, :prepend, or :replace, defaulting to :append, when mode is to append, it combines duplicated
175
+ # keys' values into an array, when :prepend it prepends an other value before previously stored one unlike for :append mode,
176
+ # when :replace it replace duplicate values with a last ones.
177
+ # :dedup key can be true, or false. It allows to deduplicate values when appending or prepending values.
178
+ # Examples:
179
+ # open_struct.deep_merge(other_open_struct)
180
+ # open_struct.deep_merge(other_open_struct, :prepend)
181
+ #
182
+ def deep_merge other_in, options_in = {}
183
+ return self if other_in.nil? or other_in.blank?
184
+
185
+ options = { mode: :append }.merge(options_in)
186
+
187
+ other =
188
+ if other_in.is_a?(::OpenStruct)
189
+ other_in.deep_dup
190
+ elsif other_in.is_a?(::Hash)
191
+ other_in.to_os
192
+ else
193
+ ::OpenStruct.new(nil => other_in)
194
+ end
195
+
196
+ other.reduce(self.to_os) do |res, key, value|
197
+ res[key] =
198
+ if res.table.keys.include?(key)
199
+ case value
200
+ when ::Hash
201
+ value.deep_merge(res[key].to_h, options)
202
+ when ::OpenStruct
203
+ value.deep_merge(res[key].to_os, options)
204
+ when ::Array
205
+ value.concat([res[key]].compact.flatten(1))
206
+ when ::NilClass
207
+ res[key]
208
+ else
209
+ value_out =
210
+ if options[:mode] == :append
211
+ [value, res[key]].compact.flatten(1)
212
+ elsif options[:mode] == :prepend
213
+ [res[key], value].compact.flatten(1)
214
+ else
215
+ value
216
+ end
217
+
218
+ if value_out.is_a?(Array) && options[:dedup]
219
+ value_out.uniq
220
+ else
221
+ value_out
222
+ end
223
+ end
224
+ else
225
+ value
226
+ end
227
+
228
+ res
229
+ end
230
+ end
231
+ end
232
+
233
+ module GemRequirement
234
+ INVALID_DEP = ["<", Gem::Version.new(0)] #:nodoc:
235
+
236
+ AND_RELAS = { #:nodoc:
237
+ [ "=", ">=", 0 ] => ->(l, r) { [["=", l]] },
238
+ [ "=", ">=", 1 ] => ->(l, r) { [["=", l]] },
239
+ [ "=", "<=", -1 ] => ->(l, r) { [["=", l]] },
240
+ [ "=", "<=", 0 ] => ->(l, r) { [["=", l]] },
241
+ [ "=", ">", 1 ] => ->(l, r) { [["=", l]] },
242
+ [ "=", "<", -1 ] => ->(l, r) { [["=", l]] },
243
+ [ "=", "=", 0 ] => ->(l, r) { [["=", l]] },
244
+ [ "=", "~>", 0 ] => ->(l, r) { [["=", l]] },
245
+ [ "=", "~>", ->(l, r) { l > r && l < r.bump } ] => ->(l, r) { [["=", l]] },
246
+ [ "!=", "=", -1 ] => ->(l, r) { [["=", r]] },
247
+ [ "!=", "=", 1 ] => ->(l, r) { [["=", r]] },
248
+ [ "!=", "!=", -1 ] => ->(l, r) { [["!=", l]] },
249
+ [ "!=", "!=", 0 ] => ->(l, r) { [["!=", l]] },
250
+ [ "!=", "!=", 1 ] => ->(l, r) { [["!=", l]] },
251
+ [ "!=", ">", -1 ] => ->(l, r) { [[">", r]] },
252
+ [ "!=", ">", 0 ] => ->(l, r) { [[">", r]] },
253
+ [ "!=", ">", 1 ] => ->(l, r) { [[">", r], ["<", l]] },
254
+ [ "!=", "<", -1 ] => ->(l, r) { [[">", l], ["<", r]] },
255
+ [ "!=", "<", 0 ] => ->(l, r) { [["<", r]] },
256
+ [ "!=", "<", 1 ] => ->(l, r) { [["<", r]] },
257
+ [ "!=", ">=", -1 ] => ->(l, r) { [[">=", r]] },
258
+ [ "!=", ">=", 0 ] => ->(l, r) { [[">", r]] },
259
+ [ "!=", ">=", 1 ] => ->(l, r) { [[">=", r], ["<", l]] },
260
+ [ "!=", "<=", -1 ] => ->(l, r) { [[">", l], ["<=", r]] },
261
+ [ "!=", "<=", 0 ] => ->(l, r) { [["<", r]] },
262
+ [ "!=", "<=", 1 ] => ->(̀r, l) { [["<=", r]] },
263
+ [ "!=", "~>", -1 ] => ->(l, r) { [[">=", r], ["<", r.bump]] },
264
+ [ "!=", "~>", 0 ] => ->(l, r) { [[">", r], ["<", r.bump]] },
265
+ [ "!=", "~>", ->(l, r) { l > r && l < r.bump } ] => ->(l, r) { [[">", l], ["<", r.bump]] },
266
+ [ "!=", "~>", ->(l, r) { l >= r.bump } ] => ->(l, r) { [[">=", l]] },
267
+ [ ">", "=", -1 ] => ->(l, r) { [["=", r]] },
268
+ [ ">", "!=", -1 ] => ->(l, r) { [[">", l], ["<", r]] },
269
+ [ ">", "!=", 0 ] => ->(l, r) { [[">", l]] },
270
+ [ ">", "!=", 1 ] => ->(l, r) { [[">", l]] },
271
+ [ ">", ">", -1 ] => ->(l, r) { [[">", [r, l].max]] },
272
+ [ ">", ">=", -1 ] => ->(l, r) { [[">=", l]] },
273
+ [ ">", ">=", 0 ] => ->(l, r) { [[">", l]] },
274
+ [ ">", ">=", 1 ] => ->(l, r) { [[">", l]] },
275
+ [ ">", "<=", -1 ] => ->(l, r) { [[">", l], ["<=", r]] },
276
+ [ ">", "~>", -1 ] => ->(l, r) { [[">=", l], ["<", r.bump]] },
277
+ [ ">", "~>", 0 ] => ->(l, r) { [[">", l], ["<", r.bump]] },
278
+ [ ">", "~>", ->(l, r) { l > r && l < r.bump } ] => ->(l, r) { [[">", l], ["<", r.bump]] },
279
+ [ ">", "~>", ->(l, r) { l >= r.bump } ] => ->(l, r) { [[">", l]] },
280
+ [ "<", "=", 1 ] => ->(l, r) { [["=", r]] },
281
+ [ "<", "!=", -1 ] => ->(l, r) { [["<", l]] },
282
+ [ "<", "!=", 0 ] => ->(l, r) { [["<", l]] },
283
+ [ "<", "!=", 1 ] => ->(l, r) { [[">=", r], ["<", l]] },
284
+ [ "<", ">", 1 ] => ->(l, r) { [[">", r], ["<", l]] },
285
+ [ "<", "<", nil ] => ->(l, r) { [["<", [r, l].min]] },
286
+ [ "<", ">=", 1 ] => ->(l, r) { [[">=", r], ["<", l]] },
287
+ [ "<", "~>", 1 ] => ->(l, r) { [[">=", r], ["<", [l, r.bump].min]] },
288
+ [ ">=", "=", -1 ] => ->(l, r) { [["=", r]] },
289
+ [ ">=", "=", 0 ] => ->(l, r) { [["=", r]] },
290
+ [ ">=", "!=", -1 ] => ->(l, r) { [[">=", l], ["<", r]] },
291
+ [ ">=", "!=", 0 ] => ->(l, r) { [[">", l]] },
292
+ [ ">=", "!=", 1 ] => ->(l, r) { [[">=", l]] },
293
+ [ ">=", ">", -1 ] => ->(l, r) { [[">", r]] },
294
+ [ ">=", ">", 0 ] => ->(l, r) { [[">", r]] },
295
+ [ ">=", ">", 1 ] => ->(l, r) { [[">=", l]] },
296
+ [ ">=", "<", -1 ] => ->(l, r) { [[">=", l], ["<", r]] },
297
+ [ ">=", ">=", nil ] => ->(l, r) { [[">=", [r, l].max]] },
298
+ [ ">=", "<=", -1 ] => ->(l, r) { [[">=", l], ["<=", r]] },
299
+ [ ">=", "<=", 0 ] => ->(l, r) { [["=", l]] },
300
+ [ ">=", "~>", ->(l, r) { l < r.bump } ] => ->(l, r) { [[">=", [r, l].max], ["<", r.bump]] },
301
+ [ "<=", "=", 0 ] => ->(l, r) { [["=", r]] },
302
+ [ "<=", "=", 1 ] => ->(l, r) { [["=", r]] },
303
+ [ "<=", "!=", -1 ] => ->(l, r) { [["<=", l]] },
304
+ [ "<=", "!=", 0 ] => ->(l, r) { [["<=", l]] },
305
+ [ "<=", "!=", 1 ] => ->(l, r) { [[">", r], ["<=", l]] },
306
+ [ "<=", ">", 1 ] => ->(l, r) { [[">", r], ["<=", l]] },
307
+ [ "<=", "<", -1 ] => ->(l, r) { [["<=", l]] },
308
+ [ "<=", "<", 0 ] => ->(l, r) { [["<", l]] },
309
+ [ "<=", "<", 1 ] => ->(l, r) { [["<", r]] },
310
+ [ "<=", ">=", 0 ] => ->(l, r) { [["=", l]] },
311
+ [ "<=", ">=", 1 ] => ->(l, r) { [[">=", r], ["<=", l]] },
312
+ [ "<=", "~>", ->(l, r) { r.bump > l } ] => ->(l, r) { [[">=", r], ["<", r.bump]] },
313
+ [ "<=", "~>", ->(l, r) { r >= l && r.bump <= l } ] => ->(l, r) { [[">=", r], ["<=", l]] },
314
+ [ "~>", "=", 0 ] => ->(l, r) { [["=", r]] },
315
+ [ "~>", "=", ->(l, r) { l.bump > r } ] => ->(l, r) { [["=", r]] },
316
+ [ "~>", "!=", ->(l, r) { l.bump >= r } ] => ->(l, r) { [[">=", l], ["<", l.bump]] },
317
+ [ "~>", "!=", ->(l, r) { l > r && l.bump < r } ] => ->(l, r) { [[">=", l], ["<", r]] },
318
+ [ "~>", "!=", 0 ] => ->(l, r) { [[">", l], ["<", l.bump]] },
319
+ [ "~>", "!=", 1 ] => ->(l, r) { [[">=", l], ["<", l.bump]] },
320
+ [ "~>", ">", ->(l, r) { l < r && l.bump >= r } ] => ->(l, r) { [[">", r], ["<", l.bump]] },
321
+ [ "~>", ">", 0 ] => ->(l, r) { [[">", l], ["<", l.bump]] },
322
+ [ "~>", ">", 1 ] => ->(l, r) { [[">=", l], ["<", l.bump]]},
323
+ [ "~>", "<", nil ] => ->(l, r) { [[">=", l], ["<", [r, l.bump].max]] },
324
+ [ "~>", ">=", ->(l, r) { l < r && l.bump >= r } ] => ->(l, r) { [[">=", r], ["<", l.bump]] },
325
+ [ "~>", ">=", 0 ] => ->(l, r) { [[">=", l], ["<", l.bump]] },
326
+ [ "~>", ">=", 1 ] => ->(l, r) { [[">=", l], ["<", l.bump]] },
327
+ [ "~>", "<=", ->(l, r) { l < r && l.bump >= r } ] => ->(l, r) { [[">=", l], ["<=", r]] },
328
+ [ "~>", "<=", ->(l, r) { l.bump < r } ] => ->(l, r) { [[">=", l], ["<", l.bump]] },
329
+ [ "~>", "<=", 0 ] => ->(l, r) { [["=", l]] },
330
+ [ "~>", "~>", ->(l, r) { l.bump >= r && l < r.bump || r.bump >= l && r < l.bump } ] => ->(l, r) { [[">=", [r, l].max], ["<", [r.bump, l.bump].min]] }
331
+ }.freeze
332
+
333
+ OR_RELAS = { #:nodoc:
334
+ [ "=", ">=", nil ] => ->(l, r) { [[">=", [r, l].min]] },
335
+ [ "=", "<=", -1 ] => ->(l, r) { [["<=", r]] },
336
+ [ "=", "<=", 0 ] => ->(l, r) { [["<=", r]] },
337
+ [ "=", ">", 0 ] => ->(l, r) { [[">=", r]] },
338
+ [ "=", ">", 1 ] => ->(l, r) { [[">", r]] },
339
+ [ "=", "<", -1 ] => ->(l, r) { [["<", r]] },
340
+ [ "=", "<", 0 ] => ->(l, r) { [["<=", r]] },
341
+ [ "=", "=", 0 ] => ->(l, r) { [["=", l]] },
342
+ [ "=", "~>", nil ] => ->(l, r) { [[">=", [r, l].min], ["<", r.bump]] },
343
+ [ "!=", "=", -1 ] => ->(l, r) { [["=", r], ["!=", l]] },
344
+ [ "!=", "=", 0 ] => ->(l, r) { [] },
345
+ [ "!=", "=", 1 ] => ->(l, r) { [["=", r], ["!=", l]] },
346
+ [ "!=", "!=", 0 ] => ->(l, r) { [["!=", l]] },
347
+ [ "!=", ">", -1 ] => ->(l, r) { [[">", r]] },
348
+ [ "!=", ">", 0 ] => ->(l, r) { [[">", r]] },
349
+ [ "!=", ">", 1 ] => ->(l, r) { [[">", r], ["!=", l]] },
350
+ [ "!=", "<", -1 ] => ->(l, r) { [["<", r], ["!=", l]] },
351
+ [ "!=", "<", 0 ] => ->(l, r) { [["<", r]] },
352
+ [ "!=", "<", 1 ] => ->(l, r) { [["<", r]] },
353
+ [ "!=", ">=", -1 ] => ->(l, r) { [[">=", r]] },
354
+ [ "!=", ">=", 0 ] => ->(l, r) { [[">", r]] },
355
+ [ "!=", ">=", 1 ] => ->(l, r) { [[">=", r], ["!=", l]] },
356
+ [ "!=", "<=", -1 ] => ->(l, r) { [["<=", r], ["!=", l]] },
357
+ [ "!=", "<=", 0 ] => ->(l, r) { [["<", r]] },
358
+ [ "!=", "<=", 1 ] => ->(̀r, l) { [["<=", r]] },
359
+ [ "!=", "~>", -1 ] => ->(l, r) { [[">=", r], ["<", r.bump], ["!=", l]] },
360
+ [ "!=", "~>", 0 ] => ->(l, r) { [[">", r], ["<", r.bump]] },
361
+ [ "!=", "~>", 1 ] => ->(l, r) { [[">=", r], ["<", r.bump], ["!=", l]] },
362
+ [ ">", "=", 0 ] => ->(l, r) { [[">=", l]] },
363
+ [ ">", "=", 1 ] => ->(l, r) { [[">", l]] },
364
+ [ ">", "!=", 0 ] => ->(l, r) { [[">", l]] },
365
+ [ ">", "!=", 1 ] => ->(l, r) { [[">", l]] },
366
+ [ ">", ">", nil ] => ->(l, r) { [[">", [r, l].min]] },
367
+ [ ">", "<", 0 ] => ->(l, r) { [] },
368
+ [ ">", "<", 1 ] => ->(l, r) { [] },
369
+ [ ">", ">=", -1 ] => ->(l, r) { [[">", l]] },
370
+ [ ">", ">=", 0 ] => ->(l, r) { [[">=", r]] },
371
+ [ ">", ">=", 1 ] => ->(l, r) { [[">=", r]] },
372
+ [ ">", "<=", 0 ] => ->(l, r) { [] },
373
+ [ ">", "<=", 1 ] => ->(l, r) { [] },
374
+ [ ">", "~>", -1 ] => ->(l, r) { [[">", l], ["<", r.bump]] },
375
+ [ ">", "~>", 0 ] => ->(l, r) { [[">=", r], ["<", r.bump]] },
376
+ [ ">", "~>", 1 ] => ->(l, r) { [[">=", r], ["<", r.bump]] },
377
+ [ "<", "=", 0 ] => ->(l, r) { [["<=", l]] },
378
+ [ "<", "=", 1 ] => ->(l, r) { [["<", l]] },
379
+ [ "<", "!=", -1 ] => ->(l, r) { [["<", l]] },
380
+ [ "<", "!=", 0 ] => ->(l, r) { [["<", l]] },
381
+ [ "<", ">", -1 ] => ->(l, r) { [] },
382
+ [ "<", ">", 0 ] => ->(l, r) { [] },
383
+ [ "<", ">", 1 ] => ->(l, r) { [[">", r], ["<", l]] },
384
+ [ "<", "<", nil ] => ->(l, r) { [["<", [r, l].max]] },
385
+ [ "<", ">=", -1 ] => ->(l, r) { [] },
386
+ [ "<", ">=", 0 ] => ->(l, r) { [] },
387
+ [ "<", ">=", 1 ] => ->(l, r) { [[">=", r], ["<", l]] },
388
+ [ "<", "~>", nil ] => ->(l, r) { [[">=", r], ["<", [l, r.bump].max]] },
389
+ [ ">=", "=", 0 ] => ->(l, r) { [[">=", l]] },
390
+ [ ">=", "=", -1 ] => ->(l, r) { [[">=", l], ["=", r]] },
391
+ [ ">=", "!=", 0 ] => ->(l, r) { [[">", l]] },
392
+ [ ">=", "!=", 1 ] => ->(l, r) { [[">=", l]] },
393
+ [ ">=", ">", -1 ] => ->(l, r) { [[">=", l]] },
394
+ [ ">=", ">", 0 ] => ->(l, r) { [[">=", l]] },
395
+ [ ">=", ">", 1 ] => ->(l, r) { [[">", r]] },
396
+ [ ">=", "<", 0 ] => ->(l, r) { [] },
397
+ [ ">=", "<", 1 ] => ->(l, r) { [] },
398
+ [ ">=", ">=", nil ] => ->(l, r) { [[">=", [r, l].min]] },
399
+ [ ">=", "<=", 0 ] => ->(l, r) { [["=", l]] },
400
+ [ ">=", "<=", 1 ] => ->(l, r) { [] },
401
+ [ ">=", "~>", nil ] => ->(l, r) { [[">=", [r, l].min], ["<", r.bump]] },
402
+ [ "<=", "=", 0 ] => ->(l, r) { [["<=", l]] },
403
+ [ "<=", "=", 1 ] => ->(l, r) { [["<=", l]] },
404
+ [ "<=", "!=", -1 ] => ->(l, r) { [["<", l]] },
405
+ [ "<=", "!=", 0 ] => ->(l, r) { [["<", l]] },
406
+ [ "<=", ">", -1 ] => ->(l, r) { [] },
407
+ [ "<=", ">", 0 ] => ->(l, r) { [] },
408
+ [ "<=", ">", 1 ] => ->(l, r) { [[">", r], ["<=", l]] },
409
+ [ "<=", "<", -1 ] => ->(l, r) { [["<=", l]] },
410
+ [ "<=", "<", 0 ] => ->(l, r) { [["<=", l]] },
411
+ [ "<=", "<", 1 ] => ->(l, r) { [["<", r]] },
412
+ [ "<=", ">=", -1 ] => ->(l, r) { [] },
413
+ [ "<=", ">=", 0 ] => ->(l, r) { [["=", l]] },
414
+ [ "<=", ">=", 1 ] => ->(l, r) { [[">=", r], ["<=", l]] },
415
+ [ "<=", "~>", ->(l, r) { r.bump > l } ] => ->(l, r) { [[">=", r], ["<", r.bump]] },
416
+ [ "<=", "~>", ->(l, r) { r.bump <= l } ] => ->(l, r) { [[">=", r], ["<=", l]] },
417
+ [ "~>", "=", nil ] => ->(l, r) { [[">=", [l, r].min], ["<", l.bump]] },
418
+ [ "~>", "!=", -1 ] => ->(l, r) { [[">=", l], ["<", l.bump], ["!=", r]] },
419
+ [ "~>", "!=", 0 ] => ->(l, r) { [[">", l], ["<", l.bump]] },
420
+ [ "~>", "!=", 1 ] => ->(l, r) { [[">=", l], ["<", l.bump], ["!=", r]] },
421
+ [ "~>", ">", -1 ] => ->(l, r) { [[">=", l], ["<", l.bump]] },
422
+ [ "~>", ">", 0 ] => ->(l, r) { [[">=", l], ["<", l.bump]] },
423
+ [ "~>", ">", 1 ] => ->(l, r) { [[">", r], ["<", l.bump]]},
424
+ [ "~>", "<", nil ] => ->(l, r) { [[">=", l], ["<", [r, l.bump].max]] },
425
+ [ "~>", ">=", nil ] => ->(l, r) { [[">=", [l, r].min], ["<", l.bump]] },
426
+ [ "~>", "<=", ->(l, r) { l.bump > r } ] => ->(l, r) { [[">=", l], ["<", l.bump]] },
427
+ [ "~>", "<=", ->(l, r) { l.bump <= r } ] => ->(l, r) { [[">=", l], ["<=", r]] },
428
+ [ "~>", "~>", nil ] => ->(l, r) { [[">=", [r, l].min], ["<", [r.bump, l.bump].max]] }
429
+ }.freeze
430
+
431
+ def | other_requirement
432
+ self.expand_requirements(self.requirements | other_requirement.requirements)
433
+ end
434
+
435
+ def expand
436
+ self.expand_requirements(self.requirements)
437
+ end
438
+
439
+ def expand_requirements requirements
440
+ reqs_in = []
441
+ res = requirements.dup
442
+
443
+ #binding.pry
444
+ while reqs_in != res do
445
+ reqs_in = res
446
+ reqs = reqs_in.dup
447
+ res = []
448
+
449
+ #binding.pry
450
+ while !reqs.empty? do
451
+ op1, ver1 = reqs.shift
452
+ op2, ver2 = reqs.shift || [op1, ver1]
453
+
454
+ prc =
455
+ Gem::Requirement::OR_RELAS.find do |((left, right, comp), _)|
456
+ match = op1 == left && op2 == right &&
457
+ case comp
458
+ when NilClass
459
+ true
460
+ when Integer
461
+ comp == (ver1 <=> ver2)
462
+ when Proc
463
+ comp[ver1, ver2]
464
+ end
465
+ end
466
+
467
+ #binding.pry
468
+ res =
469
+ if prc
470
+ res.concat(prc.last[ver1, ver2])
471
+ elsif reqs.empty?
472
+ res.concat([[op1, ver1], [op2, ver2]])
473
+ else
474
+ #binding.pry
475
+ reqs.unshift([op2, ver2])
476
+ res.concat([[op1, ver1]])
477
+ end
478
+ end
479
+ end
480
+
481
+ #binding.pry
482
+ Gem::Requirement.new(res.map {|x|x.join(" ")})
483
+ end
484
+
485
+ # merging gem requirement with others strictizing the conditions
486
+ def merge other_requirement
487
+ reqs_pre = self.requirements | other_requirement.requirements
488
+ reqs_tmp = []
489
+
490
+ while reqs_tmp != reqs_pre
491
+ reqs_tmp = reqs_pre
492
+ reqs_pre =
493
+ reqs_tmp[1..-1].reduce([reqs_tmp.first]) do |res, req|
494
+ op1, ver1 = res.last
495
+ op2, ver2 = req
496
+
497
+ prc =
498
+ Gem::Requirement::AND_RELAS.find do |((left, right, comp), _)|
499
+ match = op1 == left && op2 == right &&
500
+ case comp
501
+ when NilClass
502
+ true
503
+ when Integer
504
+ comp == (ver1 <=> ver2)
505
+ when Proc
506
+ comp[ver1, ver2]
507
+ end
508
+ end
509
+
510
+ res[0...-1] | prc ? prc.last[ver1, ver2] : [INVALID_DEP]
511
+ end
512
+ end
513
+
514
+ # binding.pry
515
+ Gem::Requirement.new(reqs_pre.map {|x|x.join(" ")})
516
+ end
517
+ end
518
+
519
+ module Kernel
520
+ def yaml_load text
521
+ if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("4.0.0")
522
+ YAML.load(text, aliases: true, permitted_classes:
523
+ [Gem::Specification,
524
+ Gem::Version,
525
+ Gem::Dependency,
526
+ Gem::Requirement,
527
+ Symbol,
528
+ OpenStruct,
529
+ Time,
530
+ Date])
531
+ else
532
+ YAML.load(text)
533
+ end
534
+ end
535
+ end
536
+ end
@@ -0,0 +1,64 @@
1
+ require 'baltix/version'
2
+
3
+ module Baltix::I18n
4
+ class << self
5
+ def locale_trees
6
+ @locale_trees ||= {}
7
+ end
8
+
9
+ def default_locale
10
+ @default_locale ||= locales.sort do |x, y|
11
+ x == "en_US.UTF-8" && -1 || y == "en_US.UTF-8" && 1 || 0
12
+ end.first
13
+ end
14
+
15
+ def locales
16
+ @locales ||= Dir[File.join(File.dirname(__FILE__), "..", "..", "locale", "*.yaml")].map do |file|
17
+ File.basename(file, ".yaml")
18
+ end
19
+ end
20
+
21
+ def defaulted_locales
22
+ @defaulted_locales ||= locales.map { |locale| locale == default_locale && "" || locale }
23
+ end
24
+
25
+ def locale_tree locale
26
+ return locale_trees[locale] if locale_trees[locale]
27
+
28
+ file = File.join(File.dirname(__FILE__), "..", "..", "locale", "#{locale}.yaml")
29
+
30
+ YAML.load(IO.read(file))
31
+ end
32
+
33
+ def t! path, options = {}
34
+ parts = path.to_s.split(".")
35
+ locale = options[:locale].blank? && default_locale || options[:locale]
36
+ #binding.pry
37
+ line = parts.reduce(locale_tree(locale)) { |r, part| [ r[part] ].flatten.first }
38
+
39
+ line.gsub(/%\w+/) do |str|
40
+ /%(?<name>\w+)/ =~ str
41
+
42
+ if options[:binding].local_variable_defined?(name)
43
+ options[:binding].local_variable_get(name)
44
+ elsif options[:binding].instance_variable_defined?("@#{name}")
45
+ options[:binding].instance_variable_get(:"@#{name}")
46
+ end
47
+ end
48
+ end
49
+
50
+ def is_default? locale
51
+ default_locale == locale.to_s
52
+ end
53
+
54
+ def t path, options = {}
55
+ t!(path, options)
56
+ rescue NoMethodError
57
+ nil
58
+ end
59
+ end
60
+
61
+ def t path, options = {}
62
+ Baltix::I18n.t(path, options)
63
+ end
64
+ end
@@ -0,0 +1,11 @@
1
+ # Cmake based compilable gemspec detection, no gemspec is actually returned
2
+ # Sample gem is: hiredis
3
+ #
4
+ module Baltix::Loader::Cmake
5
+ def cmake file
6
+ log_in = `cmake .`
7
+ debug(log_in)
8
+ rescue Errno::ENOENT
9
+ error "Error: cmake is required to properly detect the gem"
10
+ end
11
+ end
@@ -0,0 +1,36 @@
1
+ # GIT-VERSION-GEN version generator based gemspec preparser
2
+ # example: "kgio" gem
3
+ #
4
+ module Baltix::Loader::GitVersionGen
5
+ def git_version_gen execfile
6
+ IO.popen(execfile) do |io|
7
+ debug(io.readlines)
8
+ end
9
+
10
+ dir = File.dirname(execfile)
11
+ version_line = IO.read(File.join(dir, "GIT-VERSION-FILE"))
12
+ if /=(?<version>.*)/ =~ version_line
13
+ ENV["VERSION"] = version.strip
14
+ end
15
+
16
+ # dot manifest generation
17
+ files = Dir["*/**/*"].select {|x| File.file?(x) }
18
+ File.open(".manifest", "w+") {|f| f.puts(files.join("\n"))}
19
+
20
+ # make documentaion
21
+ if File.directory?('Documentation')
22
+ `make -C Documentation`
23
+ end
24
+
25
+ if !File.exist?('.manifest') || !File.exist?('.gem-manifest')
26
+ files = Dir.glob("**/*", File::FNM_DOTMATCH).reject do |f|
27
+ /\/\.git/ =~ f || File.directory?(f)
28
+ end
29
+
30
+ File.open(File.join('.gem-manifest'), "w") { |f| f.puts files }
31
+ FileUtils.cp('.gem-manifest', '.manifest')
32
+ end
33
+
34
+ nil
35
+ end
36
+ end