Class: Richcss::Generators::PartTemplate
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Richcss::Generators::PartTemplate
- Includes:
- Thor::Actions
- Defined in:
- lib/richcss/generators.rb
Class Method Summary collapse
-
.source_root ⇒ Object
argument :part, :type => :array argument :part_name, :type => :string.
Instance Method Summary collapse
Class Method Details
.source_root ⇒ Object
argument :part, :type => :array argument :part_name, :type => :string
52 53 54 |
# File 'lib/richcss/generators.rb', line 52 def self.source_root File.dirname(__FILE__) + "/generator" end |
Instance Method Details
#create_css_files ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/richcss/generators.rb', line 71 def create_css_files # TODO: add choice of CSS or SCSS files to generate # TODO: Make it not hardcode box/elements extension = ".css" # extension = ".css.scss" @boxFiles.each do |filename| create_file "#{@name}/lib/box/#{filename}#{extension}" unless File.file?("#{@name}/lib/box/#{filename}#{extension}") end @elementFiles.each do |filename| create_file "#{@name}/lib/elements/#{filename}#{extension}" unless File.file?("#{@name}/lib/elements/#{filename}#{extension}") end end |
#create_files ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/richcss/generators.rb', line 85 def create_files create_file "#{@name}/README.md" unless File.file?("#{@name}/README.md") if !File.file?("#{@name}/#{@name.downcase}.spec") create_file "#{@name}/#{@name.downcase}.spec" # Write JSON to Test.Spec specs = { "name" => "#{@name}", "authors" => "AUTHOR_NAME", "email" => "AUTHOR_EMAIL", "description" => "DESCRIPTION", "version" => "0.0.0", "homepage" => "GITHUB_REPO_URL", "dependencies" => { "DEPENDECY_NAME" => "DEPENDECY_VERSION" } } File.open("#{@name}/#{@name.downcase}.spec","w") do |f| f.write(JSON.pretty_generate(specs)) end end end |
#create_folders ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/richcss/generators.rb', line 63 def create_folders empty_directory(@name) unless Dir.exists?(@name) empty_directory("#{@name}/lib") unless Dir.exists?("#{@name}/lib") @groups.each do |g| empty_directory("#{@name}/lib/#{g}") unless Dir.exists?("#{@name}/lib/#{g}") end end |
#init ⇒ Object
56 57 58 59 60 61 |
# File 'lib/richcss/generators.rb', line 56 def init @name = part_name.first @groups = ['box', 'elements'] @boxFiles = ['blocks', 'main', 'positioning'] @elementFiles = ['button', 'colors', 'features', 'fonts', 'images', 'inputs', 'lists'] end |