Sha256: b1b36a3f1f7e3eb6c86d7b3ab80957388f3f35c62fb0da56ded8dabb9f901e07

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 KB

Contents

module NightcrawlerSwift::CLI
  module Formatters
    class Basic

      def initialize runner
        @runner = runner
      end

      def command_list command
        array = command.new.execute
        array.each {|hash| @runner.log hash["name"]}
      end

      def command_download command
        filepath = @runner.argv.first
        @runner.log command.new.execute(filepath)
      end

      def command_upload command
        realpath = @runner.argv.shift
        swiftpath = @runner.argv.shift

        uploaded = command.new.execute swiftpath, File.open(File.expand_path(realpath), "r")
        @runner.log(uploaded ? "success" : "failure")
      end

      def command_delete command
        filepath = @runner.argv.first
        deleted = command.new.execute(filepath).to_json
        @runner.log(deleted ? "success" : "failure")
      end

      def command_metadata command
        filepath = @runner.argv.first
        metadata = command.new.execute(filepath)
        @runner.log JSON.pretty_generate(metadata)
      end

      def command_url_for command
        filepath = @runner.argv.first
        @runner.log command.new.execute(filepath)
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
nightcrawler_swift-1.0.0 lib/nightcrawler_swift/cli/formatters/basic.rb
nightcrawler_swift-0.11.1 lib/nightcrawler_swift/cli/formatters/basic.rb
nightcrawler_swift-0.11.0 lib/nightcrawler_swift/cli/formatters/basic.rb
nightcrawler_swift-0.10.0 lib/nightcrawler_swift/cli/formatters/basic.rb
nightcrawler_swift-0.9.0 lib/nightcrawler_swift/cli/formatters/basic.rb
nightcrawler_swift-0.8.1 lib/nightcrawler_swift/cli/formatters/basic.rb
nightcrawler_swift-0.8.0 lib/nightcrawler_swift/cli/formatters/basic.rb