class DrinkUpDoctor::NewSite
Public Class Methods
source_root()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 22 def self.source_root File.expand_path("../../../", __FILE__) end
Public Instance Methods
app_name()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 8 def app_name @app_name || File.basename($0) end
append_gitinore_file()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 78 def append_gitinore_file append_to_file "#{name}/.gitignore", %Q{ # Added by #{app_name} /_site/ /.sass-cache/ /node_modules/ /assets/ /bower_components/ .DS_Store } end
copy_gemfile()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 133 def copy_gemfile copy_file "templates/Gemfile", "#{name}/Gemfile" end
copy_gulp_file()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 74 def copy_gulp_file template "templates/gulpfile.js.erb", "#{name}/gulpfile.js" end
copy_new_main_scss()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 107 def copy_new_main_scss copy_file "templates/main.scss", "#{name}/_sass/main.scss" end
create_bower_file()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 66 def create_bower_file template "templates/bower.json.erb", "#{name}/bower.json" end
create_config_with_baseurl()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 57 def create_config_with_baseurl config_file = "#{name}/_baseurl.yml" config = { "baseurl" => options["baseurl"] } create_file config_file, config.to_yaml prepend_to_file config_file, "# Generated by #{app_name}" end
create_jekyll_project()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 30 def create_jekyll_project unless run "jekyll new #{name}" warn "#{app_name} must be run on a new directory" exit -1 end end
create_package_file()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 70 def create_package_file template "templates/package.json.erb", "#{name}/package.json" end
create_project_directory()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 26 def create_project_directory empty_directory name end
create_readme_for_site()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 115 def create_readme_for_site template "templates/README.md.erb", "#{name}/README.md" end
create_setup()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 137 def create_setup copy_file "templates/setup.sh", "#{name}/.setup.sh" chmod "#{name}/.setup.sh", 0755 end
edit_about()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 129 def edit_about insert_into_file("#{name}/about.md", "navbar: true\n", after: %r{title:.*\n}) end
edit_header()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 124 def edit_header gsub_file("#{name}/_includes/header.html",%r{<svg.*?>.*</svg>}ms, "<i class=\"fa fa-bars\"></i>") gsub_file("#{name}/_includes/header.html",%r{if page.title}, "if page.navbar") end
exclude_files()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 93 def exclude_files append_to_file "#{name}/_config.yml", %Q{ # Added by #{app_name} exclude: [README.md, bower.json, package.json, gulpfile.js, node_modules, bower_components, Gemfile, Gemfile.lock] } end
print_instructions()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 142 def print_instructions puts <<-instructions ******************************************************************************** Completing the Installation --------------------------- Change into the new site directory and run the setup script: $ cd "./#{name}" $ ./.setup.sh This will install the npm modules, bower components, and ruby gems needed to work with your new site. After the setup is complete, you can start up the gulp server and start blogging: $ gulp When you are ready to publish, shut down the gulp server with Ctrl-C and run the distribution build: $ gulp dist The distribution will be in "./#{name}/_dist/" and you can push that to where your site is located. (Github pages, AWS S3, your own server, or whatever you choose to use.) ******************************************************************************** instructions end
remove_main_scss()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 103 def remove_main_scss remove_file "#{name}/css/main.scss" end
update_config()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 37 def update_config config_file = "#{name}/_config.yml" config = YAML.load_file(config_file) config.merge! options config.merge!({ "baseurl" => "", "markdown" => "kramdown", "kramdown" => { "input" => "GFM", "hard_wrap" => false }, "defaults" => { "author" => options["author"] } }) remove_file config_file create_file config_file, config.to_yaml prepend_to_file config_file, "# Generated by #{app_name}\n" end
update_for_assets()
click to toggle source
# File lib/drink_up_doctor/new_site.rb, line 111 def update_for_assets gsub_file("#{name}/_includes/head.html", %r{/css/main.css},"/assets/css/main.css") end