chriseppstein-compass 0.8.14 → 0.8.15

Sign up to get free protection for your applications and to get access to all the features.
data/REVISION CHANGED
@@ -1 +1 @@
1
- 65e5b122f2d5c0022e65a519342adb2cc4a27907
1
+ 495854bb78b7b4ffbd94fbdaaaefbc5892ad47c4
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 14
2
+ :patch: 15
3
3
  :major: 0
4
4
  :minor: 8
@@ -8,16 +8,17 @@ module FSSM::Backends
8
8
  end
9
9
 
10
10
  def add_path(path, preload=true)
11
- handler = FSSM::State.new(path, preload)
11
+ handler = FSSM::State.new(path)
12
12
  @handlers["#{path}"] = handler
13
13
 
14
- fsevent = Rucola::FSEvents.new("#{path}") do |events|
14
+ fsevent = Rucola::FSEvents.new("#{path}", {:latency => 0.5}) do |events|
15
15
  events.each do |event|
16
16
  handler.refresh(event.path)
17
17
  end
18
18
  end
19
19
 
20
20
  fsevent.create_stream
21
+ handler.refresh(path.to_pathname, true) if preload
21
22
  fsevent.start
22
23
  @fsevents << fsevent
23
24
  end
@@ -6,7 +6,9 @@ module FSSM::Backends
6
6
  end
7
7
 
8
8
  def add_path(path, preload=true)
9
- @handlers << FSSM::State.new(path, preload)
9
+ handler = FSSM::State.new(path)
10
+ handler.refresh(path.to_pathname, true) if preload
11
+ @handlers << handler
10
12
  end
11
13
 
12
14
  def run
@@ -4,7 +4,32 @@ class Pathname
4
4
  path.is_a?(Pathname) ? path : new(path)
5
5
  end
6
6
  end
7
-
7
+
8
+ # before overwriting chop_basename:
9
+ # %total - 29.50%
10
+ # %self - 20.50%
11
+ # after overwriting chop_basename:
12
+ # %total - 24.36%
13
+ # %self - 15.47%
14
+ CHOP_PAT = /\A#{SEPARATOR_PAT}?\z/
15
+ def chop_basename(path)
16
+ base = File.basename(path)
17
+ # the original version of this method recalculates this regexp
18
+ # each run, despite the pattern never changing.
19
+ if CHOP_PAT =~ base
20
+ return nil
21
+ else
22
+ return path[0, path.rindex(base)], base
23
+ end
24
+ end
25
+
26
+ def segments
27
+ prefix, names = split_names(@path)
28
+ names.unshift(prefix) unless prefix.empty?
29
+ names.shift if names[0] == '.'
30
+ names
31
+ end
32
+
8
33
  def names
9
34
  prefix, names = split_names(@path)
10
35
  names
@@ -1,17 +1,18 @@
1
1
  require 'yaml'
2
2
  class FSSM::State
3
- def initialize(path, preload=true)
3
+ def initialize(path)
4
4
  @path = path
5
- @cache = FSSM::Cache.new
6
- snapshot(@path.to_pathname) if preload
5
+ @cache = FSSM::Tree::Cache.new
7
6
  end
8
7
 
9
- def refresh(base=nil)
8
+ def refresh(base=nil, skip_callbacks=false)
10
9
  previous, current = recache(base || @path.to_pathname)
11
10
 
12
- deleted(previous, current)
13
- created(previous, current)
14
- modified(previous, current)
11
+ unless skip_callbacks
12
+ deleted(previous, current)
13
+ created(previous, current)
14
+ modified(previous, current)
15
+ end
15
16
  end
16
17
 
17
18
  private
@@ -0,0 +1,176 @@
1
+ module FSSM::Tree
2
+ module NodeBase
3
+ def initialize
4
+ @children = {}
5
+ end
6
+
7
+ protected
8
+
9
+ def child(segment)
10
+ @children["#{segment}"]
11
+ end
12
+
13
+ def child!(segment)
14
+ (@children["#{segment}"] ||= Node.new)
15
+ end
16
+
17
+ def has_child?(segment)
18
+ @children.has_key?("#{segment}")
19
+ end
20
+
21
+ def remove_child(segment)
22
+ @children.delete("#{segment}")
23
+ end
24
+
25
+ def remove_children
26
+ @children.clear
27
+ end
28
+ end
29
+
30
+ module NodeEnumerable
31
+ include NodeBase
32
+ include Enumerable
33
+
34
+ def each(prefix=nil, &block)
35
+ @children.each do |segment, node|
36
+ cprefix = prefix ?
37
+ Pathname.for(prefix).join(segment) :
38
+ Pathname.for(segment)
39
+ block.call(cprefix, node)
40
+ node.each(cprefix, &block)
41
+ end
42
+ end
43
+ end
44
+
45
+ module NodeInsertion
46
+ include NodeBase
47
+
48
+ def unset(path)
49
+ key = key_segments(path)
50
+
51
+ if key.empty?
52
+ remove_children
53
+ return nil
54
+ end
55
+
56
+ segment = key.pop
57
+ node = descendant(key)
58
+
59
+ return unless node
60
+
61
+ node.remove_child(segment)
62
+
63
+ nil
64
+ end
65
+
66
+ def set(path)
67
+ node = descendant!(path)
68
+ node.from_path(path).mtime
69
+ end
70
+
71
+ protected
72
+
73
+ def key_segments(key)
74
+ return key if key.is_a?(Array)
75
+ Pathname.for(key).segments
76
+ end
77
+
78
+ def descendant(path)
79
+ recurse(path, false)
80
+ end
81
+
82
+ def descendant!(path)
83
+ recurse(path, true)
84
+ end
85
+
86
+ def recurse(key, create=false)
87
+ key = key_segments(key)
88
+ node = self
89
+
90
+ until key.empty?
91
+ segment = key.shift
92
+ node = create ? node.child!(segment) : node.child(segment)
93
+ return nil unless node
94
+ end
95
+
96
+ node
97
+ end
98
+ end
99
+
100
+ module CacheDebug
101
+ def set(path)
102
+ FSSM.dbg("Cache#set(#{path})")
103
+ super
104
+ end
105
+
106
+ def unset(path)
107
+ FSSM.dbg("Cache#unset(#{path})")
108
+ super
109
+ end
110
+
111
+ def ftype(ft)
112
+ FSSM.dbg("Cache#ftype(#{ft})")
113
+ super
114
+ end
115
+ end
116
+
117
+ class Node
118
+ include NodeBase
119
+ include NodeEnumerable
120
+
121
+ attr_accessor :mtime
122
+ attr_accessor :ftype
123
+
124
+ def <=>(other)
125
+ return unless other.is_a?(::FSSM::Tree::Node)
126
+ self.mtime <=> other.mtime
127
+ end
128
+
129
+ def from_path(path)
130
+ path = Pathname.for(path)
131
+ @ftype = path.ftype
132
+ # this handles bad symlinks without failing. why handle bad symlinks at
133
+ # all? well, we could still be interested in their creation and deletion.
134
+ @mtime = path.symlink? ? Time.at(0) : path.mtime
135
+ self
136
+ end
137
+ end
138
+
139
+ class Cache
140
+ include NodeBase
141
+ include NodeEnumerable
142
+ include NodeInsertion
143
+ include CacheDebug if $DEBUG
144
+
145
+ def set(path)
146
+ # all paths set from this level need to be absolute
147
+ # realpath will fail on broken links
148
+ path = Pathname.for(path).expand_path
149
+ super(path)
150
+ end
151
+
152
+ def files
153
+ ftype('file')
154
+ end
155
+
156
+ def directories
157
+ ftype('directory')
158
+ end
159
+
160
+ def links
161
+ ftype('link')
162
+ end
163
+ alias symlinks links
164
+
165
+ private
166
+
167
+ def ftype(ft)
168
+ inject({}) do |hash, entry|
169
+ path, node = entry
170
+ hash["#{path}"] = node.mtime if node.ftype == ft
171
+ hash
172
+ end
173
+ end
174
+ end
175
+
176
+ end
data/lib/vendor/fssm.rb CHANGED
@@ -4,9 +4,13 @@ $LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
4
4
  module FSSM
5
5
  FileNotFoundError = Class.new(StandardError)
6
6
  CallbackError = Class.new(StandardError)
7
-
7
+
8
8
  class << self
9
- def monitor(*args, &block)
9
+ def dbg(msg=nil)
10
+ STDERR.puts(msg)
11
+ end
12
+
13
+ def monitor(*args, &block)
10
14
  monitor = FSSM::Monitor.new
11
15
  context = args.empty? ? monitor : monitor.path(*args)
12
16
 
@@ -28,7 +32,7 @@ require 'pathname'
28
32
 
29
33
  require 'fssm/ext'
30
34
  require 'fssm/support'
31
- require 'fssm/cache'
35
+ require 'fssm/tree'
32
36
  require 'fssm/path'
33
37
  require 'fssm/state'
34
38
  require 'fssm/monitor'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chriseppstein-compass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.14
4
+ version: 0.8.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Eppstein
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-02 00:00:00 -07:00
12
+ date: 2009-09-05 00:00:00 -07:00
13
13
  default_executable: compass
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -270,6 +270,7 @@ files:
270
270
  - lib/vendor/fssm/path.rb
271
271
  - lib/vendor/fssm/state.rb
272
272
  - lib/vendor/fssm/support.rb
273
+ - lib/vendor/fssm/tree.rb
273
274
  - test/command_line_helper.rb
274
275
  - test/command_line_test.rb
275
276
  - test/compass_test.rb
@@ -307,7 +308,6 @@ files:
307
308
  - test/test_rails_helper.rb
308
309
  has_rdoc: false
309
310
  homepage: http://compass-style.org
310
- licenses:
311
311
  post_install_message:
312
312
  rdoc_options:
313
313
  - --charset=UTF-8
@@ -328,7 +328,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
328
328
  requirements: []
329
329
 
330
330
  rubyforge_project: compass
331
- rubygems_version: 1.3.5
331
+ rubygems_version: 1.2.0
332
332
  signing_key:
333
333
  specification_version: 3
334
334
  summary: A Real Stylesheet Framework