Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved generator w/ template support
- Loading branch information
1 parent
359087c
commit 372a410
Showing
16 changed files
with
67 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ | |
/tmp/ | ||
*.DS_Store | ||
*.sass-cache | ||
*.gem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
source 'https://rubygems.org' | ||
source "https://rubygems.org" | ||
|
||
# Specify your gem's dependencies in kickster.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# kickster | ||
Kickster | ||
======== | ||
|
||
Jekyll starter template with GitHub Pages deploy to kickstart your project. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require File.dirname(__FILE__) + '/../lib/kickster.rb' | ||
|
||
require File.dirname(__FILE__) + "/../lib/kickster.rb" | ||
Kickster::Generator.start |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
require "kickster/generator" | ||
require "kickster/version" | ||
require_relative "kickster/version" | ||
require_relative "kickster/install" | ||
require_relative "kickster/generator" | ||
|
||
module Kickster | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,16 @@ | ||
require "fileutils" | ||
require "erb" | ||
require "kickster/version" | ||
require "pathname" | ||
require "thor" | ||
|
||
module Kickster | ||
class Generator < Thor | ||
map ['-v', '--version'] => :version | ||
include Thor::Actions | ||
|
||
desc 'new', 'Create new folder with the Kickster template' | ||
method_options :path => :string, :force => :boolean | ||
def new(name) | ||
if kickster_files_already_exist?(name) && !options[:force] | ||
puts "Folder already exist, use --force to overwrite." | ||
else | ||
install_files(name) | ||
puts "Kickster template folder successfully created!" | ||
end | ||
end | ||
map ["-v", "--version"] => :version | ||
|
||
desc 'version', 'Show Kickster version' | ||
desc "version", "Show Kickster version" | ||
def version | ||
say "kickster-#{Kickster::VERSION}" | ||
end | ||
|
||
private | ||
|
||
def kickster_files_already_exist?(name) | ||
install_path(name).exist? | ||
end | ||
|
||
def install_path(name) | ||
@install_path ||= if options[:path] | ||
Pathname.new(File.join(options[:path], name)) | ||
erb = ERB.new(File.read("config.yml")) | ||
site_name = name | ||
puts erb.result(site_name) | ||
else | ||
Pathname.new(name) | ||
end | ||
end | ||
|
||
def install_files(name) | ||
FileUtils.mkdir_p(install_path(name)) | ||
FileUtils.cp_r(template_files, install_path(name)) | ||
|
||
end | ||
|
||
def template_files | ||
Dir["#{template_directory}/."] | ||
say "Kickster #{Kickster::VERSION}" | ||
end | ||
|
||
def template_directory | ||
File.join(top_level_directory, "template") | ||
end | ||
|
||
def top_level_directory | ||
File.dirname(File.dirname(File.dirname(__FILE__))) | ||
end | ||
register(Kickster::Install, "new", "new", "Create new folder with the Kickster template") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require "thor" | ||
|
||
module Kickster | ||
class Install < Thor::Group | ||
include Thor::Actions | ||
|
||
argument :name | ||
class_options force: :boolean | ||
|
||
def self.source_root | ||
File.expand_path("../../../template", __FILE__) | ||
end | ||
|
||
def name_components | ||
@_name_components ||= name.scan(/[[:alnum:]]+/) | ||
end | ||
|
||
def snake_name | ||
@_snake_name = name_components.map(&:downcase).join("_") | ||
end | ||
|
||
def camel_name | ||
@_camel_name = name_components.map(&:capitalize).join("") | ||
end | ||
|
||
def check_if_exists? | ||
if File.directory?(snake_name) && !options[:force] | ||
say "Folder already exist, use --force to overwrite.", :red | ||
exit 1 | ||
end | ||
end | ||
|
||
def copy_templates | ||
directory("./", "./#{snake_name}") | ||
end | ||
|
||
def report_success | ||
say "Kickster template folder successfully created!", :green | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Kickster | ||
VERSION = "0.1.3" | ||
VERSION = "0.1.4" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
permalink: pretty | ||
name: <%= site_name %> | ||
name: <%= snake_name %> | ||
|
||
exclude: | ||
- .bowerrc | ||
|
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "kickster", | ||
"name": "<%= snake_name %>", | ||
"dependencies": { | ||
"jquery": "~1.11.2" | ||
} | ||
|
Empty file.