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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b2057bf31a1836e294df47b8319be4313e19dcf
4
- data.tar.gz: 56a4e90fe86efe309d745b95cc57ab29514fb58f
3
+ metadata.gz: de29e58f3c06ef987ee3993e90e3525ec413edba
4
+ data.tar.gz: 6d9660e9bfe46255f1e58db4cf1f2e1d48b999b9
5
5
  SHA512:
6
- metadata.gz: 1291145a71a60ec1702691a0b360c94448e841945b74e7c2c6ff83cd53f56945b67aabca93fb44cb07b78ef122813c73ce58965dda0b40f661f9396e89f6e210
7
- data.tar.gz: 91afb4773c5b910f3ef5422b405d59b382c7ff7ab4a6faf8ba62c7bb65c1b0322784a356d33076afbe32bd72b51acbb8ba7ec5fb2716eb51ea6487430d98171f
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 thet task is run whenever any files in the project change.
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 )
@@ -25,28 +25,30 @@ module Rake
25
25
  @listeners ||= []
26
26
  end
27
27
 
28
- def run(name)
29
- task_name = name.gsub(/^\~/, '')
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 = listen_path.fetch(:paths, listen_path.fetch(:path) { Dir.pwd })
33
- opts = listen_path.fetch(:opts) {{}}
34
- blk = listen_path[: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
@@ -1,5 +1,5 @@
1
1
  module Rake
2
2
  module Tilde
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
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.2
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: 2014-12-09 00:00:00.000000000 Z
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.2.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