rego 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. data/b.rb +20 -0
  2. data/bin/rego +20 -81
  3. data/foo +1 -0
  4. data/lib/rego.rb +59 -4
  5. data/rego.gemspec +9 -4
  6. data/~/foo +0 -0
  7. metadata +10 -7
data/b.rb ADDED
@@ -0,0 +1,20 @@
1
+
2
+ require 'directory_watcher'
3
+
4
+ options = {}
5
+
6
+ options[:glob] = '*'
7
+ options[:pre_load] = true
8
+ options[:interval] = 0.42
9
+ options[:scanner] = :em
10
+
11
+
12
+ dw = DirectoryWatcher.new('/tmp', options)
13
+
14
+ dw.add_observer do |*events|
15
+ events.each{|event| p event}
16
+ end
17
+
18
+ dw.start
19
+
20
+ sleep
data/bin/rego CHANGED
@@ -98,7 +98,7 @@ Main {
98
98
  @directories.push(path)
99
99
  else
100
100
  @files.push(path)
101
- @directories.push(File.dirname(path))
101
+ @directories.push(Rego.realpath(File.dirname(path)))
102
102
  end
103
103
  end
104
104
 
@@ -115,10 +115,12 @@ Main {
115
115
  end
116
116
  end
117
117
 
118
- n = '0'
119
- line = '#' * 42
118
+ #
119
+ n = '0'
120
+ line = '#' * 42
120
121
  $running = false
121
122
 
123
+ #
122
124
  rego =
123
125
  proc do |*args|
124
126
  path = args.shift
@@ -126,42 +128,30 @@ Main {
126
128
 
127
129
  puts line
128
130
 
129
- say("# rego.#{ n } @ #{ Time.now.strftime('%H:%M:%S') } - #{ cmd }", :color => :magenta)
131
+ Rego.say("# rego.#{ n } @ #{ Time.now.strftime('%H:%M:%S') } - #{ cmd }", :color => :magenta)
130
132
  puts
131
133
 
132
134
  system(cmd)
133
135
  puts
134
136
 
135
- say("# rego.#{ n } @ #{ Time.now.strftime('%H:%M:%S') } - #{ $?.exitstatus }", :color => :yellow)
137
+ Rego.say("# rego.#{ n } @ #{ Time.now.strftime('%H:%M:%S') } - #{ $?.exitstatus }", :color => :yellow)
136
138
  puts
137
139
 
138
140
  n.succ!
139
141
  end
140
142
 
141
- rego[ false ]
142
-
143
- begin
144
- Listen.to!(*@directories, :latency => 0.1) do |modified, added, removed|
145
- [modified, added, removed].flatten.compact.uniq.each do |path|
146
- rego[path]
147
- end
148
- end
149
- rescue SignalException
150
- STDERR.reopen('/dev/null', 'w+')
151
- exit(42)
152
- end
153
-
154
-
155
- =begin
143
+ #
156
144
  fsevent = FSEvent.new
157
145
 
158
146
  fsevent.watch(
147
+
159
148
  @directories,
160
- :latency => 0.00042,
161
- :no_defer => true,
149
+ :latency => 0.00042,
150
+ :no_defer => true,
162
151
  :file_events => true,
163
- :watch_root => true,
164
- :since_when => 0
152
+ :watch_root => true,
153
+ :since_when => 0
154
+
165
155
  ) do |*args|
166
156
  unless $running
167
157
  $running = true
@@ -192,8 +182,11 @@ Main {
192
182
  $running = false
193
183
  end
194
184
 
195
- fsevent.run
196
- =end
185
+ begin
186
+ fsevent.run
187
+ rescue SignalException
188
+ exit(0)
189
+ end
197
190
  end
198
191
  }
199
192
 
@@ -230,62 +223,8 @@ BEGIN {
230
223
  end
231
224
  end
232
225
 
233
- ANSI = {
234
- :clear => "\e[0m",
235
- :reset => "\e[0m",
236
- :erase_line => "\e[K",
237
- :erase_char => "\e[P",
238
- :bold => "\e[1m",
239
- :dark => "\e[2m",
240
- :underline => "\e[4m",
241
- :underscore => "\e[4m",
242
- :blink => "\e[5m",
243
- :reverse => "\e[7m",
244
- :concealed => "\e[8m",
245
- :black => "\e[30m",
246
- :red => "\e[31m",
247
- :green => "\e[32m",
248
- :yellow => "\e[33m",
249
- :blue => "\e[34m",
250
- :magenta => "\e[35m",
251
- :cyan => "\e[36m",
252
- :white => "\e[37m",
253
- :on_black => "\e[40m",
254
- :on_red => "\e[41m",
255
- :on_green => "\e[42m",
256
- :on_yellow => "\e[43m",
257
- :on_blue => "\e[44m",
258
- :on_magenta => "\e[45m",
259
- :on_cyan => "\e[46m",
260
- :on_white => "\e[47m"
261
- }
262
-
263
- module Kernel
264
- private
265
- def say(phrase, *args)
266
- options = args.last.is_a?(Hash) ? args.pop : {}
267
- options[:color] = args.shift.to_s.to_sym unless args.empty?
268
- keys = options.keys
269
- keys.each{|key| options[key.to_s.to_sym] = options.delete(key)}
270
-
271
- color = options[:color]
272
- bold = options.has_key?(:bold)
273
-
274
- parts = [phrase]
275
-
276
- if STDOUT.tty?
277
- parts.unshift(ANSI[color]) if color
278
- parts.unshift(ANSI[:bold]) if bold
279
- parts.push(ANSI[:clear]) if parts.size > 1
280
- end
281
-
282
- method = options[:method] || :puts
283
-
284
- send(method, parts.join)
285
- end
286
- end
287
-
288
226
  require 'pathname'
227
+
289
228
  this = Pathname.new(__FILE__).realpath.to_s
290
229
  bindir = File.dirname(this)
291
230
  rootdir = File.dirname(bindir)
data/foo ADDED
@@ -0,0 +1 @@
1
+ 45
data/lib/rego.rb CHANGED
@@ -3,7 +3,7 @@ require 'pathname'
3
3
  require 'yaml'
4
4
 
5
5
  module Rego
6
- Version = '1.2.0' unless defined?(Version)
6
+ Version = '1.3.0' unless defined?(Version)
7
7
 
8
8
  def version
9
9
  Rego::Version
@@ -11,9 +11,8 @@ module Rego
11
11
 
12
12
  def dependencies
13
13
  {
14
- 'main' => [ 'main' , ' >= 4.8.1' ] ,
15
- #'rb-fsevent' => [ 'rb-fsevent' , ' >= 0.4.3.1' ] ,
16
- 'listen' => [ 'listen' , ' >= 1.0.2' ] ,
14
+ 'main' => [ 'main' , ' >= 4.8' ] ,
15
+ 'rb-fsevent' => [ 'rb-fsevent' , ' >= 0.9' ] ,
17
16
  }
18
17
  end
19
18
 
@@ -36,6 +35,62 @@ module Rego
36
35
  Rego.libdir{ libs.each{|lib| Kernel.load(lib) } }
37
36
  end
38
37
 
38
+ def realpath(path)
39
+ Pathname.new(path.to_s).realpath.to_s
40
+ end
41
+
42
+ def say(phrase, *args)
43
+ options = args.last.is_a?(Hash) ? args.pop : {}
44
+ options[:color] = args.shift.to_s.to_sym unless args.empty?
45
+ keys = options.keys
46
+ keys.each{|key| options[key.to_s.to_sym] = options.delete(key)}
47
+
48
+ color = options[:color]
49
+ bold = options.has_key?(:bold)
50
+
51
+ parts = [phrase]
52
+
53
+ if STDOUT.tty?
54
+ parts.unshift(ANSI[color]) if color
55
+ parts.unshift(ANSI[:bold]) if bold
56
+ parts.push(ANSI[:clear]) if parts.size > 1
57
+ end
58
+
59
+ method = options[:method] || :puts
60
+
61
+ send(method, parts.join)
62
+ end
63
+
64
+ ANSI = {
65
+ :clear => "\e[0m",
66
+ :reset => "\e[0m",
67
+ :erase_line => "\e[K",
68
+ :erase_char => "\e[P",
69
+ :bold => "\e[1m",
70
+ :dark => "\e[2m",
71
+ :underline => "\e[4m",
72
+ :underscore => "\e[4m",
73
+ :blink => "\e[5m",
74
+ :reverse => "\e[7m",
75
+ :concealed => "\e[8m",
76
+ :black => "\e[30m",
77
+ :red => "\e[31m",
78
+ :green => "\e[32m",
79
+ :yellow => "\e[33m",
80
+ :blue => "\e[34m",
81
+ :magenta => "\e[35m",
82
+ :cyan => "\e[36m",
83
+ :white => "\e[37m",
84
+ :on_black => "\e[40m",
85
+ :on_red => "\e[41m",
86
+ :on_green => "\e[42m",
87
+ :on_yellow => "\e[43m",
88
+ :on_blue => "\e[44m",
89
+ :on_magenta => "\e[45m",
90
+ :on_cyan => "\e[46m",
91
+ :on_white => "\e[47m"
92
+ }
93
+
39
94
  extend(Rego)
40
95
  end
41
96
 
data/rego.gemspec CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "rego"
6
- spec.version = "1.2.0"
6
+ spec.version = "1.3.0"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "rego"
9
9
  spec.description = "description: rego kicks the ass"
@@ -11,12 +11,17 @@ Gem::Specification::new do |spec|
11
11
  spec.files =
12
12
  ["README",
13
13
  "Rakefile",
14
+ "b.rb",
15
+ "bar",
16
+ "bar/foo",
14
17
  "bin",
15
18
  "bin/rego",
19
+ "foo",
16
20
  "lib",
17
21
  "lib/rego.rb",
18
22
  "rego.gemspec",
19
- "~"]
23
+ "~",
24
+ "~/foo"]
20
25
 
21
26
  spec.executables = ["rego"]
22
27
 
@@ -25,9 +30,9 @@ Gem::Specification::new do |spec|
25
30
  spec.test_files = nil
26
31
 
27
32
 
28
- spec.add_dependency(*["main", " >= 4.8.1"])
33
+ spec.add_dependency(*["main", " >= 4.8"])
29
34
 
30
- spec.add_dependency(*["listen", " >= 1.0.2"])
35
+ spec.add_dependency(*["rb-fsevent", " >= 0.9"])
31
36
 
32
37
 
33
38
  spec.extensions.push(*[])
data/~/foo ADDED
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rego
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
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: 2013-04-29 00:00:00.000000000 Z
12
+ date: 2013-05-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: main
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 4.8.1
21
+ version: '4.8'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,15 +26,15 @@ dependencies:
26
26
  requirements:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 4.8.1
29
+ version: '4.8'
30
30
  - !ruby/object:Gem::Dependency
31
- name: listen
31
+ name: rb-fsevent
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: 1.0.2
37
+ version: '0.9'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: 1.0.2
45
+ version: '0.9'
46
46
  description: ! 'description: rego kicks the ass'
47
47
  email: ara.t.howard@gmail.com
48
48
  executables:
@@ -52,9 +52,12 @@ extra_rdoc_files: []
52
52
  files:
53
53
  - README
54
54
  - Rakefile
55
+ - b.rb
55
56
  - bin/rego
57
+ - foo
56
58
  - lib/rego.rb
57
59
  - rego.gemspec
60
+ - ~/foo
58
61
  homepage: https://github.com/ahoward/rego
59
62
  licenses: []
60
63
  post_install_message: