kikubari 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", "~> 1.3.1"
10
+ gem "bundler"
11
+ gem "jeweler", "~> 1.8.3"
12
+ gem "rcov", ">= 0"
13
+ gem 'git'
14
+ end
@@ -0,0 +1,25 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.8.3)
6
+ bundler (~> 1.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rdoc
10
+ json (1.6.4)
11
+ rake (0.9.2.2)
12
+ rcov (0.9.11)
13
+ rdoc (3.12)
14
+ json (~> 1.4)
15
+ rspec (1.3.1)
16
+
17
+ PLATFORMS
18
+ ruby
19
+
20
+ DEPENDENCIES
21
+ bundler
22
+ git
23
+ jeweler (~> 1.8.3)
24
+ rcov
25
+ rspec (~> 1.3.1)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Jose Antonio Pio Gil
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ = kikubari
2
+
3
+ Naive deploy system for deploy agnostic code. Kikubari only take care about repository, folder structure and file configurations. It also will run before an after task from commmand line and log it to the deployment log.
4
+
5
+ Usage:
6
+
7
+ * Create a deploy.yml file in your deploy folder
8
+ * Run deploy "path_folder" "environment"
9
+ * Have a beer and see it work
10
+
11
+
12
+ == Contributing to kikubari
13
+
14
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
15
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
16
+ * Fork the project.
17
+ * Start a feature/bugfix branch.
18
+ * Commit and push until you are happy with your contribution.
19
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
20
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
21
+
22
+ == Copyright
23
+
24
+ Copyright (c) 2012 Jose Antonio Pio Gil. See LICENSE.txt for further details.
25
+
@@ -0,0 +1,58 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "kikubari"
18
+ gem.homepage = "https://github.com/josetonyp/kikubari"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{ Naive multiframework deploy system }
21
+ gem.description = %Q{ Naive multiframework deployer for handle server deployments with some care about the code replacement. Also an experimental project.}
22
+ gem.email = "josetonyp@latizana.com"
23
+ gem.authors = ["Jose Antonio Pio Gil"]
24
+
25
+ gem.bindir = 'bin'
26
+ gem.executables = ['kikubari']
27
+ gem.default_executable = 'kikubari'
28
+
29
+ # dependencies defined in Gemfile
30
+ end
31
+ Jeweler::RubygemsDotOrgTasks.new
32
+
33
+ require 'rake/testtask'
34
+ Rake::TestTask.new(:test) do |test|
35
+ test.libs << 'lib' << 'test'
36
+ test.pattern = 'test/**/test_*.rb'
37
+ test.verbose = true
38
+ end
39
+
40
+ require 'rcov/rcovtask'
41
+ Rcov::RcovTask.new do |test|
42
+ test.libs << 'test'
43
+ test.pattern = 'test/**/test_*.rb'
44
+ test.verbose = true
45
+ test.rcov_opts << '--exclude "gems/*"'
46
+ end
47
+
48
+ task :default => :test
49
+
50
+ require 'rdoc/task'
51
+ Rake::RDocTask.new do |rdoc|
52
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
53
+
54
+ rdoc.rdoc_dir = 'rdoc'
55
+ rdoc.title = "kikubari #{version}"
56
+ rdoc.rdoc_files.include('README*')
57
+ rdoc.rdoc_files.include('lib/**/*.rb')
58
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env ruby
2
+ require 'date'
3
+ require 'getoptlong'
4
+ require 'fileutils'
5
+ require 'yaml'
6
+ require 'pathname'
7
+ require "stringio"
8
+ require 'open3'
9
+ require 'git'
10
+
11
+ #Dir[ File.join(File.dirname(__FILE__), *%w[.. lib ** *]) ].each{ |file| require file unless File.directory? file }
12
+
13
+ require "lib/configuration/deploy_configuration"
14
+ require "lib/deploy_dir"
15
+ require "lib/deploy_logger"
16
+ require "lib/kikubari"
17
+ require "lib/deployer/deployer"
18
+ require "lib/deployer/deployer_git"
19
+ require "lib/deployer/deployer_git_symfony"
20
+ require "lib/deployer/deployer_git_wordpress"
21
+
22
+
23
+ ##Globals
24
+ debug, dry_run, rollback = false, false, false
25
+ parser = GetoptLong.new
26
+
27
+ parser.set_options( ["-D", "--debug", GetoptLong::NO_ARGUMENT],
28
+ ["-d", "--dry", GetoptLong::NO_ARGUMENT],
29
+ ["-b", "--rollback", GetoptLong::NO_ARGUMENT]
30
+ )
31
+
32
+ loop do
33
+ begin
34
+ opt, arg = parser.get
35
+ break if not opt
36
+
37
+ case opt
38
+ when "-D"
39
+ debug = true;
40
+ break
41
+ when "-d"
42
+ dry_run = true;
43
+ when "-b"
44
+ rollback = true;
45
+ end
46
+
47
+ rescue => err
48
+ break
49
+ end
50
+ end
51
+
52
+ if (!ARGV.first.nil? and File.directory? ARGV.first.to_s)
53
+ folder = ARGV.first.to_s
54
+ else
55
+
56
+ begin
57
+
58
+ print "Please insert the project folder to deploy: "
59
+ folder = gets.chomp
60
+
61
+ end until begin
62
+
63
+ ##FileUtils.cd folder
64
+ puts "Deploying to #{folder}"
65
+ true
66
+ rescue Exception => e
67
+ print e.message
68
+ puts e.backtrace.inspect
69
+ false
70
+ end
71
+
72
+ end
73
+
74
+
75
+ p "Deploying to #{ Pathname.new( folder ).realpath }/..."
76
+
77
+
78
+ if( !ARGV[1].nil? )
79
+
80
+ env_folder = ARGV[1].to_s
81
+
82
+ else
83
+
84
+ begin
85
+
86
+ print "Production [1] or preproduction [2] ? (1,2) : "
87
+ environment = gets.chomp
88
+
89
+ end until begin
90
+ if environment =~ /1|2/
91
+ true
92
+ else
93
+ false
94
+ end
95
+ rescue Exception => e
96
+ print e.message
97
+ puts e.backtrace.inspect
98
+ false
99
+ end
100
+
101
+ case environment
102
+ when "1"
103
+ env_folder = "production"
104
+ when "2"
105
+ env_folder = "preproduction"
106
+ end
107
+
108
+ end
109
+
110
+ p "Deploying on environment < #{ env_folder } >..."
111
+
112
+ Kikubari::Deploy.new(Kikubari::Deploy::Configuration.new( "#{folder}/deploy.yml", :deploy_folder => folder, :debug => debug, :dry_run => dry_run , :environment => env_folder, :rollback => rollback ))
113
+
@@ -0,0 +1,83 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "kikubari"
8
+ s.version = "0.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jose Antonio Pio Gil"]
12
+ s.date = "2012-05-23"
13
+ s.description = " Naive multiframework deployer for handle server deployments with some care about the code replacement. Also an experimental project."
14
+ s.email = "josetonyp@latizana.com"
15
+ s.executables = ["kikubari"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/kikubari",
29
+ "kikubari.gemspec",
30
+ "lib/configuration/deploy_configuration.rb",
31
+ "lib/deploy_dir.rb",
32
+ "lib/deploy_logger.rb",
33
+ "lib/deployer/deployer.rb",
34
+ "lib/deployer/deployer_git.rb",
35
+ "lib/deployer/deployer_git_symfony.rb",
36
+ "lib/deployer/deployer_git_wordpress.rb",
37
+ "lib/kikubari.rb",
38
+ "test/deploy_files/databases.yml",
39
+ "test/deploy_files/deploy.yml",
40
+ "test/deploy_files/deploy_git.yml",
41
+ "test/deploy_files/deploy_git_test_file.yml",
42
+ "test/deploy_files/deploy_symlink.yml",
43
+ "test/deploy_files/empty.yml",
44
+ "test/deploy_files/one_file_test.yml",
45
+ "test/deploy_files/one_folder.yml",
46
+ "test/helper.rb",
47
+ "test/lib/deploy_spec.rb",
48
+ "test/lib/deployers/git.rb",
49
+ "test/lib/deployers/mysql_backup.rb",
50
+ "test/lib/deployers/symfony_git.rb",
51
+ "test/spec_helper.rb"
52
+ ]
53
+ s.homepage = "https://github.com/josetonyp/kikubari"
54
+ s.licenses = ["MIT"]
55
+ s.require_paths = ["lib"]
56
+ s.rubygems_version = "1.8.17"
57
+ s.summary = "Naive multiframework deploy system"
58
+
59
+ if s.respond_to? :specification_version then
60
+ s.specification_version = 3
61
+
62
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
63
+ s.add_development_dependency(%q<rspec>, ["~> 1.3.1"])
64
+ s.add_development_dependency(%q<bundler>, [">= 0"])
65
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
66
+ s.add_development_dependency(%q<rcov>, [">= 0"])
67
+ s.add_development_dependency(%q<git>, [">= 0"])
68
+ else
69
+ s.add_dependency(%q<rspec>, ["~> 1.3.1"])
70
+ s.add_dependency(%q<bundler>, [">= 0"])
71
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
72
+ s.add_dependency(%q<rcov>, [">= 0"])
73
+ s.add_dependency(%q<git>, [">= 0"])
74
+ end
75
+ else
76
+ s.add_dependency(%q<rspec>, ["~> 1.3.1"])
77
+ s.add_dependency(%q<bundler>, [">= 0"])
78
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
79
+ s.add_dependency(%q<rcov>, [">= 0"])
80
+ s.add_dependency(%q<git>, [">= 0"])
81
+ end
82
+ end
83
+
@@ -0,0 +1,103 @@
1
+ # Holds the deployment configuration for each deploy
2
+ #
3
+ # Author:: Jose A Pio (mailto:josetonyp@gmail.com)
4
+ # Copyright:: Copyright (c) 2011
5
+ # License:: Distributes under the same terms as Ruby
6
+ module Kikubari
7
+ class Deploy
8
+ class Configuration
9
+
10
+ attr_accessor :deploy_folder, :debug, :dry_run, :environment, :rollback, :deploy_file, :config, :do , :environment_folder, :env_time_folder, :current_deploy_folder, :date_folder, :after, :before
11
+
12
+ def initialize( file , *params )
13
+
14
+ unless File.exist?(file)
15
+ raise "Deploy guide file doesn't exists: #{file}"
16
+ end
17
+
18
+ @deploy_file = YAML::load_file(file)
19
+
20
+ @config = @deploy_file["config"] || {}
21
+ @do = @deploy_file["do"] || {}
22
+ @after = @deploy_file["after"] || {}
23
+ @before = @deploy_file["before"] || {}
24
+
25
+ raise ArgumentError, "There is no params for deploy" if params.size == 0
26
+
27
+ ## verify all arguments for params are present
28
+
29
+ params.first.each do |pair|
30
+ instance_variable_set "@#{pair[0]}".strip, pair[1]
31
+ end
32
+
33
+ unless File.directory? @deploy_folder
34
+ raise ArgumentError , "Deploy folder #{@deploy_folder} is not a valid deploy folder"
35
+ end
36
+
37
+ @environment_folder = "#{@deploy_folder}/#{@environment}"
38
+ @date_folder = DateTime.now.strftime("%Y%m%d%H%M%S%L")
39
+ @env_time_folder = "#{@deploy_folder}/#{@environment}/#{@date_folder}"
40
+ @current_deploy_folder = "#{@deploy_folder}/#{@environment}/current"
41
+
42
+ parse_strcuture_folders if @do.has_key?("folder_structure") && !@do["folder_structure"].empty?
43
+ parse_test_files if @do.has_key?("test_files") && !@do["test_files"].empty?
44
+
45
+ end
46
+
47
+ # Return a class name for create a deployer instance for deployment process
48
+ def get_deployer_class
49
+ fw_class = ( @config.has_key?("framework") ) ? @config["framework"].downcase.capitalize : ""
50
+ fw_system = ( @config.has_key?("system") ) ? @config["system"].downcase.capitalize : ""
51
+ "#{fw_class}#{fw_system}Deployer"
52
+ end
53
+
54
+ # Return a class name for create a backup worker instance for backup process
55
+ def get_backup_class
56
+ fw_class = ( @config.has_key?("framework") ) ? @config["framework"].downcase.capitalize : ""
57
+ return "" unless @config.has_key?("database") && @config["database"].has_key?("driver")
58
+ driver = @config["database"]["driver"].downcase.capitalize
59
+ "#{fw_class}#{driver}Backup"
60
+ end
61
+
62
+ def get_structure_folder ( name )
63
+ @do["folder_structure"].each do |folder|
64
+ return folder.first[1] if folder.first[0] == name
65
+ end
66
+ ""
67
+ end
68
+
69
+ def get_test_file ( name )
70
+ @do["test_files"].each do |folder|
71
+ return folder.first[1] if folder.first[0] == name
72
+ end
73
+ ""
74
+ end
75
+
76
+ private
77
+
78
+ def parse_strcuture_folders
79
+ tmp = Array.new
80
+ environment = @environment
81
+ @do["folder_structure"].each do |folder|
82
+ tmp.push Hash[ { folder[0] => "#{@deploy_folder}/#{eval(%Q["#{folder[1]}"])}" } ]
83
+ end
84
+ @do["folder_structure"] = tmp
85
+ end
86
+
87
+
88
+
89
+ def parse_test_files
90
+ tmp = Array.new
91
+ environment = @environment
92
+ @do["test_files"].each do |folder|
93
+ tmp.push Hash[ { folder[0] => "#{@deploy_folder}/#{eval(%Q["#{folder[1]}"])}" } ]
94
+ end
95
+ @do["test_files"] = tmp
96
+ end
97
+
98
+
99
+ end
100
+
101
+ end
102
+
103
+ end