buildem 0.0.2

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.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/EXAMPLE ADDED
@@ -0,0 +1,16 @@
1
+ $configuration.workers = 2
2
+
3
+ run "initialize.sh"
4
+ run "clean.sh"
5
+
6
+ unorderd do
7
+ queued_run "build.sh"
8
+ queued_run "checkin.sh"
9
+ queued_run "publish.sh"
10
+ run "some_task_in_the_middle_of_queue.sh" # this will block all of the queued_run calls after this
11
+ queued_run "build.sh"
12
+ queued_run "checkin.sh"
13
+ queued_run "publish.sh"
14
+ end
15
+
16
+ run "do_something_at_the_end.sh"
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in buildem.gemspec
4
+ gemspec
data/README ADDED
@@ -0,0 +1,46 @@
1
+ Build'em quick, Build'em right
2
+
3
+ Build'em is a small little script parser that is intended for large build systems.
4
+ Build'em is still very young :) so be careful using it. Input is always welcome and if there is a feature that you just half to have i'd probably do it.
5
+
6
+
7
+ Features:
8
+
9
+ Execution:
10
+ Scripts go in a plain text file, I use my_very_important_task.buildem
11
+ and then simply call buildem my_very_important_task.buildem
12
+
13
+ 1) Build'em supports sequential tasks (tasks that go in order)
14
+
15
+ Example:
16
+ run "./task.sh"
17
+ run "./another.sh" #another.sh waits for task.sh to complete
18
+
19
+ 2) Build'em supports a work queue, what does this mean?
20
+ This means that you can run tasks concurrently, easily.
21
+
22
+ Example:
23
+
24
+ unorderd do
25
+ queued_run "./some_task.sh"
26
+ queued_run "./some_task1.sh" # All of these items will be executed at the same time
27
+ queued_run "./some_task2.sh"
28
+ end
29
+
30
+
31
+ *IMPORTANT* All queued_run tasks must be inside of an unorderd block if you want them to run at the same time. If you use run for a task, it will block to complete.
32
+ That being said you can inject ordered tasks in the middle of unorderd tasks by using run instead of using qeueued_run if you wish to.
33
+
34
+
35
+ 3) Configuration
36
+ To set the worker amount for unorderd tasks before the unorderd block do $configuration.workers = 10 to get 10 nano-bots working for you.
37
+
38
+ Example:
39
+ $configuration.workers = 5
40
+ unorderd do
41
+ ....
42
+ end
43
+
44
+ This will give you 5 nano-bots for your unordered tasks
45
+
46
+
@@ -0,0 +1,19 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require "rspec/core/rake_task"
5
+ namespace :spec do
6
+
7
+ desc "Run all of the system specs. [spec=system/foo.rb]"
8
+ RSpec::Core::RakeTask.new(:system) do |spec|
9
+ spec.pattern = 'spec/system/*_spec.rb'
10
+ spec.rspec_opts = ['--color']
11
+ end
12
+
13
+ desc "Run all of the unit specs. [spec=unit/foo.rb]"
14
+ RSpec::Core::RakeTask.new(:test) do |spec|
15
+ spec.pattern = 'spec/unit/*_spec.rb'
16
+ spec.rspec_opts = ['--color']
17
+ end
18
+
19
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby -*-
3
+
4
+ require 'rubygems'
5
+ require 'buildem/runner'
6
+ BuildEm::Runner.start
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "buildem/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "buildem"
7
+ s.version = BuildEm::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Jeremy W. Rowe"]
10
+ s.email = ["jeremy.w.rowe@gmail.com"]
11
+ s.homepage = "http://github.com/jeremywrowe/buildem"
12
+ s.summary = %q{A simple build script wrapper that allows for concurent tasks}
13
+ s.add_dependency('process_pool', '>= 0.1.3')
14
+ s.add_development_dependency('rspec')
15
+
16
+ s.rubyforge_project = "buildem"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+ end
@@ -0,0 +1,4 @@
1
+
2
+ class BuildEm
3
+
4
+ end
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require "buildem"
3
+
4
+ def windows?
5
+ return java.lang.System.get_property("os.name")[/windows/i] if RUBY_PLATFORM == "java"
6
+ return RUBY_PLATFORM[/mswin/]
7
+ end
@@ -0,0 +1,16 @@
1
+ # configuration.workers 2
2
+ # configuration.output_file "output.out"
3
+ # configuration.error_file "errors.out"
4
+
5
+ class BuildEm::Configuration
6
+
7
+ attr_accessor :workers, :output_file, :error_file, :run_output
8
+
9
+ def initialize(optz={})
10
+ @workers ||= (optz[:workers] || 2)
11
+ @output_file ||= (optz[:output_file] || "output.out")
12
+ @error_file ||= (optz[:error_file] || "error.out")
13
+ @run_output ||= optz[:run_output]
14
+ end
15
+
16
+ end
@@ -0,0 +1,31 @@
1
+ require "buildem/base"
2
+
3
+ class BuildEm::Executor
4
+
5
+ attr_accessor :argz
6
+
7
+ def initialize(args)
8
+ @argz ||= args
9
+ end
10
+
11
+ def name
12
+ BuildEm::Executor
13
+ end
14
+
15
+ def run
16
+ # queued_run "publish.sh", :output => "publish_output.out", :errors => "publish_errors.out"
17
+ begin
18
+ puts `#{argz[0]} #{redirect_standard_err_and_out}`
19
+ rescue Exception => e
20
+ puts e
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def redirect_standard_err_and_out
27
+ ""
28
+ end
29
+
30
+
31
+ end
@@ -0,0 +1,58 @@
1
+ require "buildem"
2
+ require 'buildem/base'
3
+ require 'buildem/configuration'
4
+ require 'buildem/executor'
5
+ require 'process_pool'
6
+
7
+ module Kernel
8
+ def unorderd
9
+ puts "Started unordered sequence"
10
+ yield
11
+ $pool = ProcessPool.new($configuration.workers)
12
+ puts $configuration.workers
13
+ $jobs.each do |command|
14
+ $pool.schedule(command,command.argz)
15
+ end
16
+ $pool.start
17
+ $pool.shutdown
18
+ end
19
+
20
+ def queued_run(command, optz = {})
21
+ optz = {:foo => "bar", :moo => "cow"}
22
+ $jobs << BuildEm::Executor.new([command,optz])
23
+ end
24
+
25
+ def run(command, optz = {})
26
+ BuildEm::Executor.new([command,optz]).run
27
+ end
28
+ end
29
+
30
+ class BuildEm::Runner
31
+ $jobs = []
32
+ def self.start
33
+ if ARGV.size == 1
34
+ puts "running #{ARGV[0]}"
35
+ $configuration = BuildEm::Configuration.new
36
+ load ARGV[0]
37
+ puts "finished #{ARGV[0]}"
38
+ else
39
+ puts usage
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ def self.usage
46
+ <<-USAGE
47
+
48
+ -----------------------------------------------------------------
49
+ BUILD'EM
50
+ -----------------------------------------------------------------
51
+
52
+ usage: buildem filename.buildem
53
+
54
+ -----------------------------------------------------------------
55
+ USAGE
56
+ end
57
+
58
+ end
@@ -0,0 +1,4 @@
1
+
2
+ class BuildEm::Validator
3
+
4
+ end
@@ -0,0 +1,3 @@
1
+ class BuildEm
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,44 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+ require 'buildem'
4
+ require 'rspec'
5
+
6
+ $SPEC_ROOT = File.expand_path(File.dirname(__FILE__))
7
+
8
+ def require_files filename
9
+ filename.each do |file|
10
+ require "#{$SPEC_ROOT}/../lib/buildem/#{file}"
11
+ end if filename.class == Array
12
+ require "#{$SPEC_ROOT}/../lib/buildem/#{filename}" if filename.class == String
13
+ end
14
+
15
+ def within path
16
+ cd path do
17
+ yield
18
+ end
19
+ end
20
+
21
+ RSpec.configure do |config|
22
+ def capture(stream)
23
+ begin
24
+ stream = stream.to_s
25
+ eval "$#{stream} = StringIO.new"
26
+ yield
27
+ result = eval("$#{stream}").string
28
+ ensure
29
+ eval("$#{stream} = #{stream.upcase}")
30
+ end
31
+
32
+ result
33
+ end
34
+
35
+ def source_root
36
+ File.join(File.dirname(__FILE__), 'fixtures')
37
+ end
38
+
39
+ def destination_root
40
+ File.join(File.dirname(__FILE__), 'sandbox')
41
+ end
42
+
43
+ alias :silence :capture
44
+ end
@@ -0,0 +1,78 @@
1
+ require File.expand_path(File.dirname(__FILE__)+"/../helper.rb")
2
+ require_files "configuration"
3
+
4
+ # configuration.workers 2
5
+ # configuration.output_file "output.out"
6
+ # configuration.error_file "errors.out"
7
+
8
+ describe BuildEm::Configuration, "workers" do
9
+
10
+ it "has a default worker of 2" do
11
+ BuildEm::Configuration.new.workers.should eq 2
12
+ end
13
+
14
+ it "sets workers through initilization" do
15
+ BuildEm::Configuration.new(:workers => 99).workers.should eq 99
16
+ end
17
+
18
+ it "sets workers" do
19
+ config = BuildEm::Configuration.new
20
+ config.workers = 55
21
+ config.workers.should eq 55
22
+ end
23
+
24
+ end
25
+
26
+ describe BuildEm::Configuration, "output_file" do
27
+
28
+ it "has a default output_file of output.out" do
29
+ BuildEm::Configuration.new.output_file.should eq "output.out"
30
+ end
31
+
32
+ it "sets output_file through initilization" do
33
+ BuildEm::Configuration.new(:output_file => "go.daddy").output_file.should eq "go.daddy"
34
+ end
35
+
36
+ it "sets output_file" do
37
+ config = BuildEm::Configuration.new
38
+ config.output_file = "foo.bar"
39
+ config.output_file.should eq "foo.bar"
40
+ end
41
+
42
+ end
43
+
44
+ describe BuildEm::Configuration, "error_file" do
45
+
46
+ it "has a default error_file of error.out" do
47
+ BuildEm::Configuration.new.error_file.should eq "error.out"
48
+ end
49
+
50
+ it "sets error_file through initilization" do
51
+ BuildEm::Configuration.new(:error_file => "slow.down").error_file.should eq "slow.down"
52
+ end
53
+
54
+ it "sets error_file" do
55
+ config = BuildEm::Configuration.new
56
+ config.error_file = "foo.bar"
57
+ config.error_file.should eq "foo.bar"
58
+ end
59
+
60
+ end
61
+
62
+ describe BuildEm::Configuration, "run_output" do
63
+
64
+ it "has a default run_output of nil" do
65
+ BuildEm::Configuration.new.run_output.should eq nil
66
+ end
67
+
68
+ it "sets run_output through initilization" do
69
+ BuildEm::Configuration.new(:run_output => "execution_log").run_output.should eq "execution_log"
70
+ end
71
+
72
+ it "sets run_output" do
73
+ config = BuildEm::Configuration.new
74
+ config.run_output = "foo.bar"
75
+ config.run_output.should eq "foo.bar"
76
+ end
77
+
78
+ end
@@ -0,0 +1,20 @@
1
+ $configuration.output_file = "my_output.file"
2
+ $configuration.workers = 2
3
+ $configuration.error_file = "errorz"
4
+
5
+ # don't do this!
6
+
7
+ run "initialize.sh"
8
+ run "clean.sh"
9
+
10
+
11
+ unorderd do
12
+ queued_run "build.sh"
13
+ queued_run "checkin.sh"
14
+ queued_run "publish.sh", :output => "publish_output.out", :errors => "publish_errors.out", :args => ["1", 2, "3"]
15
+ end
16
+
17
+ puts "waiting for things to stop"
18
+
19
+ run "do_something_at_the_end.sh"
20
+
@@ -0,0 +1,6 @@
1
+
2
+ unorderd do
3
+ queued_run "build.sh"
4
+ queued_run "checkin.sh"
5
+ queued_run "publish.sh", :output => "publish_output.out", :errors => "publish_errors.out"
6
+ end
@@ -0,0 +1,9 @@
1
+ $configuration.output_file = "my_output.file"
2
+ $configuration.workers = 10
3
+ $configuration.error_file = "errorz"
4
+
5
+ unorderd do
6
+ queued_run "build.sh"
7
+ queued_run "checkin.sh"
8
+ queued_run "publish.sh", :output => "publish_output.out", :errors => "publish_errors.out"
9
+ end
@@ -0,0 +1,3 @@
1
+ run "initialize.sh"
2
+ run "clean.sh"
3
+ run "do_something_at_the_end.sh"
@@ -0,0 +1,9 @@
1
+ @configuration.output_file "my_output.file"
2
+ @configuration.workers 2
3
+ @configuration.error_file "errorz"
4
+
5
+ # don't do this!
6
+
7
+ run "initialize.sh"
8
+ run "clean.sh"
9
+ run "do_something_at_the_end.sh"
@@ -0,0 +1,7 @@
1
+ @configuration.output_file "my_output.file"
2
+ @configuration.workers 2
3
+ @configuration.error_file "errorz"
4
+
5
+ run "initialize.sh"
6
+ run "clean.sh"
7
+ run "do_something_at_the_end.sh"
@@ -0,0 +1,49 @@
1
+ require File.expand_path(File.dirname(__FILE__)+"/../helper.rb")
2
+ require_files "runner"
3
+
4
+ describe BuildEm::Runner, "start" do
5
+
6
+ it "runs the program" do
7
+ ARGV.replace ["#{here}/helper/examples/blank_file.buildem"]
8
+ capture(:stdout) {BuildEm::Runner.start}.strip.should == "running #{here}/helper/examples/blank_file.buildem\nfinished #{here}/helper/examples/blank_file.buildem"
9
+ end
10
+
11
+ it "runs the program" do
12
+ ARGV.replace ["#{here}/helper/examples/not_there.buildem"]
13
+ lambda { capture(:stdout) {BuildEm::Runner.start} }.should raise_error(LoadError)
14
+ end
15
+
16
+ it "spits out usage when the user doesn't supply a filename" do
17
+ ARGV.replace []
18
+ capture(:stdout) {BuildEm::Runner.start}.should == usage_banner
19
+ end
20
+
21
+ describe "execution flow" do
22
+
23
+ before do
24
+
25
+ end
26
+
27
+ end
28
+
29
+ private
30
+
31
+ def here
32
+ File.expand_path(File.dirname(__FILE__))
33
+ end
34
+
35
+ def usage_banner
36
+ <<-USAGE
37
+
38
+ -----------------------------------------------------------------
39
+ BUILD'EM
40
+ -----------------------------------------------------------------
41
+
42
+ usage: buildem filename.buildem
43
+
44
+ -----------------------------------------------------------------
45
+ USAGE
46
+
47
+ end
48
+
49
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: buildem
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
11
+ platform: ruby
12
+ authors:
13
+ - Jeremy W. Rowe
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-19 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: process_pool
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 29
30
+ segments:
31
+ - 0
32
+ - 1
33
+ - 3
34
+ version: 0.1.3
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: rspec
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :development
50
+ version_requirements: *id002
51
+ description:
52
+ email:
53
+ - jeremy.w.rowe@gmail.com
54
+ executables:
55
+ - buildem
56
+ extensions: []
57
+
58
+ extra_rdoc_files: []
59
+
60
+ files:
61
+ - .gitignore
62
+ - EXAMPLE
63
+ - Gemfile
64
+ - README
65
+ - Rakefile
66
+ - bin/buildem
67
+ - buildem.gemspec
68
+ - lib/buildem.rb
69
+ - lib/buildem/base.rb
70
+ - lib/buildem/configuration.rb
71
+ - lib/buildem/executor.rb
72
+ - lib/buildem/runner.rb
73
+ - lib/buildem/validator.rb
74
+ - lib/buildem/version.rb
75
+ - spec/helper.rb
76
+ - spec/unit/configuration_spec.rb
77
+ - spec/unit/helper/examples/blank_file.buildem
78
+ - spec/unit/helper/examples/everything.buildem
79
+ - spec/unit/helper/examples/nonsequential.buildem
80
+ - spec/unit/helper/examples/nonsequential_with_config.buildem
81
+ - spec/unit/helper/examples/sequential.buildem
82
+ - spec/unit/helper/examples/sequential_with_comments.buildem
83
+ - spec/unit/helper/examples/sequential_with_config.buildem
84
+ - spec/unit/runner_spec.rb
85
+ has_rdoc: true
86
+ homepage: http://github.com/jeremywrowe/buildem
87
+ licenses: []
88
+
89
+ post_install_message:
90
+ rdoc_options: []
91
+
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ hash: 3
100
+ segments:
101
+ - 0
102
+ version: "0"
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ hash: 3
109
+ segments:
110
+ - 0
111
+ version: "0"
112
+ requirements: []
113
+
114
+ rubyforge_project: buildem
115
+ rubygems_version: 1.6.1
116
+ signing_key:
117
+ specification_version: 3
118
+ summary: A simple build script wrapper that allows for concurent tasks
119
+ test_files:
120
+ - spec/helper.rb
121
+ - spec/unit/configuration_spec.rb
122
+ - spec/unit/helper/examples/blank_file.buildem
123
+ - spec/unit/helper/examples/everything.buildem
124
+ - spec/unit/helper/examples/nonsequential.buildem
125
+ - spec/unit/helper/examples/nonsequential_with_config.buildem
126
+ - spec/unit/helper/examples/sequential.buildem
127
+ - spec/unit/helper/examples/sequential_with_comments.buildem
128
+ - spec/unit/helper/examples/sequential_with_config.buildem
129
+ - spec/unit/runner_spec.rb