capistrano-progressbar 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ *.swp
6
+ *.orig
7
+ test
8
+ config
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in capistrano-progressbar.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Capistrano Progressbar
2
+
3
+ Capistrano plugin that integrates Progressbar tasks into capistrano deployment script.
4
+
5
+ ## Installation
6
+
7
+ gem install capistrano-progressbar
8
+ # or add it to Gemfile
9
+ gem 'capistrano-progressbar'
10
+ ## Usage
11
+
12
+ # Set the variable in the deploy file
13
+ require 'capistrano-progressbar'
14
+ set :task_count, '14' #the task count to be executed
15
+ ## Banner
16
+
17
+ Put the banner file into `config/banner` file,if the file is not existed the default banner will be used.
18
+ You can get more banners at [Text Ascii Art Generator](http://patorjk.com/software/taag/)
19
+
20
+ ## Alias
21
+
22
+ Put the alias command into `~/.bashrc` or `.rvmrc`
23
+
24
+ alias deploy='bunlde exec cap deploy -l "./log/capistrano.log"'
25
+
26
+ Then you can use deploy to execute `cap deploy` with fire the progressbar at the terminal
27
+
28
+ ## Screencast
29
+ ![Fire](http://i.imgur.com/GF6QE.jpg)
30
+ ## License
31
+ MIT: http://rem.mit-license.org
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "capistrano-progressbar/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "capistrano-progressbar"
7
+ s.version = Capistrano::Progressbar::VERSION
8
+ s.authors = ["Zhengquan Yang"]
9
+ s.email = ["yangzhengquan@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Add the progressbar when using capistrnao}
12
+ s.description = %q{Show progressbar when executing `cap deploy`}
13
+ s.extra_rdoc_files = [
14
+ "README.md"
15
+ ]
16
+
17
+ s.rubyforge_project = "capistrano-progressbar"
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
23
+
24
+ # specify any dependencies here; for example:
25
+ # s.add_development_dependency "rspec"
26
+ s.add_runtime_dependency "capistrano"
27
+ s.add_runtime_dependency "progressbar"
28
+ end
@@ -0,0 +1,2 @@
1
+ require "capistrano-progressbar/version"
2
+ require "capistrano-progressbar/capistrano_integration"
@@ -0,0 +1,84 @@
1
+ require 'capistrano'
2
+ require 'capistrano/version'
3
+
4
+ module CapistranoProgressbar
5
+ class CapistranoIntegration
6
+ def self.load_into(capistrano_config)
7
+ capistrano_config.load do
8
+ # load progressbar
9
+ require 'progressbar'
10
+ # check wether the command is existed
11
+ def shell_command_exists?(command)
12
+ ENV['PATH'].split(File::PATH_SEPARATOR).any?{|d| File.exists? File.join(d, command) }
13
+ end
14
+ # get the banner
15
+ def get_banner
16
+ cap_banner = <<-BANNER
17
+ ###### ### ######## #### ###### ######## ######## ### ## ## #######
18
+ ## ## ## ## ## ## ## ## ## ## ## ## ## ## ### ## ## ##
19
+ ## ## ## ## ## ## ## ## ## ## ## ## #### ## ## ##
20
+ ## ## ## ######## ## ###### ## ######## ## ## ## ## ## ## ##
21
+ ## ######### ## ## ## ## ## ## ######### ## #### ## ##
22
+ ## ## ## ## ## ## ## ## ## ## ## ## ## ## ### ## ##
23
+ ###### ## ## ## #### ###### ## ## ## ## ## ## ## #######
24
+ BANNER
25
+ banner = cap_banner.split(/\n/).map(&:chomp)
26
+ banner = File.readlines('./config/banner').map(&:chomp!) if File.exist? './config/banner'
27
+ banner
28
+ end
29
+ # get the current terminal size
30
+ def get_terminal_size
31
+ terminal_size ||= {}
32
+ if ENV["LINES"] && ENV["COLUMNS"]
33
+ terminal_size["lines"] = ENV["LINES"]
34
+ terminal_size["columns"] = ENV["COLUMNS"]
35
+ elsif (RUBY_PLATFORM =~ /java/ || (!STDIN.tty? && ENV['TERM'])) && shell_command_exists?('tput')
36
+ terminal_size["lines"] = `tput lines`.strip.to_i
37
+ terminal_size["columns"] = `tput cols`.strip.to_i
38
+ elsif STDIN.tty? && shell_command_exists?('stty')
39
+ terminal_size["lines"], terminal_size["columns"] = `stty size`.strip.split(/\s/).map(&:to_i)
40
+ else
41
+ terminal_size["lines"], terminal_size["columns"] = 40, 90
42
+ end
43
+ terminal_size
44
+ end
45
+
46
+ # Get the task count to be executed
47
+ # To be fixed
48
+ def get_task_count
49
+ variables.has_key?(:task_count) ? variables[:task_count] : 14
50
+ end
51
+
52
+ @terminal_size = get_terminal_size
53
+ @banner = get_banner
54
+
55
+ #Initialize the ProgressBar
56
+ $bar = ProgressBar.new('Fire', get_task_count)
57
+ $bar.bar_mark = '='
58
+
59
+ #Clear the screen and cup the cursor postion and display the banner
60
+ row_position= (@terminal_size["columns"] - @banner[0].size)/2
61
+ system "tput clear && tput cup 1 #{row_position}"
62
+ @banner.each_with_index do |line,index|
63
+ system "tput cup #{index + 2} #{row_position}"
64
+ puts line
65
+ end
66
+ # put the progressbar at the middle of the terminal
67
+ system "tput cup #{@terminal_size["lines"]/2} 0"
68
+
69
+ #cleanup the releases
70
+ after "deploy", "deploy:cleanup"
71
+ # set the callback to update the progressbar
72
+ on :after, :only => 'deploy:clean' do
73
+ system "tput clear"
74
+ end
75
+ on :after do
76
+ $bar.inc
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ if Capistrano::Configuration.instance
83
+ CapistranoProgressbar::CapistranoIntegration.load_into(Capistrano::Configuration.instance)
84
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Progressbar
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-progressbar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Zhengquan Yang
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-15 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: &85923070 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *85923070
25
+ - !ruby/object:Gem::Dependency
26
+ name: progressbar
27
+ requirement: &85922860 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *85922860
36
+ description: Show progressbar when executing `cap deploy`
37
+ email:
38
+ - yangzhengquan@gmail.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files:
42
+ - README.md
43
+ files:
44
+ - .gitignore
45
+ - Gemfile
46
+ - README.md
47
+ - Rakefile
48
+ - capistrano-progressbar.gemspec
49
+ - lib/capistrano-progressbar.rb
50
+ - lib/capistrano-progressbar/capistrano_integration.rb
51
+ - lib/capistrano-progressbar/version.rb
52
+ homepage: ''
53
+ licenses: []
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project: capistrano-progressbar
72
+ rubygems_version: 1.8.10
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: Add the progressbar when using capistrnao
76
+ test_files: []
77
+ has_rdoc: