Class: Squareone::Generator
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Squareone::Generator
- Includes:
- Thor::Actions
- Defined in:
- lib/squareone/generator.rb
Class Method Summary collapse
-
.source_root ⇒ Object
Declare source files directory.
Instance Method Summary collapse
-
#copy_files ⇒ Object
Copy files in the root directory.
-
#copy_folders ⇒ Object
Copy files in folders.
-
#create_git_files ⇒ Object
Create git files.
-
#generate_from_templates ⇒ Object
Generate files with template variables.
-
#setup ⇒ Object
Setup generator.
- #success_message ⇒ Object
Class Method Details
.source_root ⇒ Object
Declare source files directory
21 22 23 |
# File 'lib/squareone/generator.rb', line 21 def self.source_root File.("../templates", File.dirname(__FILE__)) end |
Instance Method Details
#copy_files ⇒ Object
Copy files in the root directory
48 49 50 51 52 |
# File 'lib/squareone/generator.rb', line 48 def copy_files %w{_config.dev.yml about.md feed.xml gulpfile.js index.html}.each do |file| copy_file file end end |
#copy_folders ⇒ Object
Copy files in folders
26 27 28 29 30 |
# File 'lib/squareone/generator.rb', line 26 def copy_folders %w{_includes _layouts _posts _sass assets}.each do |dir| directory dir end end |
#create_git_files ⇒ Object
Create git files
33 34 35 36 37 38 |
# File 'lib/squareone/generator.rb', line 33 def create_git_files %w{assets/images/.gitkeep assets/stylesheets/.gitkeep}.each do |file| create_file file end copy_file ".gitignore" end |
#generate_from_templates ⇒ Object
Generate files with template variables
41 42 43 44 45 |
# File 'lib/squareone/generator.rb', line 41 def generate_from_templates %w{package.json _config.yml}.each do |file| template file end end |
#setup ⇒ Object
Setup generator
11 12 13 14 15 16 17 18 |
# File 'lib/squareone/generator.rb', line 11 def setup @project_name = name.downcase raise Thor::Error, set_color("ERROR: #{@project_name} already exist.", :red) if File.exist?(@project_name) @project_title = name.split(/[- _]/).map(&:capitalize).join(' ') self.destination_root = File.(@project_name) end |
#success_message ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/squareone/generator.rb', line 54 def = <<-MSG ============================================= Project #{@project_name} created successfully. 1. Move into the project directory. $ cd #{@project_name} 2. Install project dependencies. $ npm install 3. Start local server with gulp watching for changes. $ npm start =========================================== MSG say end |