Sha256: 67a5e53e758277466920ef632767c0c1a73ea8f4bf97b9baad5f4e70600769aa
Contents?: true
Size: 1.56 KB
Versions: 3
Compression:
Stored size: 1.56 KB
Contents
require 'rails/generators' module Staple class AmputateGenerator < Rails::Generators::Base desc 'remove styles from default' source_root File.join(File.dirname(__FILE__), '..', '..') argument :actions, :type => :array, :default => [] def amputate_styles gsub_file "app/assets/stylesheets/staple/#{component}.scss", "\n.#{component.singularize}.#{pattern}{\n\t#{contents}\n}", "" if contents gsub_file "app/assets/stylesheets/staple/builders/build_#{component}.scss", "\n.#{component.singularize}.\#{$class}.#{pattern}{\n\t#{contents}\n}", "" if contents gsub_file "app/assets/stylesheets/staple/#{component}.scss", "\n.#{component.singularize}.#{pattern}:hover{\n\t#{hover}\n}", "" if hover gsub_file "app/assets/stylesheets/staple/builders/build_#{component}.scss", "\n.#{component.singularize}.\#{$class}.#{pattern}:hover{\n\t#{hover}\n}", "" 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/amputate_generator.rb |
staple-0.2.1 | lib/staple/amputate_generator.rb |
staple-0.2.0 | lib/staple/amputate_generator.rb |