rake-tilde 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -1
- data/lib/rake/tilde.rb +32 -14
- data/lib/rake/tilde/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de29e58f3c06ef987ee3993e90e3525ec413edba
|
4
|
+
data.tar.gz: 6d9660e9bfe46255f1e58db4cf1f2e1d48b999b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c602b508f4d82e88fdb78dfdf210895eddf9be7a8842e068e7d132ca1a98ad997aa074155177086ada93c12d1fe398eb698f159373b4776ae37cc343f1f99f5
|
7
|
+
data.tar.gz: 3a9818bf42dfaa6d630bd7cb71bb4b8268754d5bebfff69452f2eb5d904e4221dbe80aa4db3bc84706dccbf320b6831f857edde3da1de5e4cfe012eccde2977c
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
|
|
22
22
|
## Usage
|
23
23
|
|
24
24
|
This gem monkeypatch's Rake to intercept any task that begins with ~. In
|
25
|
-
that case
|
25
|
+
that case that task is run whenever any files in the project change.
|
26
26
|
This is a basic wrapper around the [listen gem](https://github.com/guard/listen).
|
27
27
|
|
28
28
|
More interesting things can be done by specifying folders, ignores, etc
|
@@ -44,6 +44,13 @@ Then run it like this:
|
|
44
44
|
$ rake ~woo
|
45
45
|
```
|
46
46
|
|
47
|
+
## Rails (or other fancy libraries)
|
48
|
+
|
49
|
+
Some libraries really care about the names of the tasks from the
|
50
|
+
original ARGV string during load. In that case, just prepend `require
|
51
|
+
'rake/tilde'` to your Rakefile before anything else and it will rewrite
|
52
|
+
all the task names before any other library can see them.
|
53
|
+
|
47
54
|
## Contributing
|
48
55
|
|
49
56
|
1. Fork it ( https://github.com/myobie/rake-tilde/fork )
|
data/lib/rake/tilde.rb
CHANGED
@@ -25,28 +25,30 @@ module Rake
|
|
25
25
|
@listeners ||= []
|
26
26
|
end
|
27
27
|
|
28
|
-
def run(
|
29
|
-
|
30
|
-
task = Rake::Task[task_name]
|
28
|
+
def run(task_name, *task_args)
|
29
|
+
task = Rake.application[task_name]
|
31
30
|
listen_path = paths.fetch(task_name) {{}}
|
32
|
-
paths
|
33
|
-
opts
|
34
|
-
blk
|
31
|
+
paths = listen_path.fetch(:paths, listen_path.fetch(:path) { Dir.pwd })
|
32
|
+
opts = listen_path.fetch(:opts) {{}}
|
33
|
+
blk = listen_path[:blk]
|
35
34
|
|
36
35
|
begin
|
37
|
-
task.invoke
|
38
|
-
rescue
|
39
|
-
$stderr.puts "Task failed to run successfully"
|
36
|
+
task.invoke(*task_args)
|
37
|
+
rescue StandardError => exception
|
38
|
+
$stderr.puts "** Task failed to run successfully with tilde"
|
39
|
+
Rake.application.display_error_message(exception)
|
40
|
+
Rake.application.exit_because_of_exception(exception)
|
40
41
|
end
|
41
42
|
|
42
43
|
listener = Listen.to(paths, opts) do |modified, added, removed|
|
43
44
|
$stdout.puts "** File system changed"
|
44
45
|
begin
|
45
46
|
Rake::Task.tasks.each { |t| t.reenable }
|
46
|
-
task.invoke
|
47
|
+
task.invoke(*task_args)
|
47
48
|
blk.call(modified, added, removed) if blk
|
48
|
-
rescue
|
49
|
-
$stderr.puts "Task failed to run successfully"
|
49
|
+
rescue StandardError => exception
|
50
|
+
$stderr.puts "** Task failed to run successfully with tilde"
|
51
|
+
Rake.application.display_error_message(exception)
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
@@ -58,18 +60,34 @@ end
|
|
58
60
|
|
59
61
|
module OverrideInvoke
|
60
62
|
def invoke_task(task_string)
|
63
|
+
task_string = task_string.gsub(/^\~/, '')
|
61
64
|
task_name, args = parse_task_string(task_string)
|
62
65
|
|
63
|
-
if task_name
|
64
|
-
Rake::Tilde.run(task_name)
|
66
|
+
if tilde_tasks.include?(task_name)
|
67
|
+
Rake::Tilde.run(task_name, *args)
|
65
68
|
else
|
66
69
|
super
|
67
70
|
end
|
68
71
|
end
|
72
|
+
|
73
|
+
def tilde_tasks
|
74
|
+
@__tilde_tasks ||= []
|
75
|
+
end
|
69
76
|
end
|
70
77
|
|
71
78
|
Rake.application.extend OverrideInvoke
|
72
79
|
|
80
|
+
# Remove tildes from all the top level tasks
|
81
|
+
# and record which ones they were
|
82
|
+
Rake.application.top_level_tasks.map! do |task_name|
|
83
|
+
if task_name =~ /^(~)(.*)$/
|
84
|
+
Rake.application.tilde_tasks << $2
|
85
|
+
$2
|
86
|
+
else
|
87
|
+
task_name
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
73
91
|
def listen(**args, &blk)
|
74
92
|
Rake::Tilde.listen(**args, &blk)
|
75
93
|
end
|
data/lib/rake/tilde/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rake-tilde
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- myobie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
87
|
version: '0'
|
88
88
|
requirements: []
|
89
89
|
rubyforge_project:
|
90
|
-
rubygems_version: 2.
|
90
|
+
rubygems_version: 2.4.5
|
91
91
|
signing_key:
|
92
92
|
specification_version: 4
|
93
93
|
summary: Run a rake task when files change
|