Skip to content

Commit

Permalink
Some code improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Schlegel committed Jun 15, 2015
1 parent 28274f7 commit 4444e08
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
6 changes: 2 additions & 4 deletions lib/sassconf.rb
Expand Up @@ -3,8 +3,6 @@
require 'sassconf/sass_executor'
require 'optparse'
require 'ostruct'
require 'filewatcher'

module Sassconf
extend Logging

Expand All @@ -19,7 +17,7 @@ module HelpText
.newline.blank(3) { 'Email: develop@schlegel11.de' }
.paragraph
REQUIRED = 'Required:'
OPTIONAL = 'Optional:'.newline(1, :left)
OPTIONAL = String.newline { 'Optional:' }
end


Expand Down Expand Up @@ -89,7 +87,7 @@ def self.start

def live_reload(activate)
Util.pre_check(activate.boolean?, 'Activate is no boolean type.')
if (activate)
if activate
@@config_manager.watch_update(@@option_args.config_path) do |filename|
begin
logger.info("Config reload: #{filename}")
Expand Down
2 changes: 1 addition & 1 deletion lib/sassconf/config_manager.rb
Expand Up @@ -27,7 +27,7 @@ def watch_update(file_path)
Util.pre_check((file_path.string? and file_path.not_nil_or_empty? and File.exist?(file_path)), "\"rb\" file path is no string, nil, empty or doesn't exist.")
Util.pre_check(block_given?, 'No block is given.')
FileWatcher.new([file_path]).watch do |filename, event|
if (event == :changed)
if event == :changed
yield(filename)
end
end
Expand Down
14 changes: 13 additions & 1 deletion lib/sassconf/core_extensions.rb
Expand Up @@ -6,7 +6,7 @@ def self.def_false(*args)
args.each { |arg| alias_method arg, :false_ }
end

def false_()
def false_
false
end
end
Expand Down Expand Up @@ -42,6 +42,18 @@ module ClassMethods
def empty
''
end

def newline(count = 1, side = :left, &block)
new.newline(count, side, &block)
end

def paragraph(count = 1, side = :left, &block)
new.paragraph(count, side, &block)
end

def blank(count = 1, side = :left, &block)
new.blank(count, side, &block)
end
end

def base_manipulation(char, count, side)
Expand Down
2 changes: 1 addition & 1 deletion lib/sassconf/sass_executor.rb
Expand Up @@ -25,7 +25,7 @@ def create_argument_string(argument_hash)
end

def create_all_argument_strings(argument_value_hash, argument_hash)
create_argument_with_value_string(argument_value_hash).concat(' ').concat(create_argument_string(argument_hash))
create_argument_with_value_string(argument_value_hash).concat(String.blank).concat(create_argument_string(argument_hash))
end

def execute(argument_string)
Expand Down
6 changes: 3 additions & 3 deletions lib/sassconf/util.rb
Expand Up @@ -43,11 +43,11 @@ module CrossSystem
def process_childs(*cmds)
Util.pre_check((cmds.any? and cmds.all? { |elem| elem.string? }), 'cmds is empty or element is no string.')

out, status = Open3.capture2(*cmds)
out, _ = Open3.capture2(*cmds)
childs = out.each_line.map { |elem| elem.to_i }.select { |elem| elem != 0 }
if block_given?
childs.each do |elem|
pid = elem.to_i;
pid = elem.to_i
yield(pid)
end
end
Expand All @@ -56,7 +56,7 @@ def process_childs(*cmds)
def process_exists?(*cmds)
Util.pre_check((cmds.any? and cmds.all? { |elem| elem.string? }), 'cmds is empty or element is no string.')

out, status = Open3.capture2(*cmds)
out, _ = Open3.capture2(*cmds)
out.each_line.select { |elem| elem.to_i != 0 }.any?
end
end
Expand Down

0 comments on commit 4444e08

Please sign in to comment.