lib/smallcage/commands/uri.rb in smallcage-0.2.6 vs lib/smallcage/commands/uri.rb in smallcage-0.2.7

- old
+ new

@@ -1,21 +1,18 @@ module SmallCage::Commands class Uri - def self.execute(opts) - self.new(opts).execute + new(opts).execute end def initialize(opts) @opts = opts end def execute target = Pathname.new(@opts[:path]) - unless target.exist? - raise "target directory or file does not exist.: " + target.to_s - end + fail 'target directory or file does not exist.: ' + target.to_s unless target.exist? @loader = SmallCage::Loader.new(target) @renderer = SmallCage::Renderer.new(@loader) print_uris end @@ -26,24 +23,24 @@ end end private :print_uris def print_default_or_template_uris(obj) - uris = @renderer.render(obj["template"] + ".uri", obj) + uris = @renderer.render(obj['template'] + '.uri', obj) if uris print_uri_templates(obj, uris.split(/\r\n|\r|\n/)) else - puts obj["uri"] + puts obj['uri'] end end private :print_default_or_template_uris def print_uri_templates(obj, uris) - uris = uris.map {|uri| uri.strip } + uris = uris.map { |uri| uri.strip } base = obj['path'].parent uris.each_with_index do |uri, index| if uri.empty? - puts "" + puts '' else docpath = SmallCage::DocumentPath.create_with_uri(@loader.root, uri, base) puts docpath.uri end end