backofen 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ === 0.0.1 2009-10-21
2
+
3
+ * 1 major enhancement:
4
+ * Initial proof-of-concept release
data/Manifest.txt ADDED
@@ -0,0 +1,18 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.rdoc
4
+ Rakefile
5
+ backofen.gemspec
6
+ bin/backofen
7
+ lib/backofen.rb
8
+ lib/backofen/cli.rb
9
+ lib/backofen/prototype.rb
10
+ path/var/folders/zT/zTM6lYZhGpaRrYEeDiGZJ++++TI/-Tmp-/d20091021-7842-1se7ikinametmp_clone/test1
11
+ script/console
12
+ script/destroy
13
+ script/generate
14
+ spec/backofen_cli_spec.rb
15
+ spec/backofen_spec.rb
16
+ spec/spec.opts
17
+ spec/spec_helper.rb
18
+ tasks/rspec.rake
data/README.rdoc ADDED
@@ -0,0 +1,55 @@
1
+ = backofen
2
+
3
+ * http://github.com/rubyphunk/backofen
4
+
5
+ == DESCRIPTION:
6
+
7
+ Backofen is Distributed Continious Integration node that verifies your changes against an upstream repository by running specs and features against it.
8
+ Its intended to be used as pre-commit hook.
9
+
10
+
11
+ == FEATURES/PROBLEMS:
12
+
13
+ Backofen is currently just a proof of concept. Yes, its working (at least for me) but needs a lot more development time.
14
+
15
+ == SYNOPSIS:
16
+
17
+ Your pre-commit hook should look like that:
18
+
19
+ #!/bin/sh
20
+ backofen -p $(pwd)
21
+
22
+
23
+ == REQUIREMENTS:
24
+
25
+ gem: git >= 1.2.5
26
+
27
+
28
+ == INSTALL:
29
+
30
+ gem install backofen --source http://gemcutter.org
31
+
32
+ == LICENSE:
33
+
34
+ (The MIT License)
35
+
36
+ Copyright (c) 2009 Andreas Wolff
37
+
38
+ Permission is hereby granted, free of charge, to any person obtaining
39
+ a copy of this software and associated documentation files (the
40
+ 'Software'), to deal in the Software without restriction, including
41
+ without limitation the rights to use, copy, modify, merge, publish,
42
+ distribute, sublicense, and/or sell copies of the Software, and to
43
+ permit persons to whom the Software is furnished to do so, subject to
44
+ the following conditions:
45
+
46
+ The above copyright notice and this permission notice shall be
47
+ included in all copies or substantial portions of the Software.
48
+
49
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
50
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
51
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
52
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
53
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
54
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
55
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/backofen'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'backofen' do
14
+ self.developer 'Andreas Wolff', 'rubyphunk@googlemail.com'
15
+ self.rubyforge_name = self.name # TODO this is default value
16
+ self.extra_deps = [['git','>= 1.2.5']]
17
+
18
+ end
19
+
20
+ require 'newgem/tasks'
21
+ Dir['tasks/**/*.rake'].each { |t| load t }
22
+
23
+ # TODO - want other tests/tasks run by default? Add them to the list
24
+ # remove_task :default
25
+ # task :default => [:spec, :features]
data/backofen.gemspec ADDED
@@ -0,0 +1,39 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{backofen}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Andreas Wolff"]
9
+ s.date = %q{2009-10-21}
10
+ s.default_executable = %q{backofen}
11
+ s.description = %q{Backofen is Distributed Continious Integration node that verifies your changes against an upstream repository by running specs and features against it.
12
+ Its intended to be used as pre-commit hook.}
13
+ s.email = ["rubyphunk@googlemail.com"]
14
+ s.executables = ["backofen"]
15
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
16
+ s.files = ["History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "backofen.gemspec", "bin/backofen", "lib/backofen.rb", "lib/backofen/cli.rb", "lib/backofen/prototype.rb", "path/var/folders/zT/zTM6lYZhGpaRrYEeDiGZJ++++TI/-Tmp-/d20091021-7842-1se7ikinametmp_clone/test1", "script/console", "script/destroy", "script/generate", "spec/backofen_cli_spec.rb", "spec/backofen_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake"]
17
+ s.homepage = %q{http://github.com/rubyphunk/backofen}
18
+ s.rdoc_options = ["--main", "README.rdoc"]
19
+ s.require_paths = ["lib"]
20
+ s.rubyforge_project = %q{backofen}
21
+ s.rubygems_version = %q{1.3.5}
22
+ s.summary = %q{Backofen is Distributed Continious Integration node that verifies your changes against an upstream repository by running specs and features against it}
23
+
24
+ if s.respond_to? :specification_version then
25
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
26
+ s.specification_version = 3
27
+
28
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
29
+ s.add_runtime_dependency(%q<git>, [">= 1.2.5"])
30
+ s.add_development_dependency(%q<hoe>, [">= 2.3.3"])
31
+ else
32
+ s.add_dependency(%q<git>, [">= 1.2.5"])
33
+ s.add_dependency(%q<hoe>, [">= 2.3.3"])
34
+ end
35
+ else
36
+ s.add_dependency(%q<git>, [">= 1.2.5"])
37
+ s.add_dependency(%q<hoe>, [">= 2.3.3"])
38
+ end
39
+ end
data/bin/backofen ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created on 2009-10-20.
4
+ # Copyright (c) 2009. All rights reserved.
5
+
6
+ require 'rubygems'
7
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/backofen")
8
+ require "backofen/cli"
9
+
10
+ Backofen::CLI.execute(STDOUT, ARGV)
data/lib/backofen.rb ADDED
@@ -0,0 +1,8 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ module Backofen
5
+ VERSION = '0.0.1'
6
+
7
+ autoload :Prototype, 'backofen/prototype'
8
+ end
@@ -0,0 +1,41 @@
1
+ require 'optparse'
2
+
3
+ module Backofen
4
+ class CLI
5
+ def self.execute(stdout, arguments=[])
6
+
7
+ # NOTE: the option -p/--path= is given as an example, and should be replaced in your application.
8
+
9
+ options = {
10
+ :path => '~'
11
+ }
12
+ mandatory_options = %w( )
13
+
14
+ parser = OptionParser.new do |opts|
15
+ opts.banner = <<-BANNER.gsub(/^ /,'')
16
+ This application is wonderful because...
17
+
18
+ Usage: #{File.basename($0)} [options]
19
+
20
+ Options are:
21
+ BANNER
22
+ opts.separator ""
23
+ opts.on("-p", "--path=PATH", String,
24
+ "This is a sample message.",
25
+ "For multiple lines, add more strings.",
26
+ "Default: ~") { |arg| options[:path] = arg }
27
+ opts.on("-h", "--help",
28
+ "Show this help message.") { stdout.puts opts; exit }
29
+ opts.parse!(arguments)
30
+
31
+ if mandatory_options && mandatory_options.find { |option| options[option.to_sym].nil? }
32
+ stdout.puts opts; exit
33
+ end
34
+ end
35
+
36
+ path = options[:path]
37
+
38
+ Backofen::Prototype.run(path)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,51 @@
1
+ require 'git'
2
+ require 'tmpdir'
3
+
4
+ module Backofen
5
+ module Prototype
6
+ class << self
7
+ def run(path)
8
+ # Get Repository url
9
+ repo = Git.open(path)
10
+ url = repo.remotes.first.url
11
+
12
+ # Clone Repository to Tmp Directory
13
+ puts "Cloning from #{url}.."
14
+ d = Dir.mktmpdir
15
+ tmp_repo = Git.clone(url, 'tmp_clone', :path => d)
16
+ tmp_repo_path = tmp_repo.dir.path
17
+ puts "Cloned to: #{tmp_repo_path}"
18
+
19
+ # Create local patches (working, index)
20
+ patch_working_file_path = File.join(tmp_repo_path, 'patch_working')
21
+ patch_index_file_path = File.join(tmp_repo_path, 'patch_index')
22
+
23
+ puts "Creating patches.."
24
+ %x(cd #{path} && git diff -p > patch_working)
25
+ %x(cd #{path} && git diff --cached -p > patch_index)
26
+
27
+ # Apply patches to tmp clone
28
+ %x(mv #{path}/patch_working #{patch_working_file_path})
29
+ %x(mv #{path}/patch_index #{patch_index_file_path})
30
+
31
+ puts "Applying patches.."
32
+ %x(cd #{tmp_repo_path} && git apply patch_working)
33
+ %x(cd #{tmp_repo_path} && git apply patch_index)
34
+
35
+ # Prepare Rails
36
+ if File.exist?(File.join(path, 'config', 'database.yml'))
37
+ puts "Found a Rails application.."
38
+ # Simply the most beautiful way to determine a Rails app
39
+ %x(cp #{path}/config/database.yml #{tmp_repo_path}/config/)
40
+ end
41
+
42
+ # Run rspec && cucumber
43
+ system("cd #{tmp_repo_path} && rake db:migrate && rake spec && rake cucumber")
44
+
45
+ # Return result
46
+ puts $?.exitstatus == 0 ? 'Integration succeeded' : 'Integration failed'
47
+ exit($?.exitstatus)
48
+ end
49
+ end
50
+ end
51
+ end
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/backofen.rb'}"
9
+ puts "Loading backofen gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,15 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require 'backofen/cli'
3
+
4
+ describe Backofen::CLI, "execute" do
5
+ before(:each) do
6
+ @stdout_io = StringIO.new
7
+ Backofen::CLI.execute(@stdout_io, [])
8
+ @stdout_io.rewind
9
+ @stdout = @stdout_io.read
10
+ end
11
+
12
+ it "should print default output" do
13
+ @stdout.should =~ /To update this executable/
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ # Time to add your specs!
4
+ # http://rspec.info/
5
+ describe "Place your specs here" do
6
+
7
+ it "find this spec in spec directory" do
8
+ # violated "Be sure to write your specs"
9
+ end
10
+
11
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,10 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
10
+ require 'backofen'
data/tasks/rspec.rake ADDED
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
5
+ require 'spec'
6
+ end
7
+ begin
8
+ require 'spec/rake/spectask'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use rspec for testing you must install rspec gem:
12
+ gem install rspec
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ desc "Run the specs under spec/models"
18
+ Spec::Rake::SpecTask.new do |t|
19
+ t.spec_opts = ['--options', "spec/spec.opts"]
20
+ t.spec_files = FileList['spec/**/*_spec.rb']
21
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: backofen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andreas Wolff
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-21 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: git
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.2.5
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: hoe
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.3.3
34
+ version:
35
+ description: |-
36
+ Backofen is Distributed Continious Integration node that verifies your changes against an upstream repository by running specs and features against it.
37
+ Its intended to be used as pre-commit hook.
38
+ email:
39
+ - rubyphunk@googlemail.com
40
+ executables:
41
+ - backofen
42
+ extensions: []
43
+
44
+ extra_rdoc_files:
45
+ - History.txt
46
+ - Manifest.txt
47
+ files:
48
+ - History.txt
49
+ - Manifest.txt
50
+ - README.rdoc
51
+ - Rakefile
52
+ - backofen.gemspec
53
+ - bin/backofen
54
+ - lib/backofen.rb
55
+ - lib/backofen/cli.rb
56
+ - lib/backofen/prototype.rb
57
+ - path/var/folders/zT/zTM6lYZhGpaRrYEeDiGZJ++++TI/-Tmp-/d20091021-7842-1se7ikinametmp_clone/test1
58
+ - script/console
59
+ - script/destroy
60
+ - script/generate
61
+ - spec/backofen_cli_spec.rb
62
+ - spec/backofen_spec.rb
63
+ - spec/spec.opts
64
+ - spec/spec_helper.rb
65
+ - tasks/rspec.rake
66
+ has_rdoc: true
67
+ homepage: http://github.com/rubyphunk/backofen
68
+ licenses: []
69
+
70
+ post_install_message:
71
+ rdoc_options:
72
+ - --main
73
+ - README.rdoc
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: "0"
81
+ version:
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: "0"
87
+ version:
88
+ requirements: []
89
+
90
+ rubyforge_project: backofen
91
+ rubygems_version: 1.3.5
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: Backofen is Distributed Continious Integration node that verifies your changes against an upstream repository by running specs and features against it
95
+ test_files: []
96
+