rego 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ ## A New Post
2
+
3
+ Enter text in [Markdown](http://daringfireball.net/projects/markdown/). Use the toolbar above, or click the **?** button for formatting help.
4
+
5
+
6
+ testing out http://prose.io
data/bin/rego CHANGED
@@ -134,6 +134,9 @@ Main {
134
134
  n.succ!
135
135
  end
136
136
 
137
+ #
138
+ rego.call()
139
+
137
140
  #
138
141
  fsevent = FSEvent.new
139
142
 
data/lib/rego.rb CHANGED
@@ -4,7 +4,7 @@ require 'yaml'
4
4
  require 'tmpdir'
5
5
 
6
6
  module Rego
7
- Version = '1.5.1' unless defined?(Version)
7
+ Version = '1.5.2' unless defined?(Version)
8
8
 
9
9
  def version
10
10
  Rego::Version
data/rego.gemspec CHANGED
@@ -3,19 +3,17 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "rego"
6
- spec.version = "1.5.1"
6
+ spec.version = "1.5.2"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "rego"
9
9
  spec.description = "description: rego kicks the ass"
10
10
 
11
11
  spec.files =
12
- ["README",
12
+ ["2013-06-22-your-filename.md",
13
+ "README",
13
14
  "Rakefile",
14
15
  "bin",
15
16
  "bin/rego",
16
- "d",
17
- "d/a.rb",
18
- "d/rego",
19
17
  "lib",
20
18
  "lib/rego.rb",
21
19
  "rego.gemspec"]
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.5.1
4
+ version: 1.5.2
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-06-19 00:00:00.000000000 Z
12
+ date: 2013-06-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: main
@@ -50,11 +50,10 @@ executables:
50
50
  extensions: []
51
51
  extra_rdoc_files: []
52
52
  files:
53
+ - 2013-06-22-your-filename.md
53
54
  - README
54
55
  - Rakefile
55
56
  - bin/rego
56
- - d/a.rb
57
- - d/rego
58
57
  - lib/rego.rb
59
58
  - rego.gemspec
60
59
  homepage: https://github.com/ahoward/rego
data/d/a.rb DELETED
@@ -1 +0,0 @@
1
- 42
data/d/rego DELETED
@@ -1,282 +0,0 @@
1
- #! /usr/bin/env ruby
2
-
3
- Main {
4
-
5
- name <<-__
6
-
7
- rego
8
-
9
- __
10
-
11
- description <<-__
12
-
13
- run arbitrary commands easily when files change
14
-
15
- __
16
-
17
- examples <<-__
18
-
19
- ### gem install rego
20
-
21
-
22
- # say hai whenever the file foo.txt changes
23
- #
24
- ~> rego foo.txt -- echo hai
25
-
26
- # say hai whenever any file (recursively) in bar changes
27
- #
28
- ~> rego ./bar/ -- echo hai
29
-
30
- # echo *the file that changed* when any file (recursively) in bar changes
31
- #
32
- ~> rego ./bar/ -- echo "@ was changed"
33
-
34
- # run a specific test whenever anything in lib, test, app, or config changes
35
- #
36
- ~> rego {lib,test,app,config} -- ruby -Itest ./test/units/foo_test.rb --name teh_test
37
-
38
- # run a specific test whenever it, or your app, has changed
39
- #
40
- ~> rego ./test -- ruby -Itest @
41
- __
42
-
43
- def run
44
- parse_the_command_line
45
- print_a_summary_of_watched_files
46
- loop_watching_files_and_running_commands
47
- end
48
-
49
- def parse_the_command_line
50
- argv = ARGV.map{|arg| "#{ arg }"}
51
-
52
- @paths, @command = argv.join(' ').split('--', 2)
53
-
54
- @paths = @paths.to_s.strip.scan(/[^\s]+/)
55
- @command = @command.to_s.strip
56
-
57
- if @paths.empty?
58
- @paths.push('.')
59
- end
60
-
61
- if @command.empty?
62
- @command = 'echo @'
63
- end
64
-
65
- @paths.map!{|path| test(?d, path) ? [path, Dir.glob(File.join(path, '**/**'))] : path}
66
- @paths.flatten!
67
- @paths.compact!
68
- @paths.uniq!
69
- @paths.map! do |path|
70
- begin
71
- Rego.realpath(path)
72
- rescue Object
73
- nil
74
- end
75
- end
76
- @paths.compact!
77
- end
78
-
79
- def print_a_summary_of_watched_files
80
- puts "## #{ @command }"
81
- puts "#"
82
- puts @paths.join("\n")
83
- puts
84
- end
85
-
86
- def loop_watching_files_and_running_commands
87
- @directories = []
88
- @files = []
89
-
90
- @paths.each do |path|
91
- if test(?d, path)
92
- @directories.push(Rego.realpath(path))
93
- else
94
- @files.push(Rego.realpath(path))
95
- @directories.push(Rego.realpath(File.dirname(path)))
96
- end
97
- end
98
-
99
- @directories.uniq!
100
- @files.uniq!
101
-
102
- stats = {}
103
-
104
- @files.each do |file|
105
- begin
106
- stats[file] = File.stat(file)
107
- rescue
108
- nil
109
- end
110
- end
111
-
112
- #
113
- n = '0'
114
- line = '#' * 42
115
- $running = false
116
-
117
- #
118
- rego =
119
- proc do |*args|
120
- path = args.shift
121
- cmd = path ? @command.gsub(/@/, path) : @command
122
-
123
- puts line
124
-
125
- Rego.say("# rego.#{ n } @ #{ Time.now.strftime('%H:%M:%S') } - #{ cmd }", :color => :magenta)
126
- puts
127
-
128
- system(cmd)
129
- puts
130
-
131
- Rego.say("# rego.#{ n } @ #{ Time.now.strftime('%H:%M:%S') } - #{ $?.exitstatus }", :color => :yellow)
132
- puts
133
-
134
- n.succ!
135
- end
136
-
137
- #
138
- fsevent = FSEvent.new
139
-
140
- options = {
141
- :latency => 0.42,
142
- :no_defer => true,
143
- :file_events => true,
144
- :since_when => 0
145
- }
146
-
147
- fsevent.watch(@directories, options) do |*args|
148
- unless $running
149
- $running = true
150
-
151
- args.flatten.each do |dir|
152
- glob = File.join(dir, '**/**')
153
- entries = Dir.glob(glob)
154
-
155
- entries.each do |entry|
156
- entry = File.expand_path(entry)
157
- next unless stats.has_key?(entry)
158
-
159
- begin
160
- stats[entry] ||= File.stat(entry)
161
- before = stats[entry]
162
- after = File.stat(entry)
163
- rescue
164
- next
165
- end
166
-
167
- unless before.mtime == after.mtime
168
- stats[entry] = after
169
- rego[ entry ]
170
- end
171
- end
172
- end
173
- end
174
- $running = false
175
- end
176
-
177
- begin
178
- fsevent.run
179
- rescue SignalException
180
- exit(0)
181
- end
182
- end
183
- =begin
184
- fsevent = FSEvent.new
185
-
186
- fsevent.watch(
187
-
188
- @directories,
189
- :latency => 0.42,
190
- :no_defer => true,
191
- :file_events => true,
192
- :watch_root => true,
193
- :since_when => 0
194
-
195
- ) do |*args|
196
- unless $running
197
- $running = true
198
-
199
- args.flatten.each do |dir|
200
- glob = File.join(dir, '**/**')
201
- entries = Dir.glob(glob)
202
-
203
- entries.each do |entry|
204
- entry = File.expand_path(entry)
205
- next unless stats.has_key?(entry)
206
-
207
- begin
208
- stats[entry] ||= File.stat(entry)
209
- before = stats[entry]
210
- after = File.stat(entry)
211
- rescue
212
- next
213
- end
214
-
215
- unless before.mtime == after.mtime
216
- stats[entry] = after
217
- rego[ entry ]
218
- end
219
- end
220
- end
221
- end
222
- $running = false
223
- end
224
-
225
- begin
226
- fsevent.run
227
- rescue SignalException
228
- exit(0)
229
- end
230
- end
231
- =end
232
- }
233
-
234
-
235
- BEGIN {
236
- # setup a child process to catch signals and brutally shut down the parent as
237
- # a monkey-patch to listen/rb-fsevent's busted ctrl-c handling...
238
- #
239
- if false
240
- unless((pid = fork))
241
- ppid = Process.ppid
242
-
243
- begin
244
- trap('SIGINT'){
245
- %w(
246
- SIGTERM SIGINT SIGQUIT SIGKILL
247
- ).each do |signal|
248
-
249
- begin
250
- Process.kill("-#{ signal }", ppid)
251
- rescue Object
252
- nil
253
- end
254
-
255
- sleep(rand)
256
- end
257
- }
258
-
259
- loop do
260
- Process.kill(0, ppid)
261
- sleep(1)
262
- end
263
- rescue Object => e
264
- exit!(0)
265
- end
266
- end
267
- end
268
-
269
- require 'pathname'
270
-
271
- this = Pathname.new(__FILE__).realpath.to_s
272
- bindir = File.dirname(this)
273
- rootdir = File.dirname(bindir)
274
- libdir = File.join(rootdir, 'lib')
275
- rego = File.join(libdir, 'rego.rb')
276
-
277
- require(rego)
278
-
279
- STDOUT.sync = true
280
- STDERR.sync = true
281
- STDIN.sync = true
282
- }