Sha256: cf4d7f3e9c7e6debcf25cbaca1f7197c222679949effca868a9afa187c76d854
Contents?: true
Size: 1.56 KB
Versions: 2
Compression:
Stored size: 1.56 KB
Contents
# encoding: utf-8 module Develry class Site # Supports initializing new projects with a Gemfile and Rakefile class Initializer def self.call(root) new(root).call end attr_reader :site attr_reader :root attr_reader :config_dir def initialize(site) @site = site @root = site.root config_dir = @root.join(DEFAULT_CONFIG_DIR_NAME).tap(&:mkpath) @config_dir = config_dir.parent end # Init develry using default config # # @return [undefined] # # @api public def call FileUtils.cp_r(DEFAULT_CONFIG_PATH, config_dir) site.sync init_gemfile init_rakefile self end private # Initialize the Gemfile # # @return [undefined] # # @api private 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 # Initialize the Rakefile # # @return [undefined] # # @api private 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 end # class Initializer end # class Site end # module Develry
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
develry-0.0.3 | lib/develry/site/initializer.rb |
develry-0.0.2 | lib/develry/site/initializer.rb |