class Develry::Site::Initializer
Supports initializing new projects with a Gemfile and Rakefile
Attributes
config_dir[R]
root[R]
site[R]
Public Class Methods
call(root)
click to toggle source
# File lib/develry/site/initializer.rb, line 9 def self.call(root) new(root).call end
new(site)
click to toggle source
# File lib/develry/site/initializer.rb, line 19 def initialize(site) @site = site @root = site.root config_dir = @root.join(DEFAULT_CONFIG_DIR_NAME).tap(&:mkpath) @config_dir = config_dir.parent end
Public Instance Methods
call()
click to toggle source
Init develry using default config
@return [undefined]
@api public
# File lib/develry/site/initializer.rb, line 31 def call FileUtils.cp_r(DEFAULT_CONFIG_PATH, config_dir) site.sync init_gemfile init_rakefile self end
Private Instance Methods
init_gemfile()
click to toggle source
Initialize the Gemfile
@return [undefined]
@api private
# File lib/develry/site/initializer.rb, line 48 def init_gemfile gemfile = root.join(DEFAULT_GEMFILE_NAME) unless gemfile.file? && gemfile.read.include?(EVAL_GEMFILE) gemfile.open('a') do |file| file << ANNOTATION_WRAPPER % EVAL_GEMFILE end end end
init_rakefile()
click to toggle source
Initialize the Rakefile
@return [undefined]
@api private
# File lib/develry/site/initializer.rb, line 62 def init_rakefile rakefile = root.join(RAKE_FILE_NAME) unless rakefile.file? && rakefile.read.include?(INIT_RAKE_TASKS) rakefile.open('a') do |file| file << ANNOTATION_WRAPPER % [REQUIRE, INIT_RAKE_TASKS].join("\n") end end end