Sha256: dd29d98613fa177960c952ae965396f19e8fa594ab074b20f66065f0b961037d
Contents?: true
Size: 1.44 KB
Versions: 3
Compression:
Stored size: 1.44 KB
Contents
require 'rails/generators' module Staple class ImportGenerator < Rails::Generators::Base desc 'bring in the staple' source_root File.join(File.dirname(__FILE__), '..', '..') argument :actions, :type => :array, :default => [] def import_styles gsub_file "app/assets/stylesheets/staple/#{component}.scss", "//&*default", "\n\t#{contents}//&*default" if contents gsub_file "app/assets/stylesheets/staple/builders/build_#{component}.scss", "//&*default", "\n\t\t#{contents}//&*default" if contents gsub_file "app/assets/stylesheets/staple/#{component}.scss", "//&*hover", "\n\t#{hover}//&*hover" if hover gsub_file "app/assets/stylesheets/staple/builders/build_#{component}.scss", "//&*hover", "\n\t\t#{hover}//&*hover" if hover puts "invalid operation. for available actions: rails g staple:list [option]" if !contents end private def contents file = File.join(self.class.source_root, 'source', 'styles', "#{component}", "#{pattern.dasherize}.scss") get_file(file) end def hover file = File.join(self.class.source_root, 'source', 'styles', "#{component}", "#{pattern.dasherize}-hover.scss") get_file(file) end def get_file(file) if File.file?(file) return File.read(file) else return false end end def component actions[0] end def pattern actions[1] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
staple-0.3.0 | lib/staple/import_generator.rb |
staple-0.2.1 | lib/staple/import_generator.rb |
staple-0.2.0 | lib/staple/import_generator.rb |