class Newport::New
Public Class Methods
process(args)
click to toggle source
# File lib/newport/new.rb, line 6 def process(args) Newport.logger.abort_with 'fatal: please specify path.'.red unless args[1] show_help if args[1] == 'help' create_blog args[1] end
Private Class Methods
after_install(path)
click to toggle source
# File lib/newport/new.rb, line 50 def after_install(path) begin require 'bundler' bundle_install path rescue LoadError Newport.logger.info 'Could not load Bundler. Bundle install skipped.' end Newport.logger.info "New Newport site installed in #{path.cyan}." end
bundle_install(path)
click to toggle source
# File lib/newport/new.rb, line 61 def bundle_install(path) Newport.logger.info "Running bundle install in #{path.cyan}..." Dir.chdir(path) do system('bundle') end end
create_blog(path)
click to toggle source
# File lib/newport/new.rb, line 20 def create_blog(path) blog_path = File.expand_path(path, Dir.pwd) FileUtils.mkdir_p blog_path FileUtils.cp_r "#{template}/.", path FileUtils.chmod_R 'u+w', path File.open(File.expand_path('Gemfile', path), 'w') do |f| f.write(gemfile_contents) end after_install path end
gemfile_contents()
click to toggle source
# File lib/newport/new.rb, line 35 def gemfile_contents <<~RUBY source "https://rubygems.org" gem "newport", "~> #{Newport::VERSION}" # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem # and associated library. platforms :mingw, :x64_mingw, :mswin, :jruby do gem "tzinfo", "~> 1.2" gem "tzinfo-data" end RUBY end
show_help()
click to toggle source
# File lib/newport/new.rb, line 14 def show_help Newport.logger.info "Newport #{Newport::VERSION}" Newport.logger.info 'usage: newport new [path]' abort end
template()
click to toggle source
# File lib/newport/new.rb, line 31 def template File.expand_path('../site_template', __dir__) end