lib/fontcustom/options.rb in fontcustom-1.3.0.beta2 vs lib/fontcustom/options.rb in fontcustom-1.3.0.beta3
- old
+ new
@@ -48,11 +48,11 @@
# :config is a dir containing fontcustom.yml
elsif File.exists? File.join(path, "fontcustom.yml")
File.join path, "fontcustom.yml"
else
- raise Fontcustom::Error, "No configuration file found at `#{relative_to_root(path)}`."
+ raise Fontcustom::Error, "No configuration file found at `#{relative_path(path)}`."
end
else
# fontcustom.yml is in the project_root
if File.exists? File.join(@cli_options[:project_root], "fontcustom.yml")
File.join @cli_options[:project_root], "fontcustom.yml"
@@ -68,20 +68,20 @@
end
def load_config
@config_options = {}
if @cli_options[:config]
- say_message :debug, "Using settings from `#{relative_to_root(@cli_options[:config])}`." if @cli_options[:debug]
+ say_message :debug, "Using settings from `#{relative_path(@cli_options[:config])}`." if @cli_options[:debug]
begin
config = YAML.load File.open(@cli_options[:config])
if config # empty YAML returns false
@config_options = symbolize_hash(config)
else
- say_message :warn, "`#{relative_to_root(@cli_options[:config])}` was empty. Using defaults."
+ say_message :warn, "`#{relative_path(@cli_options[:config])}` was empty. Using defaults."
end
rescue Exception => e
- raise Fontcustom::Error, "Error parsing `#{relative_to_root(@cli_options[:config])}`:\n#{e.message}"
+ raise Fontcustom::Error, "Error parsing `#{relative_path(@cli_options[:config])}`:\n#{e.message}"
end
end
end
def merge_options
@@ -96,11 +96,11 @@
def clean_css_selector
unless @options[:css_selector].include? "{{glyph}}"
raise Fontcustom::Error,
"CSS selector `#{@options[:css_selector]}` should contain the \"{{glyph}}\" placeholder."
end
- @options[:css_selector] = @options[:css_selector].strip.gsub(/[^\{\}\w]/, "-")
+ @options[:css_selector] = @options[:css_selector].strip.gsub(/[^\.#\{\}\w]/, "-")
end
def set_manifest_path
@options[:manifest] = if ! @options[:manifest].nil?
expand_path @options[:manifest]
@@ -133,11 +133,11 @@
check_input input
@options[:input] = { :vectors => input, :templates => input }
end
if Dir[File.join(@options[:input][:vectors], "*.svg")].empty?
- raise Fontcustom::Error, "`#{relative_to_root(@options[:input][:vectors])}` doesn't contain any SVGs."
+ raise Fontcustom::Error, "`#{relative_path(@options[:input][:vectors])}` doesn't contain any SVGs."
end
end
def set_output_paths
if @options[:output].is_a? Hash
@@ -149,26 +149,26 @@
@options[:output].each do |key, val|
@options[:output][key] = expand_path val
if File.exists?(val) && ! File.directory?(val)
raise Fontcustom::Error,
- "Output `#{relative_to_root(@options[:output][key])}` exists but isn't a directory. Check your options."
+ "Output `#{relative_path(@options[:output][key])}` exists but isn't a directory. Check your options."
end
end
@options[:output][:css] ||= @options[:output][:fonts]
@options[:output][:preview] ||= @options[:output][:fonts]
else
if @options[:output].is_a? String
output = expand_path @options[:output]
if File.exists?(output) && ! File.directory?(output)
raise Fontcustom::Error,
- "Output `#{relative_to_root(output)}` exists but isn't a directory. Check your options."
+ "Output `#{relative_path(output)}` exists but isn't a directory. Check your options."
end
else
output = File.join @options[:project_root], @options[:font_name]
- say_message :debug, "Generated files will be saved to `#{relative_to_root(output)}/`." if @options[:debug]
+ say_message :debug, "Generated files will be saved to `#{relative_path(output)}/`." if @options[:debug]
end
@options[:output] = {
:fonts => output,
:css => output,
@@ -205,23 +205,23 @@
File.join template_path, "_fontcustom-bootstrap-ie7.scss"
else
template = File.expand_path File.join(@options[:input][:templates], template) unless template[0] == "/"
unless File.exists? template
raise Fontcustom::Error,
- "Custom template `#{relative_to_root(template)}` doesn't exist. Check your options."
+ "Custom template `#{relative_path(template)}` doesn't exist. Check your options."
end
template
end
end
end
def check_input(dir)
if ! File.exists? dir
raise Fontcustom::Error,
- "Input `#{relative_to_root(dir)}` doesn't exist. Check your options."
+ "Input `#{relative_path(dir)}` doesn't exist. Check your options."
elsif ! File.directory? dir
raise Fontcustom::Error,
- "Input `#{relative_to_root(dir)}` isn't a directory. Check your options."
+ "Input `#{relative_path(dir)}` isn't a directory. Check your options."
end
end
end
end