Class: Embork::Generator
- Inherits:
-
Object
- Object
- Embork::Generator
- Defined in:
- lib/embork/generator.rb
Defined Under Namespace
Classes: ErbHelpers
Constant Summary collapse
- BLUEPRINT_DIR =
File.('../../../blueprint', __FILE__).freeze
Instance Attribute Summary collapse
-
#dot_files ⇒ Object
readonly
Returns the value of attribute dot_files.
-
#erb_files ⇒ Object
readonly
Returns the value of attribute erb_files.
-
#project_path ⇒ Object
readonly
Returns the value of attribute project_path.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(package_name, options) ⇒ Generator
constructor
A new instance of Generator.
- #read_dot_files ⇒ Object
- #read_erb_files ⇒ Object
- #set_project_path(directory) ⇒ Object
Constructor Details
#initialize(package_name, options) ⇒ Generator
Returns a new instance of Generator.
14 15 16 17 18 19 20 |
# File 'lib/embork/generator.rb', line 14 def initialize(package_name, ) @package_name = package_name @logger = Embork::Logger.new STDOUT, :simple read_erb_files read_dot_files set_project_path([:directory]) end |
Instance Attribute Details
#dot_files ⇒ Object (readonly)
Returns the value of attribute dot_files.
9 10 11 |
# File 'lib/embork/generator.rb', line 9 def dot_files @dot_files end |
#erb_files ⇒ Object (readonly)
Returns the value of attribute erb_files.
8 9 10 |
# File 'lib/embork/generator.rb', line 8 def erb_files @erb_files end |
#project_path ⇒ Object (readonly)
Returns the value of attribute project_path.
10 11 12 |
# File 'lib/embork/generator.rb', line 10 def project_path @project_path end |
Instance Method Details
#generate ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/embork/generator.rb', line 45 def generate check_for_npm copy_files process_erb move_dot_files install_npm_deps install_bower_deps bundle init_git print_success end |
#read_dot_files ⇒ Object
27 28 29 30 |
# File 'lib/embork/generator.rb', line 27 def read_dot_files list_file_path = File.join(BLUEPRINT_DIR, 'dotfiles') @dot_files = File.readlines(list_file_path).map{ |f| f.strip } end |
#read_erb_files ⇒ Object
22 23 24 25 |
# File 'lib/embork/generator.rb', line 22 def read_erb_files list_file_path = File.join(BLUEPRINT_DIR, 'erbfiles') @erb_files = File.readlines(list_file_path).map{ |f| f.strip } end |
#set_project_path(directory) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/embork/generator.rb', line 32 def set_project_path(directory) if directory.nil? @project_path = File.join Dir.pwd, @package_name else p = Pathname.new directory if p.absolute? @project_path = p.to_s else @project_path = File. p.to_s, Dir.pwd end end end |