captify 0.1.1

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,9 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'capistrano'
4
+
5
+ group :development do
6
+ gem "rdoc", "~> 3.12"
7
+ gem "bundler", "~> 1.0.0"
8
+ gem "jeweler", "~> 1.8.3"
9
+ end
@@ -0,0 +1,36 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ capistrano (2.12.0)
5
+ highline
6
+ net-scp (>= 1.0.0)
7
+ net-sftp (>= 2.0.0)
8
+ net-ssh (>= 2.0.14)
9
+ net-ssh-gateway (>= 1.1.0)
10
+ git (1.2.5)
11
+ highline (1.6.12)
12
+ jeweler (1.8.3)
13
+ bundler (~> 1.0)
14
+ git (>= 1.2.5)
15
+ rake
16
+ rdoc
17
+ json (1.7.3)
18
+ net-scp (1.0.4)
19
+ net-ssh (>= 1.99.1)
20
+ net-sftp (2.0.5)
21
+ net-ssh (>= 2.0.9)
22
+ net-ssh (2.5.2)
23
+ net-ssh-gateway (1.1.0)
24
+ net-ssh (>= 1.99.1)
25
+ rake (0.9.2.2)
26
+ rdoc (3.12)
27
+ json (~> 1.4)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ bundler (~> 1.0.0)
34
+ capistrano
35
+ jeweler (~> 1.8.3)
36
+ rdoc (~> 3.12)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Huiming Teo
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,38 @@
1
+ = captify
2
+
3
+ == Install
4
+ gem install capistrano-templates # default template is stored in this gem
5
+
6
+ For bundler, add this to your Gemfile:
7
+
8
+ gem 'capistrano-templates'
9
+
10
+ == Usage
11
+ cd my_project
12
+ captify . # use default template: rails-basic
13
+
14
+ It will:
15
+
16
+ 1. Run capify.
17
+ 2. Overwrite Capistrano files with default template: rails-basic
18
+
19
+ To use a different template:
20
+
21
+ cd my_project
22
+ T=sinatra-basic captify .
23
+
24
+ == Contributing to capy
25
+
26
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
27
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
28
+ * Fork the project.
29
+ * Start a feature/bugfix branch.
30
+ * Commit and push until you are happy with your contribution.
31
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
32
+ * 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.
33
+
34
+ == Copyright
35
+
36
+ Copyright (c) 2012 Huiming Teo. See LICENSE.txt for
37
+ further details.
38
+
@@ -0,0 +1,38 @@
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 = "captify"
18
+ gem.homepage = "http://github.com/teohm/captify"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Capistrano capify with canned templates.}
21
+ gem.description = %Q{Capistrano capify with canned templates.}
22
+ gem.email = "teohuiming@gmail.com"
23
+ gem.authors = ["Huiming Teo"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ task :default => :test
29
+
30
+ require 'rdoc/task'
31
+ Rake::RDocTask.new do |rdoc|
32
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
33
+
34
+ rdoc.rdoc_dir = 'rdoc'
35
+ rdoc.title = "captify #{version}"
36
+ rdoc.rdoc_files.include('README*')
37
+ rdoc.rdoc_files.include('lib/**/*.rb')
38
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'captify/template'
4
+
5
+ Captify::Template.load_all
6
+
7
+ if ARGV.empty?
8
+ abort "Please specify the directory to captify, e.g. `#{File.basename($0)} .'"
9
+ elsif !File.exists?(ARGV.first)
10
+ abort "`#{ARGV.first}' does not exist."
11
+ elsif !File.directory?(ARGV.first)
12
+ abort "`#{ARGV.first}' is not a directory."
13
+ elsif ARGV.length > 1
14
+ abort "Too many arguments; please specify only the directory to capify."
15
+ end
16
+
17
+ base_dir = ARGV.first
18
+
19
+ template_name = ENV['T'] || 'rails-basic'
20
+ file_paths = Captify::Template.template_files(template_name)
21
+
22
+ puts `capify #{base_dir}`
23
+
24
+ file_paths.each do |src_path|
25
+ dest_path = src_path.split( "#{template_name}" ).last
26
+ dest_dir = File.dirname(dest_path)
27
+ puts "[captify] Overwrite file '#{base_dir}#{dest_path}'"
28
+ `mkdir -p \"#{base_dir}#{dest_dir}\" && cp \"#{src_path}\" \"#{base_dir}#{dest_path}\"`
29
+ end
30
+
31
+ puts "[captify] Done!"
@@ -0,0 +1,59 @@
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 = "captify"
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Huiming Teo"]
12
+ s.date = "2012-06-06"
13
+ s.description = "Capistrano capify with canned templates."
14
+ s.email = "teohuiming@gmail.com"
15
+ s.executables = ["captify"]
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/captify",
29
+ "captify.gemspec",
30
+ "lib/captify/template.rb"
31
+ ]
32
+ s.homepage = "http://github.com/teohm/captify"
33
+ s.licenses = ["MIT"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = "1.8.24"
36
+ s.summary = "Capistrano capify with canned templates."
37
+
38
+ if s.respond_to? :specification_version then
39
+ s.specification_version = 3
40
+
41
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
42
+ s.add_runtime_dependency(%q<capistrano>, [">= 0"])
43
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
44
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
45
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
46
+ else
47
+ s.add_dependency(%q<capistrano>, [">= 0"])
48
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
49
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
50
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
51
+ end
52
+ else
53
+ s.add_dependency(%q<capistrano>, [">= 0"])
54
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
55
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
56
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
57
+ end
58
+ end
59
+
@@ -0,0 +1,51 @@
1
+ module Captify
2
+ class Template
3
+
4
+ def self.load_all
5
+ $LOAD_PATH.each do |path|
6
+ template_path = File.join(path, 'template.rb')
7
+ load template_path if File.exist? template_path
8
+ end
9
+ end
10
+
11
+ def self.template_files(template_name)
12
+ @@templates ||= {}
13
+ @@templates.fetch(template_name, [])
14
+ end
15
+
16
+ protected
17
+
18
+ def self.inherited(subclass)
19
+ file_path = extract_file_path caller
20
+ templates_path = get_templates_path file_path
21
+ dirs = find_all_template_dir templates_path
22
+
23
+ @@templates ||= {}
24
+ dirs.each do |dir|
25
+ name, files = extract_template_name_and_files dir
26
+ @@templates[name] = files
27
+ end
28
+ end
29
+
30
+ def self.extract_template_name_and_files(dir)
31
+ name = File.basename dir
32
+ files = Dir[ File.join(dir, '**', '*') ]
33
+ files = files.select{|path| File.file? path}
34
+
35
+ [name, files]
36
+ end
37
+
38
+ def self.extract_file_path(caller_value)
39
+ caller_value.first[/^[^:]+/]
40
+ end
41
+
42
+ def self.get_templates_path(file_path)
43
+ File.realdirpath File.join(File.dirname(file_path), '..', 'templates')
44
+ end
45
+
46
+ def self.find_all_template_dir(templates_path)
47
+ Dir[ File.join(templates_path, '*') ]
48
+ end
49
+ end
50
+ end
51
+
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: captify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Huiming Teo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: !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: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rdoc
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '3.12'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.12'
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.0.0
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: jeweler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.8.3
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.8.3
78
+ description: Capistrano capify with canned templates.
79
+ email: teohuiming@gmail.com
80
+ executables:
81
+ - captify
82
+ extensions: []
83
+ extra_rdoc_files:
84
+ - LICENSE.txt
85
+ - README.rdoc
86
+ files:
87
+ - .document
88
+ - Gemfile
89
+ - Gemfile.lock
90
+ - LICENSE.txt
91
+ - README.rdoc
92
+ - Rakefile
93
+ - VERSION
94
+ - bin/captify
95
+ - captify.gemspec
96
+ - lib/captify/template.rb
97
+ homepage: http://github.com/teohm/captify
98
+ licenses:
99
+ - MIT
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ segments:
111
+ - 0
112
+ hash: 2119559040684084433
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 1.8.24
122
+ signing_key:
123
+ specification_version: 3
124
+ summary: Capistrano capify with canned templates.
125
+ test_files: []