Class: Octopress::Scaffold
- Inherits:
-
Object
- Object
- Octopress::Scaffold
- Defined in:
- lib/octopress/scaffold.rb
Instance Attribute Summary collapse
-
#force ⇒ Object
readonly
Returns the value of attribute force.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(args, options) ⇒ Scaffold
constructor
A new instance of Scaffold.
- #local_path ⇒ Object
- #scaffold_file_list ⇒ Object
-
#scaffold_files ⇒ Object
Returns a list of.
- #scaffold_path ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(args, options) ⇒ Scaffold
Returns a new instance of Scaffold.
7 8 9 10 11 |
# File 'lib/octopress/scaffold.rb', line 7 def initialize(args, ) @path = File.(args.join(" "), Dir.pwd) @force = !!['force'] @blank = !!['blank'] end |
Instance Attribute Details
#force ⇒ Object (readonly)
Returns the value of attribute force.
5 6 7 |
# File 'lib/octopress/scaffold.rb', line 5 def force @force end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/octopress/scaffold.rb', line 5 def path @path end |
Instance Method Details
#local_path ⇒ Object
23 24 25 26 |
# File 'lib/octopress/scaffold.rb', line 23 def local_path pwd = File.join(Dir.pwd, '') path.sub(pwd, '') end |
#scaffold_file_list ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/octopress/scaffold.rb', line 39 def scaffold_file_list scaffold_files.map do |file| name = file.sub(File.join(scaffold_path, ''), '') name = name.gsub(/[^\/]+\//, ' ') if File.directory?(file) name = File.join(name, '') end " + " + name end.join("\n") end |
#scaffold_files ⇒ Object
Returns a list of
33 34 35 36 37 |
# File 'lib/octopress/scaffold.rb', line 33 def scaffold_files Find.find(scaffold_path).to_a.reject do |file| file == scaffold_path end end |
#scaffold_path ⇒ Object
28 29 30 |
# File 'lib/octopress/scaffold.rb', line 28 def scaffold_path Octopress.gem_dir('scaffold') end |
#write ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/octopress/scaffold.rb', line 13 def write if !@force && File.exist?(File.join(path, '_templates')) abort "Some files already exist. Use --force to overwrite." end FileUtils.cp_r(File.join(scaffold_path, '.'), path) puts "Added Octopress scaffold:" puts scaffold_file_list.green end |