ruby-quilt 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/quilt.rb +37 -8
  2. metadata +2 -2
data/lib/quilt.rb CHANGED
@@ -17,6 +17,8 @@ class Quilt
17
17
  DEBUG_PREFIX_KEY = "debug_prefix"
18
18
  ARCHIVE_SUFFIX = ".tgz"
19
19
  DEFAULT_LRU_SIZE = 10
20
+ VALID_POSITIONS = ['before_header', 'after_header', 'before_common', 'after_common', 'before_optional',
21
+ 'optional', 'after_optional', 'before_footer', 'after_footer']
20
22
 
21
23
  def initialize(config = "quilt", log = Logger.new(STDOUT))
22
24
  @@fetching_versions = {}
@@ -95,7 +97,8 @@ class Quilt
95
97
  :header => '',
96
98
  :common => '',
97
99
  :optional => {},
98
- :footer => ''
100
+ :footer => '',
101
+ :base_modules => []
99
102
  }
100
103
  }
101
104
  begin
@@ -110,7 +113,8 @@ class Quilt
110
113
  :header => '',
111
114
  :common => '',
112
115
  :optional => {},
113
- :footer => ''
116
+ :footer => '',
117
+ :base_modules => []
114
118
  }
115
119
  end
116
120
  rescue Exception => e
@@ -125,6 +129,7 @@ class Quilt
125
129
  # "footer" : "<footer file>",
126
130
  # "common" : [
127
131
  # "<module file>",
132
+ # { <module file> : "<position>" },
128
133
  # ...
129
134
  # ],
130
135
  # "optional" : {
@@ -147,11 +152,28 @@ class Quilt
147
152
  end
148
153
  if manifest[COMMON_KEY] && manifest[COMMON_KEY].is_a?(Array)
149
154
  manifest[COMMON_KEY].each do |filename|
150
- begin
151
- new_version[prefix][:common] =
152
- "#{new_version[prefix][:common]}#{File.open(File.join(dir, filename), "rb").read}"
153
- rescue Exception => e
154
- log_error(" Could not load #{prefix.to_s} common module: #{filename}", e)
155
+ if (filename.is_a?(String))
156
+ begin
157
+ new_version[prefix][:common] =
158
+ "#{new_version[prefix][:common]}#{File.open(File.join(dir, filename), "rb").read}"
159
+ rescue Exception => e
160
+ log_error(" Could not load #{prefix.to_s} common module: #{filename}", e)
161
+ end
162
+ elsif (filename.is_a?(Hash))
163
+ filename.each do |actual_name, position_str|
164
+ position = position_str && VALID_POSITIONS.include?(position_str) ?
165
+ position_str.to_sym : :before_common
166
+ tmp_module_name = get_module_name(actual_name)
167
+ if (tmp_module_name)
168
+ tmp_module = get_module(actual_name, [], position, dir)
169
+ if (tmp_module)
170
+ new_version[prefix][:optional][tmp_module_name] = tmp_module
171
+ new_version[prefix][:base_modules].push(tmp_module_name)
172
+ end
173
+ else
174
+ log_error(" Could not extract #{prefix.to_s} module name from: #{filename}")
175
+ end
176
+ end
155
177
  end
156
178
  end
157
179
  end
@@ -163,7 +185,8 @@ class Quilt
163
185
  dependancies = value
164
186
  elsif (value.is_a?(Hash))
165
187
  dependancies = value[DEPENDANCIES_KEY] || []
166
- position = value[POSITION_KEY] ? value[POSITION_KEY].to_sym : :optional
188
+ position = value[POSITION_KEY] && VALID_POSITIONS.include?(value[POSITION_KEY]) ?
189
+ value[POSITION_KEY].to_sym : :optional
167
190
  end
168
191
  tmp_module_name = get_module_name(filename)
169
192
  if (tmp_module_name)
@@ -302,6 +325,12 @@ class Quilt
302
325
  elsif (selector.is_a?(Array))
303
326
  modules = selector
304
327
  end
328
+ base_modules = []
329
+ outversion[:base_modules].each do |mod|
330
+ next if modules.include?(mod)
331
+ base_modules.push(mod)
332
+ end
333
+ modules = base_modules.concat(modules)
305
334
 
306
335
  # resolve dependancies
307
336
  dynamics = dynamic_modules && dynamic_modules.is_a?(Hash) ? dynamic_modules : {}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-quilt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-02 00:00:00.000000000 Z
12
+ date: 2012-07-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json