arake 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/arake +2 -76
  2. data/lib/arake.rb +79 -0
  3. metadata +2 -1
data/bin/arake CHANGED
@@ -1,81 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'rake'
4
- require 'watchr'
3
+ require 'arake'
5
4
 
6
-
7
-
8
-
9
- class ARake
10
- attr_accessor :accumulated_args
11
-
12
- def initialize(top_level_self)
13
- @top_level_self = top_level_self
14
- @accumulated_args = []
15
-
16
- hook_task_definition
17
- end
18
-
19
- def hook_task_definition
20
- a = self
21
- (class << @top_level_self; self; end).class_eval do
22
- include Rake::TaskManager
23
-
24
- # FIXME: How about other rake tasks?
25
- define_method :file do |*args, &block|
26
- super *args, &block
27
- a.accumulate_args *resolve_args(args), &block
28
- end
29
- end
30
- end
31
-
32
- def accumulate_args(*args, &block)
33
- @accumulated_args.push [*args, block]
34
- end
35
-
36
- def create_custom_watchr
37
- a = self
38
- s = Watchr::Script.new
39
- (class << s; self; end).class_eval do
40
- define_method :parse! do
41
- @ec.instance_eval do
42
- a.accumulated_args.each do |pattern, arg_names, deps, block|
43
- p deps
44
- deps.each do |d|
45
- watch "^#{Regexp.escape d}$", &block
46
- end
47
- end
48
- end
49
- end
50
- end
51
- Watchr::Controller.new(s, Watchr.handler.new)
52
- end
53
-
54
- def load_rakefiles
55
- RakeApplicationWrapper.new.run
56
- end
57
-
58
- def run
59
- load_rakefiles
60
- watchr = create_custom_watchr
61
- watchr.run
62
- end
63
- end
64
-
65
- class RakeApplicationWrapper < Rake::Application
66
- def run
67
- standard_exception_handling do
68
- init
69
- load_rakefile
70
- # Don't run top_level at first. Because all tasks are automatically run
71
- # whenever dependents are updated.
72
- end
73
- end
74
- end
75
-
76
-
77
-
78
-
79
- ARake.new(self).run
5
+ ARake::Application.new(self).run
80
6
 
81
7
  __END__
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rake'
4
+ require 'watchr'
5
+
6
+
7
+
8
+
9
+ module ARake
10
+ class Application
11
+ attr_accessor :accumulated_args
12
+
13
+ def initialize(top_level_self)
14
+ @top_level_self = top_level_self
15
+ @accumulated_args = []
16
+
17
+ hook_task_definition
18
+ end
19
+
20
+ def hook_task_definition
21
+ a = self
22
+ (class << @top_level_self; self; end).class_eval do
23
+ include Rake::TaskManager
24
+
25
+ # FIXME: How about other rake tasks?
26
+ define_method :file do |*args, &block|
27
+ super *args, &block
28
+ a.accumulate_args *resolve_args(args), &block
29
+ end
30
+ end
31
+ end
32
+
33
+ def accumulate_args(*args, &block)
34
+ @accumulated_args.push [*args, block]
35
+ end
36
+
37
+ def create_custom_watchr
38
+ a = self
39
+ s = Watchr::Script.new
40
+ (class << s; self; end).class_eval do
41
+ define_method :parse! do
42
+ @ec.instance_eval do
43
+ a.accumulated_args.each do |pattern, arg_names, deps, block|
44
+ deps.each do |d|
45
+ watch "^#{Regexp.escape d}$", &block
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ Watchr::Controller.new(s, Watchr.handler.new)
52
+ end
53
+
54
+ def load_rakefiles
55
+ CustomRakeAppliation.new.run
56
+ end
57
+
58
+ def run
59
+ load_rakefiles
60
+ create_custom_watchr.run
61
+ end
62
+ end
63
+
64
+ class CustomRakeAppliation < Rake::Application
65
+ def run
66
+ standard_exception_handling do
67
+ init
68
+ load_rakefile
69
+ # Don't run top_level at first. Because all tasks are automatically
70
+ # run whenever dependents are updated.
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+
77
+
78
+
79
+ __END__
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: arake
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.0
5
+ version: 0.0.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kana Natsuno
@@ -58,6 +58,7 @@ extra_rdoc_files: []
58
58
  files:
59
59
  - arake.gemspec
60
60
  - bin/arake
61
+ - lib/arake.rb
61
62
  has_rdoc: true
62
63
  homepage: http://github.com/kana/ruby-arake
63
64
  licenses: []