nake 0.0.1 → 0.0.2.pre

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -7,3 +7,6 @@
7
7
  * Each task can has multiple aliases
8
8
  * Command line arguments parsing. Arguments will be passed as an arguments for blocks of the given task and options will be extracted into a hash, parsed into Ruby data types and passed as the last argument for the blocks.
9
9
  * Default tasks for help (-H, --help), list of available tasks (-T, --tasks) and interactive session (-i, --interactive)
10
+
11
+ = Version 0.0.2
12
+ * Support for configuration
data/README.textile CHANGED
@@ -11,6 +11,7 @@ h1. Features
11
11
  - Tasks can have a *name*, *description*, *dependencies*, *aliases* and *blocks* which will be executed when the task is called. Task can be also hidden if you don't want to list it in the list of available tasks.
12
12
  - You can use `nake` in *shebang*, so you can use your file with tasks as a runner.
13
13
  - *Arguments parsing*, everything what start with @--@ will be passed into options hash and everything other will be treated as an arguments. Both arguments and options will be passed as a block arguments for task, so you don't have to learn any new API, just use normal Ruby expressions as you are used to. Options are parsed into Ruby data types, so if you have @--without-mysql@, you'll get @{mysql: false}@, if you have @--name=botanicus@, you'll get @{name: "botanicus"}@ etc.
14
+ - *Configuration support*, so you don't have to use bunch of constants as in Rake. Example: @Task[:clean].config[:files] = Dir.glob("*.gem")@
14
15
  - *Arbitrary names of tasks* is one of the key features of Nake. This way you can *namespace* your tasks (like @nake build:prerelease@) or you can define tasks like @-T@.
15
16
  - Two level of API for defining tasks. @task@ helper is useful for defining simple tasks and if you need something more complicated, you can use @Task.new@
16
17
  - *Interactive session* if you run @nake -i@ or @nake -i task@ you get an interactive nake session.
@@ -21,4 +22,10 @@ First of all there is a bunch of "examples":github.com/botanicus/nake/tree/maste
21
22
 
22
23
  h1. Links
23
24
 
24
- - http://github.com/botanicus/filelist
25
+ * "RDoc.info API Docs":http://rdoc.info/projects/botanicus/nake
26
+ * "Yardoc.org API Docs":http://yardoc.org/docs/botanicus-nake
27
+ * "Examples":http://github.com/botanicus/nake/tree/master/examples
28
+ * "Bug reporting":http://github.com/botanicus/nake/issues
29
+ * "Caliper Code Metrics":http://devver.net/caliper/project?repo=git%3A%2F%2Fgithub.com%2Fbotanicus%2Fnake.git
30
+
31
+ * http://github.com/botanicus/filelist
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ # I know, Rake is piece of shift, unfortunately RunCodeRun.com requires it.
4
+ # http://support.runcoderun.com/faqs/builds/how-do-i-run-rake-with-trace-enabled
5
+ Rake.application.options.trace = true
6
+
7
+ # default task for RunCodeRun.com
8
+ task(:default) { exec "spec spec" }
data/bin/nake CHANGED
@@ -10,6 +10,6 @@ load ARGV.first
10
10
  # Parse arguments and run tasks
11
11
  begin
12
12
  Nake.run(ARGV[1..-1])
13
- rescue TaskNotFound => exception
13
+ rescue TaskNotFound, ConfigurationError => exception
14
14
  abort "[#{"ERROR".red}] #{exception.message}"
15
15
  end
@@ -0,0 +1,11 @@
1
+ #!./bin/nake
2
+
3
+ # this will be probably in a library
4
+ Task.new(:build) do |task|
5
+ task.define do
6
+ exec "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"
data/lib/nake.rb CHANGED
@@ -4,8 +4,9 @@ require "nake/argv"
4
4
  require "nake/task"
5
5
 
6
6
  module Nake
7
- VERSION ||= "0.0.1"
7
+ VERSION ||= "0.0.2"
8
8
  TaskNotFound ||= Class.new(StandardError)
9
+ ConfigurationError ||= Class.new(StandardError)
9
10
 
10
11
  def self.run(args = ARGV)
11
12
  name = args.shift
data/lib/nake/task.rb CHANGED
@@ -30,7 +30,7 @@ module Nake
30
30
  task && task.setup(*dependencies, &block) || super(name, *dependencies, &block)
31
31
  end
32
32
 
33
- attr_accessor :name, :description, :dependencies, :hidden, :options
33
+ attr_accessor :name, :description, :dependencies, :hidden
34
34
  attr_reader :blocks, :aliases
35
35
  def initialize(name, *dependencies, &block)
36
36
  @aliases, @hidden = Array.new, false
@@ -47,6 +47,12 @@ module Nake
47
47
  self.setup(*dependencies, &block)
48
48
  end
49
49
 
50
+ def config
51
+ @config ||= Hash.new do |hash, key|
52
+ raise ConfigurationError, "Configuration key #{key} in task #{name} doesn't exist"
53
+ end
54
+ end
55
+
50
56
  def setup(*dependencies, &block)
51
57
  self.dependencies.push(*dependencies)
52
58
  self.instance_exec(self, &block) if block
@@ -65,13 +71,13 @@ module Nake
65
71
  # which doesn't have any args and options, we wall just call it without any arguments,
66
72
  # but when we use splat, then we will have to call it at least with Hash.new for options
67
73
  def call(args = Array.new, options = Hash.new)
68
- unless @dependencies.empty?
74
+ unless self.dependencies.empty?
69
75
  puts "~ Invoking task #{name}".cyan
70
76
  self.invoke_dependencies(*args, options)
71
77
  end
72
- unless @blocks.empty?
78
+ unless self.blocks.empty?
73
79
  puts "~ Executing task #{name} with arguments #{args.inspect} and options #{options.inspect}".green
74
- @blocks.each do |block|
80
+ self.blocks.each do |block|
75
81
  if block.arity.eql?(0)
76
82
  block.call
77
83
  else
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ # NOTE: if you have bundler bundled locally, just
4
+ # add bundler/lib into $: and this task will work
5
+ Task.new(:bundle) do |task|
6
+ task.description = "Install your gems locally from gems/cache via bundler"
7
+ task.define do |*args, options|
8
+ require 'rubygems'
9
+ require 'rubygems/command'
10
+
11
+ begin
12
+ require 'bundler'
13
+ require 'bundler/commands/bundle_command'
14
+ rescue LoadError
15
+ abort "You have to have bundler installed!"
16
+ end
17
+
18
+ args.push("--cached")
19
+ Gem::Commands::BundleCommand.new.invoke(*args)
20
+ end
21
+ end
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ require "nake/dsl"
4
+
5
+ # require "nake/tasks/clean"
6
+ # Task[:clean].config[:files] = Dir["*.gem"]
7
+ Task.new(:clean) do |task|
8
+ task.config[:files] = Array.new
9
+ task.define do
10
+ task.config[:files].each { |file| rm_f file }
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ require "nake/dsl"
4
+ require "nake/tasks/clean"
5
+
6
+ # register gem files for cleaning
7
+ Task[:clean].config[:files].push(*Dir["*.gem"])
8
+
9
+ # require "nake/tasks/gem"
10
+ # Task[:build].config[:gemspec] = Dir["*.gemspec"]
11
+ Task.new(:build) do |task|
12
+ task.define do
13
+ sh "gem build #{task.config[:gemspec]}"
14
+ end
15
+ end
@@ -0,0 +1,43 @@
1
+ # encoding: utf-8
2
+
3
+ require "nake/tasks/gem"
4
+
5
+ # require "nake/tasks/release"
6
+ # Task[:release].config[:version] = Nake::VERSION
7
+ task(:release, "release:tag", "release:gemcutter").tap do |task|
8
+ task.description = "Release current version version"
9
+ task.define do
10
+ puts "Version #{version} was successfuly published. Don't forget to increase VERSION constant!"
11
+ end
12
+ end
13
+
14
+ task(:prerelease).tap do |task|
15
+ task.description = "Update prerelease version"
16
+ task.define do
17
+ Task[:release].config[:version] = "#{Task[:release].config[:version]}.pre"
18
+ Task[:build].config[:gemspec] = Task[:build].config[:gemspec].sub(/\.gemspec/, ".pre.gemspec")
19
+ Task["release:gemcutter"].call
20
+ end
21
+ end
22
+
23
+ Task.new("release:tag") do |task|
24
+ task.description = "Create Git tag"
25
+ task.define do
26
+ version = Task[:release].config[:version]
27
+ raise ConfigurationError, "You have to provide Task[:release].config[:version]!" if version.nil?
28
+ puts "Creating new git tag #{version} and pushing it online ..."
29
+ sh "git tag -a -m 'Version #{version}' #{version}"
30
+ sh "git push --tags"
31
+ puts "Tag #{version} was created and pushed to GitHub."
32
+ end
33
+ end
34
+
35
+ Task.new("release:gemcutter") do |task|
36
+ task.description = "Push gem to Gemcutter"
37
+ task.dependencies = [:clean, :build]
38
+ task.define do
39
+ task.config[:gem] = "#{Task[:release].config[:name]}-#{Task[:release].config[:version]}.gem"
40
+ puts "Pushing to Gemcutter ..."
41
+ sh "gem push #{task.config[:gem]}"
42
+ end
43
+ end
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ dependencies = FileList["vendor/*/.git"].sub(/\/\.git$/, "")
4
+
5
+ desc "Regenerate deps.rip"
6
+ file "deps.rip" => dependencies do
7
+ commits = Hash.new
8
+ commits = dependencies.inject(Hash.new) do |hash, path|
9
+ Dir.chdir(path) do
10
+ revision = %x(git show | head -1).chomp.sub("commit ", "")
11
+ hash[File.basename(path)] = revision
12
+ hash
13
+ end
14
+ end
15
+ template = File.read("deps.rip.rbe")
16
+ deps_rip = eval("%Q{#{template}}")
17
+ File.open("deps.rip", "w") do |file|
18
+ file.puts(deps_rip)
19
+ end
20
+ sh "chmod +x deps.rip"
21
+ sh "git commit deps.rip -m 'Updated deps.rip'"
22
+ end
23
+
24
+ # register task
25
+ Task[:release].dependencies.unshift("deps.rip")
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+
3
+ # ./tasks.rb spec/nake/argv_spec.rb spec/nake/task_spec.rb
4
+ task(:spec) do |*paths, options|
5
+ paths.push("spec") if paths.empty?
6
+ exec "spec #{paths.join(" ")}"
7
+ end
8
+
9
+ Task.new("spec:stubs") do |task|
10
+ task.description = "Create stubs of all library files."
11
+ task.define do
12
+ Dir.glob("lib/**/*.rb").each do |file|
13
+ specfile = file.sub(/^lib/, "spec").sub(/\.rb$/, '_spec.rb')
14
+ unless File.exist?(specfile)
15
+ %x[mkdir -p #{File.dirname(specfile)}]
16
+ %x[touch #{specfile}]
17
+ puts "Created #{specfile}"
18
+ end
19
+ end
20
+ (Dir.glob("spec/rango/**/*.rb") + ["spec/rango_spec.rb"]).each do |file|
21
+ libfile = file.sub(/spec/, "lib").sub(/_spec\.rb$/, '.rb')
22
+ if !File.exist?(libfile) && File.zero?(file)
23
+ %x[rm #{file}]
24
+ puts "Removed empty file #{file}"
25
+ elsif !File.exist?(libfile)
26
+ puts "File exists just in spec, not in lib: #{file}"
27
+ end
28
+ end
29
+ end
30
+ end
data/nake.gemspec CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
34
34
  warn "You have to have changelog gem installed for post install message"
35
35
  else
36
36
  changelog = CHANGELOG.new(File.join(File.dirname(__FILE__), "CHANGELOG"))
37
- s.post_install_message = "=== Changes in the last Nake ===\n - #{changelog.last_version_changes.join("\n- ")}"
37
+ s.post_install_message = "=== Changes in the last Nake ===\n- #{changelog.last_version_changes.join("\n- ")}"
38
38
  end
39
39
 
40
40
  # RubyForge
data/tasks.rb CHANGED
@@ -1,12 +1,11 @@
1
1
  #!./bin/nake
2
2
  # encoding: utf-8
3
3
 
4
- task(:build) do
5
- sh "gem build nake.gemspec"
6
- end
4
+ require "nake/tasks/gem"
5
+ require "nake/tasks/spec"
6
+ require "nake/tasks/release"
7
7
 
8
- # ./tasks.rb spec/nake/argv_spec.rb spec/nake/task_spec.rb
9
- task(:spec) do |*paths, options|
10
- paths.push("spec") if paths.empty?
11
- exec "spec #{paths.join(" ")}"
12
- end
8
+ Task[:build].config[:gemspec] = "nake.gemspec"
9
+ Task[:prerelease].config[:gemspec] = "nake.pre.gemspec"
10
+ Task[:release].config[:name] = "nake"
11
+ Task[:release].config[:version] = Nake::VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Jakub \xC5\xA0\xC5\xA5astn\xC3\xBD aka Botanicus"
@@ -35,6 +35,7 @@ files:
35
35
  - examples/args.rb
36
36
  - examples/basic.rb
37
37
  - examples/complex.rb
38
+ - examples/configuration.rb
38
39
  - examples/default.rb
39
40
  - examples/default_proc.rb
40
41
  - examples/dependencies.rb
@@ -47,12 +48,18 @@ files:
47
48
  - lib/nake/dsl.rb
48
49
  - lib/nake/helpers.rb
49
50
  - lib/nake/task.rb
51
+ - lib/nake/tasks/bundle.rb
52
+ - lib/nake/tasks/clean.rb
53
+ - lib/nake/tasks/gem.rb
54
+ - lib/nake/tasks/release.rb
55
+ - lib/nake/tasks/rip.rb
56
+ - lib/nake/tasks/spec.rb
50
57
  - lib/nake/tasks.rb
51
58
  - lib/nake.rb
52
59
  - LICENSE
53
- - nake-0.0.1.gem
54
60
  - nake.gemspec
55
61
  - nake.pre.gemspec
62
+ - Rakefile
56
63
  - README.textile
57
64
  - spec/nake/argv_spec.rb
58
65
  - spec/nake/colors_spec.rb
@@ -71,14 +78,7 @@ licenses: []
71
78
 
72
79
  post_install_message: |-
73
80
  === Changes in the last Nake ===
74
- - bin/nake executable
75
- - sh helper (nake/helpers)
76
- - task helper (nake/dsl)
77
- - Task with description, dependencies and blocks
78
- - Hidden tasks
79
- - Each task can has multiple aliases
80
- - Command line arguments parsing. Arguments will be passed as an arguments for blocks of the given task and options will be extracted into a hash, parsed into Ruby data types and passed as the last argument for the blocks.
81
- - Default tasks for help (-H, --help), list of available tasks (-T, --tasks) and interactive session (-i, --interactive)
81
+ - Support for configuration
82
82
  rdoc_options: []
83
83
 
84
84
  require_paths:
@@ -91,9 +91,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
91
  version:
92
92
  required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - ">"
95
95
  - !ruby/object:Gem::Version
96
- version: "0"
96
+ version: 1.3.1
97
97
  version:
98
98
  requirements: []
99
99