nake 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. data/CHANGELOG +12 -0
  2. data/Rakefile +1 -1
  3. data/TODO.txt +2 -6
  4. data/bin/nake +7 -1
  5. data/{tmp/restart.txt → bm/Rakefile} +0 -0
  6. data/bm/bms.rb +22 -0
  7. data/bm/output.txt +5 -0
  8. data/bm/tasks.rb +0 -0
  9. data/examples/arguments.rb +29 -3
  10. data/examples/basic.rb +2 -4
  11. data/examples/complex.rb +1 -1
  12. data/examples/configuration.rb +5 -1
  13. data/examples/default.rb +2 -2
  14. data/examples/default_proc.rb +1 -1
  15. data/examples/dependencies.rb +4 -1
  16. data/examples/file.rb +12 -8
  17. data/examples/helpers.rb +2 -2
  18. data/examples/invoking.rb +11 -2
  19. data/examples/setup.rb +24 -0
  20. data/examples/task_arguments.rb +27 -0
  21. data/features/arguments.feature +22 -0
  22. data/features/basic.feature +6 -0
  23. data/features/builtin_arguments.feature +14 -0
  24. data/features/complex.feature +6 -0
  25. data/features/configuration.feature +10 -0
  26. data/features/default.feature +10 -0
  27. data/features/default_proc.feature +6 -0
  28. data/features/dependencies.feature +16 -0
  29. data/features/env.rb +11 -0
  30. data/features/executable.feature +26 -0
  31. data/features/file.feature +23 -0
  32. data/features/helpers.feature +6 -0
  33. data/features/invoking.feature +14 -0
  34. data/features/script.feature +10 -0
  35. data/features/setup.feature +5 -0
  36. data/features/steps.rb +39 -0
  37. data/features/task_arguments.feature +10 -0
  38. data/lib/nake.rb +10 -14
  39. data/lib/nake/colors.rb +4 -0
  40. data/lib/nake/dsl.rb +12 -3
  41. data/spec/spec_helper.rb +10 -0
  42. data/tasks.rb +21 -0
  43. metadata +27 -7
  44. data/examples/args.rb +0 -5
  45. data/examples/flags.rb +0 -15
  46. data/examples/options.rb +0 -6
data/CHANGELOG CHANGED
@@ -14,3 +14,15 @@
14
14
 
15
15
  = Version 0.0.3
16
16
  * Some bug fixes and task improvements
17
+
18
+ = Version 0.0.4
19
+ * Support for arguments parsing
20
+ * FileTask & file & directory helpers
21
+
22
+ = Version 0.0.5
23
+ * Benchmarks
24
+ * Some bug fixes
25
+
26
+ = Version 0.0.6
27
+ * Cucumber features
28
+ * DSL helper rule
data/Rakefile CHANGED
@@ -5,4 +5,4 @@
5
5
  Rake.application.options.trace = true
6
6
 
7
7
  # default task for RunCodeRun.com
8
- task(:default) { exec "spec spec" }
8
+ task(:default) { exec "spec spec && cucumber features" }
data/TODO.txt CHANGED
@@ -1,9 +1,5 @@
1
- - task#setup (see Desktop/nake-setup.rb)
1
+ - Task#setup
2
2
  - yardoc
3
- - specs
4
- - fix interactive task, it doesn't work so far
3
+ - specs & features
5
4
  - better argv parsing maybe, task(:spec) do |*paths, options| is fine, but task(:spec) do |path, options| will fail if no path specified ... but actually task(:spec) do |path = "spec", options| might be fine, try it ... BTW task(["-i", "--interactive"]) do |task, *args, options| doesn't work ... putting options as a first argument should solve everything, but it's not very intuitive :/
6
5
  - how to solve args inheriting (like if we have task release which depends on task build which takes a gemspec as an argument)
7
- - benchmarks against rake
8
- - maybe some of: fileutils extensions, multitask, rule (from rake, see http://rake.rubyforge.org/files/doc/rakefile_rdoc.html)
9
- - some default tasks like nake/tasks/package, nake/tasks/clean, nake/tasks/yardoc, nake/tasks/spec, nake/tasks/bundle
data/bin/nake CHANGED
@@ -30,7 +30,7 @@ rescue Exception => exception
30
30
  puts "Exception occured during parsing arguments"
31
31
  print_exception_with_backtrace_and_abort(exception)
32
32
  else
33
- if Nake.parse[:nake].include?("--debug") # Nake.debug isn't initialized yet
33
+ if Nake.parse[:nake] && Nake.parse[:nake].include?("--debug") # Nake.debug isn't initialized yet
34
34
  puts "~ Arguments parsed into #{Nake.parse.inspect.green}"
35
35
  end
36
36
  end
@@ -42,6 +42,10 @@ if Nake.parse[:file]
42
42
  rescue Exception => exception
43
43
  print_exception_with_backtrace_and_abort(exception)
44
44
  end
45
+ elsif File.exist?("tasks.rb")
46
+ # default value, useful when running nake on systems without
47
+ # shebang support, so you are using nake -T instead of ./tasks.rb -T
48
+ Nake.parse[:file] = "tasks.rb"
45
49
  else
46
50
  abort "You have to specify a file with tasks"
47
51
  end
@@ -66,6 +70,8 @@ end
66
70
  # run tasks
67
71
  begin
68
72
  Nake.run_task
73
+ rescue TaskNotFound => exception
74
+ abort exception.message
69
75
  rescue SystemExit => exception
70
76
  exit exception.status
71
77
  rescue Exception => exception
File without changes
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $VERBOSE = nil # shut up
4
+
5
+ require "rbench"
6
+
7
+ rake = `which rake`.chomp
8
+ nake = "./bin/nake"
9
+
10
+ abort "You have to install Rake!" if rake.empty?
11
+ puts "Using nake from #{nake} and rake from #{rake}\n\n"
12
+
13
+ # Make sure you are running both Rake and Nake on the same Ruby version!
14
+ RBench.run(10) do
15
+ column :rake
16
+ column :nake
17
+
18
+ report "list tasks" do
19
+ rake { system("#{rake} -T &> /dev/null") || abort("Problem during running #{rake} -T") }
20
+ nake { system("#{nake} -T &> /dev/null") || abort("Problem during running #{nake} -T") }
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ Using nake from ./bin/nake and rake from /Users/botanicus/.rvm/ruby-1.9.1-p376/bin/rake
2
+
3
+ RAKE | NAKE |
4
+ --------------------------------------
5
+ list tasks 2.676 | 0.580 |
File without changes
@@ -1,4 +1,10 @@
1
- #!./bin/nake
1
+ #!/usr/bin/env ./bin/nake --debug
2
+
3
+ # This example document how you can change different flags
4
+ # - specify these flags in shebang
5
+ # - use API directly
6
+ # - ./examples/flags --verbose
7
+ Nake.verbose = false
2
8
 
3
9
  # Arguments might be considered as a light-weight variant to tasks
4
10
  # There are two ways how you can use tasks:
@@ -6,7 +12,27 @@
6
12
  # 2) add your own functionality and then use exit
7
13
  # 3) just set the task which will run afterwards
8
14
  Nake.args["-H", "--help"] = lambda { Kernel.abort("This is my customized help!") }
9
- Nake.args["-T", "--tasks"] = lambda { Nake.parse[:task].clear.push("tasks") }
10
- Nake.args["--debug", "--no-debug"] = lambda { |key, value| Nake.debug = value }
15
+
16
+ task(:tasks) { puts "Available tasks: #{Nake::Task.tasks.keys.join(", ")}" }
17
+ Nake.args["-T", "--tasks"] = lambda { |*| Nake.parse[:task].clear.push("tasks") }
18
+
19
+ argument("--debug", "--no-debug") do |key, value|
20
+ puts "~ Setting #{key} to #{value}"
21
+ Nake.debug = value
22
+ end
23
+
24
+ # ./examples/arguments.rb --report greet
25
+ # ./examples/arguments.rb --report wait
26
+ task(:greet) { puts "Hey mate!" }
27
+ task(:wait) { sleep(1) }
28
+
29
+ argument("--report") do |*|
30
+ @before = Time.now
31
+ at_exit do
32
+ task = Nake.parse[:task].first
33
+ time = Time.now - @before
34
+ puts "Running task #{task} took #{time} seconds"
35
+ end
36
+ end
11
37
 
12
38
  # TODO: execution order, argument helper + args passing to the proc
@@ -1,7 +1,5 @@
1
- #!./bin/nake
1
+ #!/usr/bin/env ./bin/nake
2
2
 
3
- # simple
4
- task(:greet1) do
3
+ task(:greet) do
5
4
  puts "Hi #{ENV["USER"]}!"
6
5
  end
7
-
@@ -1,4 +1,4 @@
1
- #!./bin/nake
1
+ #!/usr/bin/env ./bin/nake
2
2
 
3
3
  Task.new(:release) do |task|
4
4
  task.description = "Just release it"
@@ -1,4 +1,4 @@
1
- #!./bin/nake
1
+ #!/usr/bin/env ./bin/nake
2
2
 
3
3
  # this will be probably in a library
4
4
  Task.new(:build) do |task|
@@ -9,3 +9,7 @@ end
9
9
 
10
10
  # and this in your file with tasks
11
11
  Task[:build].config[:gemspec] = "nake.gemspec"
12
+
13
+ # if the task isn't defined yet
14
+ task(:mytask)
15
+ Task[:mytask].config[:name] = "foo"
@@ -1,4 +1,4 @@
1
- #!./bin/nake
1
+ #!/usr/bin/env ./bin/nake
2
2
 
3
3
  # When you run rake without arguments, it will try to run task called default.
4
4
  # Since I don't believe in any stupid convention, I don't support anything similar,
@@ -7,4 +7,4 @@
7
7
  # so you have to put this to the end of your file or you might want to use
8
8
  # Hash#default_proc=(proc) as described in examples/default_proc.rb like:
9
9
  # Task.tasks.default_proc = lambda { |*| Task[:build] }
10
- Task.tasks.default = Task["-T"]
10
+ Task.tasks.default = Nake.args["-T"] #Task["-T"]
@@ -1,4 +1,4 @@
1
- #!./bin/nake
1
+ #!/usr/bin/env ./bin/nake
2
2
 
3
3
  # Default value returned from Task["not_existing_task"] don't have to be even a task,
4
4
  # it just have to respond to #call, so you can use Hash#default_proc=(proc) as well
@@ -1,4 +1,7 @@
1
- #!./bin/nake
1
+ #!/usr/bin/env ./bin/nake
2
+
3
+ task(:greet1)
4
+ task(:greet2)
2
5
 
3
6
  task = task(:greet3, :greet1, :greet2)
4
7
  task.description = "Run greet1 & greet2"
@@ -1,10 +1,12 @@
1
- #!./bin/nake
1
+ #!/usr/bin/env ./bin/nake
2
2
 
3
- begin
4
- require "recho"
5
- rescue LoadError
6
- raise LoadError, "This task require recho gem!"
7
- end
3
+ # File tasks doesn't have any options or arguments,
4
+ # because if you have some setup which may generate
5
+ # each time different file, than the whole machinery
6
+ # for recognization if given task should run is useless.
7
+ # Of course you may want to use task for generating
8
+ # a file with arguments and options, but then just
9
+ # use a normal task helper or Task.new method.
8
10
 
9
11
  directory "tmp"
10
12
  directory "tmp/www"
@@ -13,6 +15,8 @@ file("tmp/restart.txt", "tmp") do |path|
13
15
  touch path
14
16
  end
15
17
 
16
- file "tmp/www/index.html", "tmp/www" do |path|
17
- echo("<html>Hello World!</html>") > path
18
+ file("tmp/www/index.html", "tmp/www") do |path|
19
+ File.open(path, "w") do |file|
20
+ file.puts("<html>Hello World!</html>")
21
+ end
18
22
  end
@@ -1,3 +1,3 @@
1
- #!./bin/nake
1
+ #!/usr/bin/env ./bin/nake
2
2
 
3
- task(:ls) { sh "ls" }.description = "List available files"
3
+ task(:greet) { sh "echo Hey from shell!" }.description = "Greeting from shell"
@@ -1,5 +1,14 @@
1
- #!./bin/nake
1
+ #!/usr/bin/env ./bin/nake
2
+
3
+ task(:inspect) do |*args, options|
4
+ puts "Arguments: #{args.inspect}"
5
+ puts "Options: #{options.inspect}"
6
+ end
2
7
 
3
8
  task(:foo) do
4
- Task[:bar].call
9
+ Task[:inspect].call
10
+ end
11
+
12
+ task(:bar) do |*args, options|
13
+ Task[:inspect].call(*args, options)
5
14
  end
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ./bin/nake
2
+
3
+ # NOTE: this isn't implemented yet!
4
+ # THERE MIGHT TO BE USEFUL TO HAVE BASE CLASS FOR TASK, BECAUSE FILE TASK DOESN'T HAVE ALIASES ETC
5
+ Task.new(:build) do |task|
6
+ task.description = "Release version #{Task[:release].config[:version]}" # but release task might not exist yet
7
+ end
8
+
9
+ # soo ...
10
+ Task.new(:build) do |task|
11
+ task.setup do |variable|
12
+ task.description = "Release version #{Task[:release].config[:version]}"
13
+ end
14
+ end
15
+
16
+ # hodi se hlavne pro descriptions a pro pushovani veci do dependencies, protoze z dependencies se daji odstranit, kdezto z procu, kde se invokujou explicitne, to jde fakt tezko
17
+ # setup task se vola na zacatku Nake.run
18
+
19
+ # advanced ...
20
+ Task.new(:build) do |task|
21
+ task.setup(:release, :other_task) do |variable|
22
+ task.description = "Release version #{Task[:release].config[:version]}"
23
+ end
24
+ end
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ./bin/nake
2
+
3
+ task(:greet) do |user, options| # FIXME: this doesn't work if you don't specify any args
4
+ puts "Hi #{user}!"
5
+ end
6
+
7
+ task(:greet) do |user = ENV["USER"], options|
8
+ puts "Hi #{user}!"
9
+ end
10
+
11
+ # ./examples/task_arguments.rb greet:options
12
+ # ./examples/task_arguments.rb greet:options --name=botanicus
13
+ # ./examples/task_arguments.rb greet:options foo bar --name=botanicus
14
+ task("greet:options") do |*, options|
15
+ raise ArgumentError, "You have to specify --name=#{ENV["USER"]}" if options.empty?
16
+ puts "Hi #{options[:name]}!"
17
+ end
18
+
19
+ ## ./examples/task_arguments.rb greet:options --name=botanicus
20
+ #task("greet:options") do |user, options|
21
+ # case options[:type]
22
+ # when :friendly
23
+ # puts "Hi mate!"
24
+ # else
25
+ # puts "Hi #{user}!"
26
+ # end
27
+ #end
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env cucumber
2
+
3
+ Feature: Arguments
4
+ Scenario: Simple argument
5
+ When I run "./examples/arguments.rb --report greet"
6
+ Then it should show "Hey mate!"
7
+ And it should succeed with "Running task greet took [\d.]+ seconds"
8
+
9
+ Scenario: Argument taking options
10
+ When I run "./examples/arguments.rb --debug greet"
11
+ Then it should show "Setting debug to true"
12
+ And it should suceed with "Hey mate!"
13
+
14
+ Scenario: Argument taking options
15
+ When I run "./examples/arguments.rb --no-debug greet"
16
+ Then it should show "Setting debug to false"
17
+ And it should suceed with "Hey mate!"
18
+
19
+ Scenario: Arguments should be able to influence task execution
20
+ When I run "./examples/arguments.rb --tasks greet"
21
+ Then it should not show "Hey mate!"
22
+ And it should suceed with "Available tasks: tasks, greet, wait"
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env cucumber
2
+
3
+ Feature: Task arguments
4
+ Scenario: run the example
5
+ When I run "./examples/basic.rb greet"
6
+ Then it should succeed with "Hi botanicus!"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env cucumber
2
+
3
+ Feature: Task arguments
4
+ Scenario: running -H or --help
5
+ When I run "./examples/basic.rb greet"
6
+ Then it should succeed with "Hi botanicus!"
7
+
8
+ Scenario: running -T or --tasks
9
+ When I run "./examples/basic.rb greet"
10
+ Then it should succeed with "Hi botanicus!"
11
+
12
+ Scenario: running -i or --interactive
13
+ When I run "./examples/basic.rb greet"
14
+ Then it should succeed with "Hi botanicus!"
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env cucumber
2
+
3
+ Feature: Task arguments
4
+ Scenario: XXX
5
+ Given this is pending
6
+ When I run "./examples/complex.rb"
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env cucumber
2
+
3
+ Feature: Task configuration
4
+ Scenario: explicit arguments
5
+ Given this is pending
6
+ When I run "./examples/configuration.rb"
7
+
8
+ Scenario: default arguments
9
+ Given this is pending
10
+ When I run "./examples/configuration.rb"
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env cucumber
2
+
3
+ Feature: Default
4
+ Scenario: explicit arguments
5
+ Given this is pending
6
+ When I run "./examples/default.rb"
7
+
8
+ Scenario: default arguments
9
+ Given this is pending
10
+ When I run "./examples/default.rb"
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env cucumber
2
+
3
+ Feature: Default proc
4
+ Scenario: XXX
5
+ Given this is pending
6
+ When I run "./examples/default_proc.rb greet"
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env cucumber
2
+
3
+ Feature: Task dependencies
4
+ # it should show dependencies as well
5
+ Scenario: inspecting with -T
6
+ Given this is pending
7
+
8
+ Scenario: Invoking task with dependencies which doesn't run yet
9
+ When I run "./examples/dependencies.rb greet3"
10
+ Then it should show "~ Invoking task greet1"
11
+ And it should show "~ Invoking task greet2"
12
+ And it should show "~ Invoking task greet3"
13
+ And it should succeed
14
+
15
+ Scenario: Invoking task with dependencies which already run
16
+ Given this is pending
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ require "spec"
4
+ require "fileutils"
5
+
6
+ # just for ensuring the tests will pass on all machines
7
+ ENV["USER"] = "botanicus"
8
+
9
+ After do
10
+ FileUtils.rm_rf "tmp"
11
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env cucumber
2
+
3
+ Feature: Running bin/nake
4
+ Scenario: Running bin/nake without any arguments
5
+ When I run "./bin/nake"
6
+ Then it should fail with "You have to specify a task you want to run!"
7
+
8
+ Scenario: Running bin/nake with a file, but without any arguments
9
+ When I run "./bin/nake examples/task_arguments.rb"
10
+ Then it should fail with "You have to specify a task you want to run!"
11
+
12
+ Scenario: Running bin/nake with a task
13
+ When I run "./bin/nake examples/task_arguments.rb greet"
14
+ Then it should succeed with "Hi botanicus"
15
+
16
+ Scenario: Running bin/nake with a task and arguments
17
+ When I run "./bin/nake examples/task_arguments.rb greet Jakub"
18
+ Then it should succeed with "Hi Jakub"
19
+
20
+ Scenario: Running task file with shebang to nake with a task
21
+ When I run "./examples/task_arguments.rb greet Jakub"
22
+ Then it should succeed with "Hi Jakub"
23
+
24
+ Scenario: Scenario: Running task file with shebang to nake with a task and arguments
25
+ When I run "./examples/task_arguments.rb greet Jakub"
26
+ Then it should succeed with "Hi Jakub"
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env cucumber
2
+
3
+ Feature: File tasks
4
+ Scenario: running -T
5
+ When I run "./examples/file.rb -T"
6
+ Then it should not show "tmp/www"
7
+ And it should show "tmp/restart.txt"
8
+
9
+ Scenario: using directory helper
10
+ When I run "./examples/file.rb tmp/www"
11
+ Then it should create "tmp/www"
12
+ And it should succeed
13
+
14
+ Scenario: using file helper
15
+ When I run "./examples/file.rb tmp/restart.txt"
16
+ Then it should create "tmp/restart.txt"
17
+ And it should succeed
18
+
19
+ Scenario: using file helper when the target file already exist
20
+ Given this is pending
21
+
22
+ Scenario: using file helper when the target file already exist but is older than its dependencies
23
+ Given this is pending
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env cucumber
2
+
3
+ Feature: Helpers
4
+ Scenario: Using sh helper
5
+ When I run "./examples/helpers.rb greet"
6
+ Then it should succeed with "Hey from shell!"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env cucumber
2
+
3
+ Feature: Invoking tasks
4
+ Scenario: without arguments
5
+ When I run "./examples/invoking.rb foo"
6
+ Then it should show "Arguments: []"
7
+ And it should show "Options: {}"
8
+ And it should suceed
9
+
10
+ Scenario: with arguments
11
+ When I run "./examples/invoking.rb foo bar a b --name=botanicus"
12
+ Then it should show "Arguments: ["a", "b"]"
13
+ And it should show "Options: {:name=>botanicus}"
14
+ And it should suceed
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env cucumber
2
+
3
+ Feature: Using Nake API for custom scripts
4
+ Scenario: running default tasks
5
+ When I run "./examples/script.rb -T"
6
+ Then it should succeed with "Available tasks"
7
+
8
+ Scenario: running custom tasks
9
+ When I run "./examples/script.rb greet:all"
10
+ Then it should succeed with "Hi guys!"
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env cucumber
2
+
3
+ Feature: Task initialization process
4
+ Scenario: XXX
5
+ Given this is pending
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+
3
+ require "open3"
4
+
5
+ # http://redmine.ruby-lang.org/issues/show/1287
6
+ When /^I run "([^\"]*)"$/ do |command|
7
+ _, @stdout, @stderr, thread = Open3.popen3(command)
8
+ @status = thread.value.exitstatus
9
+ end
10
+
11
+ Then /^it should show "([^\"]*)"$/ do |pattern|
12
+ @stdout.read.should_not match(pattern)
13
+ end
14
+
15
+ Then /^it should not show "([^\"]*)"$/ do |pattern|
16
+ @stdout.read.should_not match(pattern)
17
+ end
18
+
19
+ Then /^it should succeed$/ do
20
+ @status.should eql(0)
21
+ end
22
+
23
+ Then /^it should suceed with "([^\"]*)"$/ do |pattern|
24
+ @stdout.read.should match(pattern)
25
+ @status.should eql(0)
26
+ end
27
+
28
+ Then /^it should fail with status "(\d+)"$/ do |status = 0|
29
+ @status.should eql(status.to_i)
30
+ end
31
+
32
+ Then /^it should fail with "([^\"]*)"$/ do |pattern|
33
+ @stderr.read.should match(pattern)
34
+ @status.should_not eql(0)
35
+ end
36
+
37
+ Then /^it should create "([^\"]*)"$/ do |path|
38
+ File.exist?(path).should be_true
39
+ end
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env cucumber
2
+
3
+ Feature: Task arguments
4
+ Scenario: explicit arguments
5
+ When I run "./examples/task_arguments.rb greet jakub"
6
+ Then it should succeed with "Hi jakub!"
7
+
8
+ Scenario: default arguments
9
+ When I run "./examples/task_arguments.rb greet"
10
+ Then it should succeed with "Hi botanicus!"
@@ -3,7 +3,7 @@
3
3
  require "nake/task"
4
4
 
5
5
  module Nake
6
- VERSION ||= "0.0.5"
6
+ VERSION ||= "0.0.6"
7
7
  def self.verbose
8
8
  @@verbose
9
9
  rescue NameError
@@ -41,20 +41,16 @@ module Nake
41
41
  end
42
42
 
43
43
  def self.parse(args = ARGV)
44
- @result ||= begin
45
- args.inject(Hash.new) do |hash, argument|
46
- hash[:nake] ||= Array.new
47
- hash[:task] ||= Array.new
48
- hash[:file] ||= "tasks.rb" if File.exist?("tasks.rb")
49
- if argument.match(/^-/) && hash[:task].empty?
50
- hash[:nake].push(argument)
51
- elsif File.exist?(argument)
52
- hash[:file] = argument
53
- else
54
- hash[:task].push(argument)
55
- end
56
- hash
44
+ default = {nake: Array.new, task: Array.new}
45
+ args.inject(default) do |hash, argument|
46
+ if argument.match(/^-/) && hash[:task].empty?
47
+ hash[:nake].push(argument)
48
+ elsif File.exist?(argument) && hash[:file].nil? # just the first one
49
+ hash[:file] = argument
50
+ else
51
+ hash[:task].push(argument)
57
52
  end
53
+ hash
58
54
  end
59
55
  end
60
56
 
@@ -7,3 +7,7 @@ rescue LoadError
7
7
  end
8
8
 
9
9
  String.send(:include, Term::ANSIColor) # just for now, I know it's a mess
10
+
11
+ # show colors just if you run nake directly from command line,
12
+ # but not if are using nake in a script or so
13
+ Term::ANSIColor.coloring = STDIN.tty?
@@ -34,13 +34,22 @@ class Object
34
34
  end
35
35
  end
36
36
 
37
+ # rule "*.o", "*.c"
38
+ # rule "**/*.o", "**/.c"
39
+ def rule(glob, dependency, &block)
40
+ Dir.glob(glob).each do |path|
41
+ FileTask.new(path) do |task|
42
+ task.description = "Generate #{path}"
43
+ task.define(&block)
44
+ end
45
+ end
46
+ end
47
+
37
48
  def directory(path)
38
49
  FileTask.new(path) do |task|
39
50
  task.hidden = true # do not show in list
40
51
  task.description = "Create directory #{path}"
41
- task.define do
42
- mkdir_p path
43
- end
52
+ task.define { mkdir_p path }
44
53
  end
45
54
  end
46
55
  end
@@ -17,3 +17,13 @@ def STDOUT.capture(&block)
17
17
  $stdout = before
18
18
  output
19
19
  end
20
+
21
+ def STDERR.capture(&block)
22
+ before = self
23
+ $stderr = StringIO.new
24
+ block.call
25
+ $stderr.rewind
26
+ output = $stderr.read
27
+ $stderr = before
28
+ output
29
+ end
data/tasks.rb CHANGED
@@ -20,3 +20,24 @@ Nake::Task["hooks:whitespace:install"].tap do |task|
20
20
  task.config[:encoding] = "utf-8"
21
21
  task.config[:whitelist] = '(bin/[^/]+|.+\.(rb|rake|nake|thor|task))$'
22
22
  end
23
+
24
+ Task.new(:features) do |task|
25
+ task.description = "Run cucumber scenarios"
26
+ task.define do
27
+ sh "cucumber features"
28
+ end
29
+ end
30
+
31
+ Task.new(:bm) do |task|
32
+ task.description = "Run benchmarks"
33
+ task.define do
34
+ load "#{File.dirname(__FILE__)}/bm/bms.rb"
35
+ end
36
+ end
37
+
38
+ Task.new("bm:save") do |task|
39
+ task.description = "Run benchmarks"
40
+ task.define do
41
+ sh "ruby bm/bms.rb > bm/output.txt"
42
+ end
43
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Jakub \xC5\xA0\xC5\xA5astn\xC3\xBD aka Botanicus"
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
- date: 2009-12-29 00:00:00 +01:00
11
+ date: 2009-12-31 00:00:00 +01:00
12
12
  default_executable: nake
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
@@ -31,8 +31,11 @@ extra_rdoc_files: []
31
31
 
32
32
  files:
33
33
  - bin/nake
34
+ - bm/bms.rb
35
+ - bm/output.txt
36
+ - bm/Rakefile
37
+ - bm/tasks.rb
34
38
  - CHANGELOG
35
- - examples/args.rb
36
39
  - examples/arguments.rb
37
40
  - examples/basic.rb
38
41
  - examples/complex.rb
@@ -41,11 +44,28 @@ files:
41
44
  - examples/default_proc.rb
42
45
  - examples/dependencies.rb
43
46
  - examples/file.rb
44
- - examples/flags.rb
45
47
  - examples/helpers.rb
46
48
  - examples/invoking.rb
47
- - examples/options.rb
48
49
  - examples/script.rb
50
+ - examples/setup.rb
51
+ - examples/task_arguments.rb
52
+ - features/arguments.feature
53
+ - features/basic.feature
54
+ - features/builtin_arguments.feature
55
+ - features/complex.feature
56
+ - features/configuration.feature
57
+ - features/default.feature
58
+ - features/default_proc.feature
59
+ - features/dependencies.feature
60
+ - features/env.rb
61
+ - features/executable.feature
62
+ - features/file.feature
63
+ - features/helpers.feature
64
+ - features/invoking.feature
65
+ - features/script.feature
66
+ - features/setup.feature
67
+ - features/steps.rb
68
+ - features/task_arguments.feature
49
69
  - lib/nake/args.rb
50
70
  - lib/nake/argv.rb
51
71
  - lib/nake/colors.rb
@@ -77,7 +97,6 @@ files:
77
97
  - spec/spec.opts
78
98
  - spec/spec_helper.rb
79
99
  - tasks.rb
80
- - tmp/restart.txt
81
100
  - TODO.txt
82
101
  has_rdoc: true
83
102
  homepage: http://github.com/botanicus/nake
@@ -85,7 +104,8 @@ licenses: []
85
104
 
86
105
  post_install_message: |-
87
106
  === Changes in the last Nake ===
88
- - Some bug fixes and task improvements
107
+ - Cucumber features
108
+ - DSL helper rule
89
109
  rdoc_options: []
90
110
 
91
111
  require_paths:
@@ -1,5 +0,0 @@
1
- #!./bin/nake
2
-
3
- task(:greet2) do |user = ENV["USER"]|
4
- puts "Hi #{user}!"
5
- end
@@ -1,15 +0,0 @@
1
- #!./bin/nake --verbose
2
-
3
- # This example document how you can change different flags
4
- # - specify these flags in shebang
5
- # - use API directly
6
- # - ./examples/flags --verbose
7
- Nake.verbose = false
8
-
9
- task(:setup) do
10
- puts "Setting environment ..."
11
- end
12
-
13
- task(:build, :setup) do
14
- puts "Building ..."
15
- end
@@ -1,6 +0,0 @@
1
- #!./bin/nake
2
-
3
- # ./examples/options.rb greet2 --name=botanicus
4
- task(:greet2) do |options|
5
- puts "Hi #{options[:name]}!"
6
- end