Sha256: d6fea8b2b76a59cda453dafe8b6c19298a4c89b14a81f2abdc47af8459f11290
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
module SmallCage::Commands class Uri def self.execute(opts) self.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 @loader = SmallCage::Loader.new(target) @renderer = SmallCage::Renderer.new(@loader) print_uris end def print_uris @loader.each_smc_obj do |obj| print_default_or_template_uris(obj) end end private :print_uris def print_default_or_template_uris(obj) uris = @renderer.render(obj["template"] + ".uri", obj) if uris print_uri_templates(obj, uris.split(/\r\n|\r|\n/)) else puts obj["uri"] end end private :print_default_or_template_uris def print_uri_templates(obj, uris) uris = uris.map {|uri| uri.strip } base = obj['path'].parent uris.each_with_index do |uri, index| if uri.empty? puts "" else docpath = SmallCage::DocumentPath.create_with_uri(@loader.root, uri, base) puts docpath.uri end end end private :print_uri_templates end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
smallcage-0.2.6 | lib/smallcage/commands/uri.rb |
smallcage-0.2.5 | lib/smallcage/commands/uri.rb |