Class: Blueprint::Compressor

Inherits:
Object
  • Object
show all
Defined in:
lib/blueprint/compressor.rb

Constant Summary collapse

TEST_FILES =
["index.html",
"parts/elements.html",
"parts/forms.html",
"parts/grid.html",
"parts/sample.html"]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCompressor

constructor



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/blueprint/compressor.rb', line 22

def initialize
  # set up defaults
  @script_name = File.basename($0)
  @loaded_from_settings = false
  @settings_file = Blueprint::SETTINGS_FILE
  self.namespace = ""
  self.destination_path = Blueprint::BLUEPRINT_ROOT_PATH
  self.custom_layout = CustomLayout.new
  self.custom_css = {}
  self.semantic_classes = {}
  self.plugins = []

  self.options.parse!(ARGV)
  initialize_project_from_yaml(self.project_name)
end

Instance Attribute Details

#custom_cssObject

Returns the value of attribute custom_css



11
12
13
# File 'lib/blueprint/compressor.rb', line 11

def custom_css
  @custom_css
end

#custom_layoutObject

Returns the value of attribute custom_layout



11
12
13
# File 'lib/blueprint/compressor.rb', line 11

def custom_layout
  @custom_layout
end

#custom_pathObject (readonly)

Returns the value of attribute custom_path



12
13
14
# File 'lib/blueprint/compressor.rb', line 12

def custom_path
  @custom_path
end

#custom_tests_pathObject

Returns the value of attribute custom_tests_path



11
12
13
# File 'lib/blueprint/compressor.rb', line 11

def custom_tests_path
  @custom_tests_path
end

#destination_pathObject

Returns the value of attribute destination_path



12
13
14
# File 'lib/blueprint/compressor.rb', line 12

def destination_path
  @destination_path
end

#loaded_from_settingsObject (readonly)

Returns the value of attribute loaded_from_settings



12
13
14
# File 'lib/blueprint/compressor.rb', line 12

def loaded_from_settings
  @loaded_from_settings
end

#namespaceObject

Returns the value of attribute namespace



11
12
13
# File 'lib/blueprint/compressor.rb', line 11

def namespace
  @namespace
end

#pluginsObject

Returns the value of attribute plugins



11
12
13
# File 'lib/blueprint/compressor.rb', line 11

def plugins
  @plugins
end

#project_nameObject

Returns the value of attribute project_name



11
12
13
# File 'lib/blueprint/compressor.rb', line 11

def project_name
  @project_name
end

#script_nameObject (readonly)

Returns the value of attribute script_name



12
13
14
# File 'lib/blueprint/compressor.rb', line 12

def script_name
  @script_name
end

#semantic_classesObject

Returns the value of attribute semantic_classes



11
12
13
# File 'lib/blueprint/compressor.rb', line 11

def semantic_classes
  @semantic_classes
end

Instance Method Details

#generate!Object

generates output CSS based on any args passed in overwrites any existing CSS, as well as grid.png and tests



40
41
42
43
44
45
# File 'lib/blueprint/compressor.rb', line 40

def generate!
  output_header       # information to the user (in the console) describing custom settings
  generate_css_files  # loops through Blueprint::CSS_FILES to generate output CSS
  generate_tests      # updates HTML with custom namespaces in order to test the generated library.  TODO: have tests kick out to custom location
  output_footer       # informs the user that the CSS generation process is complete
end

#optionsObject

:nodoc:#



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/blueprint/compressor.rb', line 47

def options #:nodoc:#
  OptionParser.new do |o|
    o.set_summary_indent("  ")
    o.banner =    "Usage: #{@script_name} [options]"
    o.define_head "Blueprint Compressor"
    o.separator ""
    o.separator "options"
    o.on( "-fSETTINGS_FILE", "--settings_file=SETTINGS_FILE", String,
          "Specify a non-default settings file path.") { |file| @settings_file = file }
    o.on( "-oOUTPUT_PATH", "--output_path=OUTPUT_PATH", String,
          "Define a different path to output generated CSS files to.") { |path| self.destination_path = path }
    o.on( "-nBP_NAMESPACE", "--namespace=BP_NAMESPACE", String,
          "Define a namespace prepended to all Blueprint classes (e.g. .your-ns-span-24)") { |ns| self.namespace = ns }
    o.on( "-pPROJECT_NAME", "--project=PROJECT_NAME", String,
          "If using the settings.yml file, PROJECT_NAME is the project name you want to export") {|project| @project_name = project }
    o.on( "--column_width=COLUMN_WIDTH", Integer,
          "Set a new column width (in pixels) for the output grid") {|cw| self.custom_layout.column_width = cw }
    o.on( "--gutter_width=GUTTER_WIDTH", Integer,
          "Set a new gutter width (in pixels) for the output grid") {|gw| self.custom_layout.gutter_width = gw }
    o.on( "--column_count=COLUMN_COUNT", Integer,
          "Set a new column count for the output grid") {|cc| self.custom_layout.column_count = cc }
    o.on( "--custom_tests_path=TESTS_OUTPUT_PATH", String,
          "Define a different path to output generated test files to") {|test_path| self.custom_tests_path = test_path }
    #o.on("-v", "--verbose", "Turn on verbose output.") { |$verbose| }
    o.on("-h", "--help", "Show this help message.") { puts o; exit }
  end
end