teapot 0.9.7 → 0.9.8

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
  SHA1:
3
- metadata.gz: 64f2a0edc8ff6b5841b0ff8cf5e2cb7d35ef977c
4
- data.tar.gz: 41621d952ff9bd058b74a6ff7d2c95feb199f849
3
+ metadata.gz: abdffc9e228ea78ccdd980fe913d57db8888db03
4
+ data.tar.gz: d2615667fdee353c3ed34e2521443d8111e3ffce
5
5
  SHA512:
6
- metadata.gz: 6d7a7cbe915fc27ebbd148658b4731cc093d8e905a3444120ba511f35b19ebc6c2d670956d411e2fcfce742d14591081581ac551757999fba397e08d5c1518a2
7
- data.tar.gz: 08421526dd8288ae6e009ceca30ccea7200c3cc9f04b4687e5f53f0ab175cdf316bb943b11911d54f9fa5990117fe525c1a843ea5f10b574717a63ffe5e10267
6
+ metadata.gz: 889208dbe3ea2535f296f8a9e1916421c8b5ab10fe9667b7c6095e9550b2cbd592183b68d6b3a11a8b9c51fc5682f5654df5d0196380993a725738a6de2ce613
7
+ data.tar.gz: b9c7b4348b0adc44a3324d45bced141dd951fa60369ddb4eb776224b8bd8905ea55e494821fa9a61eeea4c579d72bd78bc9ffb4f1d3e83455d4bebe49297a9e5
@@ -80,6 +80,10 @@ module Teapot
80
80
  def to_s
81
81
  @table.to_s
82
82
  end
83
+
84
+ def self.by_name(contents = [])
85
+ self.new(contents, &:name)
86
+ end
83
87
  end
84
88
 
85
89
  class Configuration < Definition
@@ -98,8 +102,8 @@ module Teapot
98
102
  @options = DEFAULT_OPTIONS.dup
99
103
  end
100
104
 
101
- @packages = IdentitySet.new(packages, &:name)
102
- @imports = IdentitySet.new(&:name)
105
+ @packages = IdentitySet.by_name(packages)
106
+ @imports = IdentitySet.by_name
103
107
 
104
108
  @visibility = :private
105
109
  end
@@ -196,6 +200,9 @@ module Teapot
196
200
  # Potentially no materialization is required:
197
201
  return false if @imports.count == 0
198
202
 
203
+ # Avoid loops in the dependency chain:
204
+ imported = IdentitySet.new(&:name)
205
+
199
206
  # Enumerate all imports and attempt to resolve the packages:
200
207
  begin
201
208
  updated = false
@@ -210,11 +217,19 @@ module Teapot
210
217
 
211
218
  imports.each do |import|
212
219
  named_configuration = @context.configurations[import.name]
213
-
220
+
221
+ # So we don't get into some crazy cycle:
222
+ next if imported.include? import
223
+
224
+ # It would be nice if we could detect cycles and issue an error to the user. However, sometimes the case above is not hit at the point where the cycle begins - it isn't clear at what point the user explicitly created a cycle, and what configuration actually ends up being imported a second time.
225
+
214
226
  if named_configuration && named_configuration != self
227
+ # Mark this as resolved
228
+ imported << import
229
+
215
230
  updated = self.merge(named_configuration, import.options) || updated
216
231
  else
217
- # It couldn't be resolved...
232
+ # It couldn't be resolved and hasn't already been resolved...
218
233
  @imports << import
219
234
  end
220
235
  end
@@ -44,7 +44,7 @@ module Teapot
44
44
  output.puts "\tconfiguration[:source] = #{source.dump}", ''
45
45
 
46
46
  packages.each do |name|
47
- output.puts "\tconfiguration.import! #{name.dump}"
47
+ output.puts "\tconfiguration.require #{name.dump}"
48
48
  end
49
49
 
50
50
  output.puts "end", ''
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Teapot
22
- VERSION = "0.9.7"
22
+ VERSION = "0.9.8"
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teapot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-11 00:00:00.000000000 Z
11
+ date: 2013-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow