sake 1.0.14 → 1.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/sake.rb +34 -22
  2. data/sake.gemspec +19 -10
  3. metadata +66 -48
@@ -77,7 +77,7 @@ class Sake
77
77
  module Version #:nodoc:
78
78
  Major = '1'
79
79
  Minor = '0'
80
- Tweak = '14'
80
+ Tweak = '15'
81
81
  String = [ Major, Minor, Tweak ].join('.')
82
82
  end
83
83
 
@@ -114,11 +114,22 @@ class Sake
114
114
  begin
115
115
  tasks = TasksFile.parse(@args[index + 1]).tasks
116
116
  pattern = @args[index + 2]
117
- rescue
117
+ rescue => parse_error
118
118
  tasks = Store.tasks.sort
119
119
  pattern = index ? @args[index + 1] : nil
120
120
  end
121
- return show_tasks(tasks, pattern, display_hidden)
121
+ output = show_tasks(tasks, pattern, display_hidden)
122
+ if output.empty? and @args.size > 1 # show_tasks didn't show any tasks
123
+ case parse_error
124
+ when Errno::ENOENT, OpenURI::HTTPError
125
+ die "# Can't find file (or task) `#{@args[index + 1]}'"
126
+ when SecurityError
127
+ die "# SecurityError parsing `#{@args[index + 1]}'"
128
+ else
129
+ die "# No matching tasks for `#{pattern}'" if pattern
130
+ end
131
+ end
132
+ return output
122
133
 
123
134
  ##
124
135
  # Install a Rakefile or a single Rake task
@@ -308,6 +319,7 @@ class Sake
308
319
  # Sake::TasksFile.parse('Rakefile')
309
320
  # Sake::TasksFile.parse('http://errtheblog.com/code/errake')
310
321
  class TasksFile
322
+ include Rake::TaskManager
311
323
  attr_reader :tasks
312
324
 
313
325
  ##
@@ -322,13 +334,6 @@ class Sake
322
334
  instance = new
323
335
  Thread.new { instance.instance_eval "$SAFE = 3\n#{body}" }.join
324
336
  instance
325
-
326
- rescue Errno::ENOENT
327
- STDERR.puts "Error: The file '#{file}' doesn't exist!"
328
- exit 1
329
- rescue OpenURI::HTTPError
330
- STDERR.puts "Error: '#{file}' not found! (OpenURI::HTTPError)"
331
- exit 1
332
337
  end
333
338
 
334
339
  def initialize
@@ -359,20 +364,16 @@ class Sake
359
364
 
360
365
  ##
361
366
  # Define a task and any dependencies it may have.
362
- def task(name, &block)
363
- # If we're passed a hash, we know it has one key (the name of
364
- # the task) pointing to a single or multiple dependencies.
365
- if name.is_a? Hash
366
- deps = name.values.first
367
- name = name.keys.first
368
- end
367
+ def task(*args, &block)
368
+ # Use Rake::TaskManager method to get task details
369
+ task_name, arg_names, deps = resolve_args(args)
369
370
 
370
371
  # Our namespace is really just a convenience method. Essentially,
371
372
  # a namespace is just part of the task name.
372
- name = [ @namespace, name ].flatten * ':'
373
+ task_name = [ @namespace, task_name ].flatten * ':'
373
374
 
374
375
  # Sake's version of a rake task
375
- task = Task.new(name, deps, @comment, &block)
376
+ task = Task.new(task_name, arg_names, deps, @comment, &block)
376
377
 
377
378
  @tasks << task
378
379
 
@@ -422,9 +423,10 @@ class Sake
422
423
  class Task
423
424
  attr_reader :name, :comment
424
425
 
425
- def initialize(name, deps = nil, comment = nil, &block)
426
+ def initialize(name, args = nil, deps = nil, comment = nil, &block)
426
427
  @name = name
427
428
  @comment = comment
429
+ @args = Array(args)
428
430
  @deps = Array(deps)
429
431
  @body = block
430
432
  end
@@ -436,12 +438,21 @@ class Sake
436
438
  out << "desc '#{@comment.gsub("'", "\\\\'")}'\n" if @comment
437
439
  out << "task '#{@name}'"
438
440
 
441
+ if @args.any?
442
+ args = @args.map { |arg| ":#{arg}" }.join(', ')
443
+ out << ", #{args} "
444
+ end
445
+
439
446
  if @deps.any?
440
447
  deps = @deps.map { |dep| "'#{dep}'" }.join(', ')
441
- out << " => [ #{deps} ]"
448
+ out << ", :needs => [ #{deps} ]"
442
449
  end
443
450
 
444
- out << " do\n"
451
+ if @args.any?
452
+ out << " do |t, args|\n"
453
+ else
454
+ out << " do\n"
455
+ end
445
456
 
446
457
  # get rid of the proc { / } lines
447
458
  out << @body.to_ruby.split("\n")[1...-1].join("\n") rescue nil
@@ -508,6 +519,7 @@ class Sake
508
519
  ##
509
520
  # Wrote our current tasks_file to disk, overwriting the current Store.
510
521
  def save!
522
+ tasks_file # ensure the tasks_file is loaded before overwriting
511
523
  File.open(path, 'w') do |file|
512
524
  file.puts tasks_file.to_ruby
513
525
  end
@@ -1,21 +1,30 @@
1
1
 
2
- # Gem::Specification for Sake-1.0.14
2
+ # Gem::Specification for Sake-1.0.15
3
3
  # Originally generated by Echoe
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = %q{sake}
7
- s.version = "1.0.14"
8
- s.date = %q{2008-03-16}
9
- s.summary = %q{Sake tastes great and helps maintain system-level Rake files.}
7
+ s.version = "1.0.15"
8
+
9
+ s.specification_version = 2 if s.respond_to? :specification_version=
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.authors = ["Chris Wanstrath"]
13
+ s.date = %q{2008-06-15}
14
+ s.default_executable = %q{sake}
15
+ s.description = %q{Sake tastes great and helps maintain system-level Rake files.}
10
16
  s.email = %q{chris@ozmm.org}
17
+ s.executables = ["sake"]
18
+ s.extra_rdoc_files = ["bin/sake", "lib/help.rb", "lib/pastie.rb", "lib/sake.rb", "lib/server.rb", "README", "LICENSE"]
19
+ s.files = ["bin/sake", "lib/help.rb", "lib/pastie.rb", "lib/sake.rb", "lib/server.rb", "Manifest", "Rakefile", "README", "LICENSE", "sake.gemspec"]
20
+ s.has_rdoc = true
11
21
  s.homepage = %q{http://errtheblog.com/}
22
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Sake", "--main", "README"]
23
+ s.require_paths = ["lib"]
12
24
  s.rubyforge_project = %q{err}
13
- s.description = %q{Sake tastes great and helps maintain system-level Rake files.}
14
- s.default_executable = %q{sake}
15
- s.has_rdoc = true
16
- s.authors = ["Chris Wanstrath"]
17
- s.files = ["bin/sake", "lib/help.rb", "lib/pastie.rb", "lib/sake.rb", "lib/server.rb", "Manifest", "Rakefile", "README", "LICENSE", "sake.gemspec"]
18
- s.executables = ["sake"]
25
+ s.rubygems_version = %q{1.1.1}
26
+ s.summary = %q{Sake tastes great and helps maintain system-level Rake files.}
27
+
19
28
  s.add_dependency(%q<ParseTree>, ["= 2.1.1"])
20
29
  s.add_dependency(%q<ruby2ruby>, ["= 1.1.8"])
21
30
  end
metadata CHANGED
@@ -1,61 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: sake
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.0.14
7
- date: 2008-03-16 00:00:00 -07:00
8
- summary: Sake tastes great and helps maintain system-level Rake files.
9
- require_paths:
10
- - lib
11
- email: chris@ozmm.org
12
- homepage: http://errtheblog.com/
13
- rubyforge_project: err
14
- description: Sake tastes great and helps maintain system-level Rake files.
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 1.0.15
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Chris Wanstrath
31
- files:
32
- - bin/sake
33
- - lib/help.rb
34
- - lib/pastie.rb
35
- - lib/sake.rb
36
- - lib/server.rb
37
- - Manifest
38
- - Rakefile
39
- - README
40
- - LICENSE
41
- - sake.gemspec
42
- test_files: []
43
-
44
- rdoc_options: []
45
-
46
- extra_rdoc_files: []
47
-
48
- executables:
49
- - sake
50
- extensions: []
51
-
52
- requirements: []
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
53
11
 
12
+ date: 2008-06-15 00:00:00 -07:00
13
+ default_executable:
54
14
  dependencies:
55
15
  - !ruby/object:Gem::Dependency
56
16
  name: ParseTree
57
17
  version_requirement:
58
- version_requirements: !ruby/object:Gem::Version::Requirement
18
+ version_requirements: !ruby/object:Gem::Requirement
59
19
  requirements:
60
20
  - - "="
61
21
  - !ruby/object:Gem::Version
@@ -64,9 +24,67 @@ dependencies:
64
24
  - !ruby/object:Gem::Dependency
65
25
  name: ruby2ruby
66
26
  version_requirement:
67
- version_requirements: !ruby/object:Gem::Version::Requirement
27
+ version_requirements: !ruby/object:Gem::Requirement
68
28
  requirements:
69
29
  - - "="
70
30
  - !ruby/object:Gem::Version
71
31
  version: 1.1.8
72
32
  version:
33
+ description: Sake tastes great and helps maintain system-level Rake files.
34
+ email: chris@ozmm.org
35
+ executables:
36
+ - sake
37
+ extensions: []
38
+
39
+ extra_rdoc_files:
40
+ - bin/sake
41
+ - lib/help.rb
42
+ - lib/pastie.rb
43
+ - lib/sake.rb
44
+ - lib/server.rb
45
+ - README
46
+ - LICENSE
47
+ files:
48
+ - bin/sake
49
+ - lib/help.rb
50
+ - lib/pastie.rb
51
+ - lib/sake.rb
52
+ - lib/server.rb
53
+ - Manifest
54
+ - Rakefile
55
+ - README
56
+ - LICENSE
57
+ - sake.gemspec
58
+ has_rdoc: true
59
+ homepage: http://errtheblog.com/
60
+ post_install_message:
61
+ rdoc_options:
62
+ - --line-numbers
63
+ - --inline-source
64
+ - --title
65
+ - Sake
66
+ - --main
67
+ - README
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: "0"
75
+ version:
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: "0"
81
+ version:
82
+ requirements: []
83
+
84
+ rubyforge_project: err
85
+ rubygems_version: 1.1.1
86
+ signing_key:
87
+ specification_version: 2
88
+ summary: Sake tastes great and helps maintain system-level Rake files.
89
+ test_files: []
90
+