do_riak 0.10.1.pre

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 (177) hide show
  1. data/CHANGELOG +2 -0
  2. data/Gemfile +9 -0
  3. data/LICENSE +20 -0
  4. data/README.textile +23 -0
  5. data/TODO.txt +4 -0
  6. data/deps.rip +8 -0
  7. data/do_riak.gemspec +40 -0
  8. data/do_riak.pre.gemspec +8 -0
  9. data/gems/cache/bacon-1.1.0.gem +0 -0
  10. data/gems/cache/code-cleaner-0.8.1.gem +0 -0
  11. data/gems/cache/nake-0.0.8.gem +0 -0
  12. data/gems/cache/term-ansicolor-1.0.4.gem +0 -0
  13. data/gems/environment.rb +107 -0
  14. data/gems/gems/bacon-1.1.0/COPYING +18 -0
  15. data/gems/gems/bacon-1.1.0/ChangeLog +220 -0
  16. data/gems/gems/bacon-1.1.0/RDOX +69 -0
  17. data/gems/gems/bacon-1.1.0/README +290 -0
  18. data/gems/gems/bacon-1.1.0/Rakefile +138 -0
  19. data/gems/gems/bacon-1.1.0/bin/bacon +117 -0
  20. data/gems/gems/bacon-1.1.0/lib/autotest/bacon.rb +36 -0
  21. data/gems/gems/bacon-1.1.0/lib/autotest/bacon_rspec.rb +2 -0
  22. data/gems/gems/bacon-1.1.0/lib/autotest/discover.rb +9 -0
  23. data/gems/gems/bacon-1.1.0/lib/bacon.rb +354 -0
  24. data/gems/gems/bacon-1.1.0/test/spec_bacon.rb +374 -0
  25. data/gems/gems/bacon-1.1.0/test/spec_should.rb +32 -0
  26. data/gems/gems/code-cleaner-0.8.1/LICENSE +20 -0
  27. data/gems/gems/code-cleaner-0.8.1/README.textile +87 -0
  28. data/gems/gems/code-cleaner-0.8.1/TODO.txt +1 -0
  29. data/gems/gems/code-cleaner-0.8.1/bin/code-cleaner +143 -0
  30. data/gems/gems/code-cleaner-0.8.1/code-cleaner-0.8.gem +0 -0
  31. data/gems/gems/code-cleaner-0.8.1/code-cleaner.gemspec +25 -0
  32. data/gems/gems/code-cleaner-0.8.1/support/pre-commit.erb +70 -0
  33. data/gems/gems/code-cleaner-0.8.1/tasks.rb +13 -0
  34. data/gems/gems/code-cleaner-0.8.1/tasks/code-cleaner.nake +49 -0
  35. data/gems/gems/code-cleaner-0.8.1/tasks/code-cleaner.rake +22 -0
  36. data/gems/gems/code-cleaner-0.8.1/tasks/code-cleaner.thor +35 -0
  37. data/gems/gems/nake-0.0.8/CHANGELOG +48 -0
  38. data/gems/gems/nake-0.0.8/LICENSE +20 -0
  39. data/gems/gems/nake-0.0.8/README.textile +39 -0
  40. data/gems/gems/nake-0.0.8/TODO.txt +23 -0
  41. data/gems/gems/nake-0.0.8/bin/nake +66 -0
  42. data/gems/gems/nake-0.0.8/bin/nrake +4 -0
  43. data/gems/gems/nake-0.0.8/bin/rake2nake +1 -0
  44. data/gems/gems/nake-0.0.8/bin/snake +41 -0
  45. data/gems/gems/nake-0.0.8/bm/Rakefile +28 -0
  46. data/gems/gems/nake-0.0.8/bm/bms.rb +56 -0
  47. data/gems/gems/nake-0.0.8/bm/output.txt +5 -0
  48. data/gems/gems/nake-0.0.8/bm/tasks.rb +21 -0
  49. data/gems/gems/nake-0.0.8/bm/tmp/test.c +6 -0
  50. data/gems/gems/nake-0.0.8/bm/tmp/www/index.html +1 -0
  51. data/gems/gems/nake-0.0.8/deps.rb +5 -0
  52. data/gems/gems/nake-0.0.8/deps.rip +5 -0
  53. data/gems/gems/nake-0.0.8/examples/arguments.rb +38 -0
  54. data/gems/gems/nake-0.0.8/examples/basic.rb +5 -0
  55. data/gems/gems/nake-0.0.8/examples/boot.rb +18 -0
  56. data/gems/gems/nake-0.0.8/examples/complex.rb +9 -0
  57. data/gems/gems/nake-0.0.8/examples/configuration.rb +15 -0
  58. data/gems/gems/nake-0.0.8/examples/default.rb +10 -0
  59. data/gems/gems/nake-0.0.8/examples/default_proc.rb +11 -0
  60. data/gems/gems/nake-0.0.8/examples/dependencies.rb +10 -0
  61. data/gems/gems/nake-0.0.8/examples/description.rb +33 -0
  62. data/gems/gems/nake-0.0.8/examples/file.rb +22 -0
  63. data/gems/gems/nake-0.0.8/examples/helpers.rb +3 -0
  64. data/gems/gems/nake-0.0.8/examples/invoking.rb +14 -0
  65. data/gems/gems/nake-0.0.8/examples/rules.rb +0 -0
  66. data/gems/gems/nake-0.0.8/examples/script.rb +20 -0
  67. data/gems/gems/nake-0.0.8/examples/task_arguments.rb +27 -0
  68. data/gems/gems/nake-0.0.8/features/arguments.feature +22 -0
  69. data/gems/gems/nake-0.0.8/features/basic.feature +6 -0
  70. data/gems/gems/nake-0.0.8/features/boot.feature +5 -0
  71. data/gems/gems/nake-0.0.8/features/builtin_arguments.feature +14 -0
  72. data/gems/gems/nake-0.0.8/features/complex.feature +6 -0
  73. data/gems/gems/nake-0.0.8/features/configuration.feature +10 -0
  74. data/gems/gems/nake-0.0.8/features/default.feature +10 -0
  75. data/gems/gems/nake-0.0.8/features/default_proc.feature +6 -0
  76. data/gems/gems/nake-0.0.8/features/dependencies.feature +16 -0
  77. data/gems/gems/nake-0.0.8/features/description.feature +0 -0
  78. data/gems/gems/nake-0.0.8/features/env.rb +11 -0
  79. data/gems/gems/nake-0.0.8/features/executable.feature +29 -0
  80. data/gems/gems/nake-0.0.8/features/file.feature +23 -0
  81. data/gems/gems/nake-0.0.8/features/helpers.feature +6 -0
  82. data/gems/gems/nake-0.0.8/features/invoking.feature +14 -0
  83. data/gems/gems/nake-0.0.8/features/rules.feature +0 -0
  84. data/gems/gems/nake-0.0.8/features/script.feature +10 -0
  85. data/gems/gems/nake-0.0.8/features/steps.rb +39 -0
  86. data/gems/gems/nake-0.0.8/features/task_arguments.feature +10 -0
  87. data/gems/gems/nake-0.0.8/lib/nake.rb +103 -0
  88. data/gems/gems/nake-0.0.8/lib/nake/abstract_task.rb +175 -0
  89. data/gems/gems/nake-0.0.8/lib/nake/args.rb +65 -0
  90. data/gems/gems/nake-0.0.8/lib/nake/argv.rb +47 -0
  91. data/gems/gems/nake-0.0.8/lib/nake/colors.rb +22 -0
  92. data/gems/gems/nake-0.0.8/lib/nake/dsl.rb +70 -0
  93. data/gems/gems/nake-0.0.8/lib/nake/file_task.rb +62 -0
  94. data/gems/gems/nake-0.0.8/lib/nake/helpers.rb +65 -0
  95. data/gems/gems/nake-0.0.8/lib/nake/rake.rb +38 -0
  96. data/gems/gems/nake-0.0.8/lib/nake/rule.rb +35 -0
  97. data/gems/gems/nake-0.0.8/lib/nake/struct_hash.rb +22 -0
  98. data/gems/gems/nake-0.0.8/lib/nake/task.rb +6 -0
  99. data/gems/gems/nake-0.0.8/lib/nake/tasks/bundle.rb +30 -0
  100. data/gems/gems/nake-0.0.8/lib/nake/tasks/clean.rb +12 -0
  101. data/gems/gems/nake-0.0.8/lib/nake/tasks/gem.rb +29 -0
  102. data/gems/gems/nake-0.0.8/lib/nake/tasks/release.rb +43 -0
  103. data/gems/gems/nake-0.0.8/lib/nake/tasks/rip.rb +33 -0
  104. data/gems/gems/nake-0.0.8/lib/nake/tasks/spec.rb +20 -0
  105. data/gems/gems/nake-0.0.8/lib/nake/template.rb +51 -0
  106. data/gems/gems/nake-0.0.8/nake-0.0.8.pre.gem +0 -0
  107. data/gems/gems/nake-0.0.8/nake.gemspec +42 -0
  108. data/gems/gems/nake-0.0.8/nake.pre.gemspec +8 -0
  109. data/gems/gems/nake-0.0.8/spec/nake/abstract_task_spec.rb +0 -0
  110. data/gems/gems/nake-0.0.8/spec/nake/args_spec.rb +0 -0
  111. data/gems/gems/nake-0.0.8/spec/nake/argv_spec.rb +51 -0
  112. data/gems/gems/nake-0.0.8/spec/nake/colors_spec.rb +0 -0
  113. data/gems/gems/nake-0.0.8/spec/nake/dsl_spec.rb +35 -0
  114. data/gems/gems/nake-0.0.8/spec/nake/file_task_spec.rb +0 -0
  115. data/gems/gems/nake-0.0.8/spec/nake/helpers_spec.rb +14 -0
  116. data/gems/gems/nake-0.0.8/spec/nake/rake_spec.rb +0 -0
  117. data/gems/gems/nake-0.0.8/spec/nake/rule_spec.rb +72 -0
  118. data/gems/gems/nake-0.0.8/spec/nake/struct_hash_spec.rb +0 -0
  119. data/gems/gems/nake-0.0.8/spec/nake/task_spec.rb +72 -0
  120. data/gems/gems/nake-0.0.8/spec/nake/tasks/bundle_spec.rb +28 -0
  121. data/gems/gems/nake-0.0.8/spec/nake/tasks/clean_spec.rb +0 -0
  122. data/gems/gems/nake-0.0.8/spec/nake/tasks/gem_spec.rb +0 -0
  123. data/gems/gems/nake-0.0.8/spec/nake/tasks/release_spec.rb +0 -0
  124. data/gems/gems/nake-0.0.8/spec/nake/tasks/rip_spec.rb +0 -0
  125. data/gems/gems/nake-0.0.8/spec/nake/tasks/spec_spec.rb +0 -0
  126. data/gems/gems/nake-0.0.8/spec/nake/tasks_spec.rb +48 -0
  127. data/gems/gems/nake-0.0.8/spec/nake/template_spec.rb +84 -0
  128. data/gems/gems/nake-0.0.8/spec/nake_spec.rb +9 -0
  129. data/gems/gems/nake-0.0.8/spec/spec.opts +5 -0
  130. data/gems/gems/nake-0.0.8/spec/spec_helper.rb +29 -0
  131. data/gems/gems/nake-0.0.8/spec/stubs/database.yml.erb +9 -0
  132. data/gems/gems/nake-0.0.8/spec/stubs/database.yml.tt +9 -0
  133. data/gems/gems/nake-0.0.8/tasks.rb +42 -0
  134. data/gems/gems/term-ansicolor-1.0.4/CHANGES +22 -0
  135. data/gems/gems/term-ansicolor-1.0.4/COPYING +340 -0
  136. data/gems/gems/term-ansicolor-1.0.4/README +31 -0
  137. data/gems/gems/term-ansicolor-1.0.4/Rakefile +86 -0
  138. data/gems/gems/term-ansicolor-1.0.4/VERSION +1 -0
  139. data/gems/gems/term-ansicolor-1.0.4/doc-main.txt +119 -0
  140. data/gems/gems/term-ansicolor-1.0.4/examples/cdiff.rb +19 -0
  141. data/gems/gems/term-ansicolor-1.0.4/examples/example.rb +89 -0
  142. data/gems/gems/term-ansicolor-1.0.4/install.rb +15 -0
  143. data/gems/gems/term-ansicolor-1.0.4/lib/term/ansicolor.rb +102 -0
  144. data/gems/gems/term-ansicolor-1.0.4/lib/term/ansicolor/version.rb +10 -0
  145. data/gems/gems/term-ansicolor-1.0.4/term-ansicolor.gemspec +20 -0
  146. data/gems/specifications/bacon-1.1.0.gemspec +30 -0
  147. data/gems/specifications/code-cleaner-0.8.1.gemspec +31 -0
  148. data/gems/specifications/nake-0.0.8.gemspec +35 -0
  149. data/gems/specifications/term-ansicolor-1.0.4.gemspec +30 -0
  150. data/lib/do_riak.rb +10 -0
  151. data/lib/do_riak/errors.rb +11 -0
  152. data/lib/do_riak/transaction.rb +24 -0
  153. data/lib/do_riak/version.rb +7 -0
  154. data/script/bacon +3 -0
  155. data/script/code-cleaner +3 -0
  156. data/script/nake +3 -0
  157. data/spec/command_spec.rb +8 -0
  158. data/spec/connection_spec.rb +17 -0
  159. data/spec/reader_spec.rb +8 -0
  160. data/spec/result_spec.rb +12 -0
  161. data/spec/spec_helper.rb +19 -0
  162. data/spec/typecast/array_spec.rb +8 -0
  163. data/spec/typecast/bigdecimal_spec.rb +8 -0
  164. data/spec/typecast/boolean_spec.rb +8 -0
  165. data/spec/typecast/byte_array_spec.rb +8 -0
  166. data/spec/typecast/class_spec.rb +8 -0
  167. data/spec/typecast/date_spec.rb +8 -0
  168. data/spec/typecast/datetime_spec.rb +8 -0
  169. data/spec/typecast/float_spec.rb +12 -0
  170. data/spec/typecast/integer_spec.rb +8 -0
  171. data/spec/typecast/nil_spec.rb +16 -0
  172. data/spec/typecast/other_spec.rb +8 -0
  173. data/spec/typecast/range_spec.rb +8 -0
  174. data/spec/typecast/string_spec.rb +8 -0
  175. data/spec/typecast/time_spec.rb +8 -0
  176. data/tasks.rb +37 -0
  177. metadata +238 -0
@@ -0,0 +1,23 @@
1
+ === 0.1 ===
2
+ - README
3
+ - update examples
4
+ - features
5
+
6
+ - task inheritance => sharing config via super
7
+ - rework rule
8
+ - check if everything works
9
+ - specs
10
+ - update benchmarks
11
+ - yardoc
12
+ - refactor bin/nake
13
+
14
+ === 0.2 ===
15
+ Task.new(:test) do |task|
16
+ task.options[:optional] = [:force] # maybe {force: :boolean}
17
+ task.options[:required] = [:name]
18
+ end
19
+ => better -T list + validations
20
+
21
+ === 0.3 ===
22
+ - nrake & nake/rake for running rake tasks in nake
23
+ - rake2nake
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
4
+
5
+ require "nake"
6
+ require "nake/args"
7
+ require "nake/helpers"
8
+
9
+ # parse arguments
10
+ begin
11
+ Nake.parse
12
+ rescue Exception => exception
13
+ puts "~ Arguments parsed into #{Nake.parse.inspect.green}"
14
+ puts "Exception occured during parsing arguments"
15
+ print_exception_with_backtrace_and_abort(exception)
16
+ else
17
+ if Nake.parse[:nake] && Nake.parse[:nake].include?("--debug") # Nake.debug isn't initialized yet
18
+ puts "~ Arguments parsed into #{Nake.parse.inspect.green}"
19
+ end
20
+ end
21
+
22
+ # load task file
23
+ if Nake.parse[:file]
24
+ begin
25
+ load Nake.parse[:file]
26
+ rescue Exception => exception
27
+ print_exception_with_backtrace_and_abort(exception)
28
+ end
29
+ elsif File.exist?("tasks.rb")
30
+ # default value, useful when running nake on systems without
31
+ # shebang support, so you are using nake -T instead of ./tasks.rb -T
32
+ Nake.parse[:file] = "tasks.rb"
33
+ else
34
+ abort "You have to specify a file with tasks"
35
+ end
36
+
37
+ # run arguments
38
+ # yes, arguments has to run after the task file is loaded
39
+ begin
40
+ original_args = Nake.parse.dup
41
+ Nake.run_args
42
+ rescue SystemExit => exception
43
+ exit exception.status
44
+ rescue Exception => exception
45
+ puts "~ Arguments parsed into #{Nake.parse.inspect.green}"
46
+ puts "Exception occured setting nake flags"
47
+ print_exception_with_backtrace_and_abort(exception)
48
+ else
49
+ if Nake.debug && Nake.parse != original_args
50
+ puts "~ Arguments changed into #{Nake.parse.inspect.green}"
51
+ end
52
+ end
53
+
54
+ # run tasks
55
+ begin
56
+ Nake.run_task
57
+ rescue TaskNotFound => exception
58
+ abort exception.message
59
+ rescue SystemExit => exception
60
+ exit exception.status
61
+ rescue Exception => exception
62
+ print_exception_with_backtrace_and_abort(exception)
63
+ end
64
+
65
+ # exit with exit status of the last command
66
+ exit $? ? $?.exitstatus : 0
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env nake
2
+
3
+ # Run rake tasks with nake
4
+ require "nake/rake"
@@ -0,0 +1 @@
1
+ #!/usr/bin/env ruby
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env nake
2
+
3
+ # Snake is similar to sake http://www.rubyinside.com/sake-system-wide-rake-tasks-543.html
4
+
5
+ # tasks
6
+
7
+ # snake get db_tasks.rb
8
+ # snake get http://gist.github.com/raw/266818/7239049c59b32d07a8af7e26f89190b61e0a7860/snake.rb
9
+ Task.new(:get) do |task|
10
+ task.description = "Add tasks from given file or URL to your %{task_file}"
11
+
12
+ task.define do |path|
13
+ require "open-uri"
14
+ begin
15
+ open(path) do |stream|
16
+ File.open(self.config[:task_file], "a") do |file|
17
+ file.puts(stream.read, "")
18
+ end
19
+ end
20
+ rescue Exception => exception
21
+ abort exception.message
22
+ end
23
+ end
24
+ end
25
+
26
+ Task.new(:edit) do |task|
27
+ task.config = Task[:get].config
28
+ task.description = "Edit %{task_file} in your editor"
29
+
30
+ task.define do
31
+ exec((ENV["EDITOR"] || "vim"), task.config[:task_file])
32
+ end
33
+ end
34
+
35
+ # setup
36
+ Task[:get].config[:task_file] = File.expand_path("~/.tasks.rb")
37
+
38
+ # run
39
+ if File.exist?(Task[:get].config[:task_file])
40
+ load Task[:get].config[:task_file]
41
+ end
@@ -0,0 +1,28 @@
1
+ desc "Simple task"
2
+ task :simple do
3
+ puts "Hello World!"
4
+ end
5
+
6
+ desc "Namespaced task"
7
+ task "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z" do
8
+ # do nothing
9
+ end
10
+
11
+ desc "Task with arguments"
12
+ task :arguments
13
+
14
+ desc "Task with dependencies"
15
+ task :dependencies
16
+
17
+ directory "tmp/www"
18
+
19
+ desc "Generate tmp/www/index.html"
20
+ file "tmp/www/index.html" => "tmp/www" do |task|
21
+ File.open(task.name, "w") do |file|
22
+ file.puts("<html>Hello World!</html>")
23
+ end
24
+ end
25
+
26
+ rule ".o" => [".c"] do |task|
27
+ sh "gcc #{task.source} -c -o #{task.name}"
28
+ end
@@ -0,0 +1,56 @@
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
+ def run(command)
14
+ system("#{command} &> /dev/null") || abort("Problem during running #{command}")
15
+ end
16
+
17
+ # Make sure you are running both Rake and Nake on the same Ruby version!
18
+ RBench.run(10) do
19
+ column :rake
20
+ column :nake
21
+
22
+ report "list tasks" do
23
+ rake { run "#{rake} -T" }
24
+ nake { run "#{nake} -T" }
25
+ end
26
+
27
+ report "simple task" do
28
+ rake { run "#{rake} simple" }
29
+ nake { run "#{nake} simple" }
30
+ end
31
+
32
+ report "namespaced task" do
33
+ rake { run "#{rake} a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z" }
34
+ nake { run "#{nake} a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z" }
35
+ end
36
+
37
+ #report "task with arguments" do
38
+ # rake { run "#{rake} arguments" }
39
+ # nake { run "#{nake} arguments" }
40
+ #end
41
+ #
42
+ #report "task with dependencies" do
43
+ # rake { run "#{rake} dependencies" }
44
+ # nake { run "#{nake} dependencies" }
45
+ #end
46
+
47
+ report "file task" do
48
+ rake { run "#{rake} tmp/www/index.html" }
49
+ nake { run "#{nake} tmp/www/index.html" }
50
+ end
51
+
52
+ #report "rule" do
53
+ # rake { run "#{rake} tmp/test.o" }
54
+ # nake { run "#{nake} tmp/test.o" }
55
+ #end
56
+ 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 |
@@ -0,0 +1,21 @@
1
+ #!../bin/nake
2
+
3
+ task :simple do
4
+ puts "Hello World!"
5
+ end
6
+
7
+ task "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z" do
8
+ # do nothing
9
+ end
10
+
11
+ directory "tmp/www"
12
+
13
+ file "tmp/www/index.html", "tmp/www" do |path|
14
+ File.open(path, "w") do |file|
15
+ file.puts("<html>Hello World!</html>")
16
+ end
17
+ end
18
+
19
+ #rule ".o" => [".c"] do |task|
20
+ # sh "gcc #{task.source} -c -o #{task.name}"
21
+ #end
@@ -0,0 +1,6 @@
1
+ #include <stdio.h>
2
+
3
+ int main() {
4
+ printf("Hello World!\n");
5
+ return 0;
6
+ }
@@ -0,0 +1 @@
1
+ <html>Hello World!</html>
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env rip install
2
+
3
+ # Syntax:
4
+ # repository [tag or commit to install]
5
+ git://github.com/flori/term-ansicolor
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env rip install
2
+
3
+ # Syntax:
4
+ # repository [tag or commit to install]
5
+ git://github.com/flori/term-ansicolor
@@ -0,0 +1,38 @@
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
8
+
9
+ # Arguments might be considered as a light-weight variant to tasks
10
+ # There are two ways how you can use tasks:
11
+ # 1) as a filter, just set a variable --debug
12
+ # 2) add your own functionality and then use exit
13
+ # 3) just set the task which will run afterwards
14
+ Nake.args["-H", "--help"] = lambda { Kernel.abort("This is my customized help!") }
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
37
+
38
+ # TODO: execution order, argument helper + args passing to the proc
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ./bin/nake
2
+
3
+ task(:greet) do
4
+ puts "Hi #{ENV["USER"]}!"
5
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ./bin/nake
2
+
3
+ # You might want to give more useful description, however you don't have access
4
+ # to some variables so far ... at least with Rake. Nake provides boot method which
5
+ # run after everything is loaded, and if you specify optional dependencies for the
6
+ # boot method, it will run the boot block of specified tasks first. This might come
7
+ # handy time to time, but usually it's enough to use it without arguments since you
8
+ # usually need just to load the whole task file where is all the configuration.
9
+
10
+ # Typical usecases:
11
+ # - you want to provide concrete info in description
12
+ # - you need to access configuration of a task on other place than in the define block
13
+
14
+ Task.new(:build) do |task|
15
+ task.boot(:release) do
16
+ task.description = "Release version #{Task[:release].config[:version]}"
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ./bin/nake
2
+
3
+ Task.new(:release) do |task|
4
+ task.description = "Just release it"
5
+ task.dependencies.clear # redefine
6
+ task.block do |*args|
7
+
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ./bin/nake
2
+
3
+ # this will be probably in a library
4
+ Task.new(:build) do |task|
5
+ task.define do
6
+ sh "gem build #{task.config[:gemspec]}"
7
+ end
8
+ end
9
+
10
+ # and this in your file with tasks
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"
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ./bin/nake
2
+
3
+ # When you run rake without arguments, it will try to run task called default.
4
+ # Since I don't believe in any stupid convention, I don't support anything similar,
5
+ # because you can do it just using standard Ruby methods like Hash#default=(value)
6
+ # Of course the task which you are assigning as a default have to already exist,
7
+ # so you have to put this to the end of your file or you might want to use
8
+ # Hash#default_proc=(proc) as described in examples/default_proc.rb like:
9
+ # Task.tasks.default_proc = lambda { |*| Task[:build] }
10
+ Task.tasks.default = Nake.args["-T"] #Task["-T"]
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ./bin/nake
2
+
3
+ # Default value returned from Task["not_existing_task"] don't have to be even a task,
4
+ # it just have to respond to #call, so you can use Hash#default_proc=(proc) as well
5
+ # Just make sure you are wrap the callable object in lambda, because the callable
6
+ # object has to be returned as a result from the finding on the hash, but the
7
+ # default proc is what is actually called if nothing is found.
8
+ # You might i. e. customize error message or you might detect desired task in runtime.
9
+ Task.tasks.default_proc = lambda do |tasks, name|
10
+ lambda { |*args| abort("Task #{name} executed with args: #{args.inspect}") }
11
+ end
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ./bin/nake
2
+
3
+ # You can do the same by adding Task[name].call in the define block, but please,
4
+ # don't use this approach. Dependencies are readable and if someone wants to,
5
+ # he can simply remove a dependency from the dependency array.
6
+ task(:greet1)
7
+ task(:greet2)
8
+
9
+ task = task(:greet3, :greet1, :greet2)
10
+ task.description = "Run greet1 & greet2"
@@ -0,0 +1,33 @@
1
+ desc :release, "Create a new release"
2
+ task(:release) do
3
+ # ...
4
+ end
5
+
6
+ task = task(:release) do
7
+ # ...
8
+ end
9
+ task.description = "Create a new release"
10
+
11
+ task(:release) do
12
+ # ...
13
+ end
14
+ Task[:release].description = "Create a new release"
15
+
16
+ task = task(:release)
17
+ task.description = "Create a new release"
18
+ task.define do
19
+ # ...
20
+ end
21
+
22
+ task(:release)
23
+ Task[:release].description = "Create a new release"
24
+ task(:release) do
25
+ # ...
26
+ end
27
+
28
+ Task.new(:release) do |task|
29
+ task.description = "Create a new release"
30
+ task.define do
31
+ # ...
32
+ end
33
+ end