Sha256: 4d7220590887fecb311f661984382b3dc0f09d975fd90451ba55282fa000aaa2

Contents?: true

Size: 1.28 KB

Versions: 16

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

require 'rack'
require 'thor'
require 'yaml'

module Weneedfeed
  class Command < ::Thor
    class << self
      # @note Override for thor breaking change.
      #   See https://github.com/erikhuda/thor/issues/244.
      def exit_on_failure?
        true
      end
    end

    desc(
      'build',
      'Build static files.'
    )

    method_option(
      :base_url,
      desc: 'Base URL where to locate built files. (e.g. `"https://user.github.io/repo"`)',
      required: true,
      type: :string
    )

    method_option(
      :schema_path,
      default: 'weneedfeed.yml',
      desc: 'Path to weneedfeed YAML schema file.',
      type: :string
    )

    # @param [String] base_url
    # @param [String] schema_path
    def build
      ::Weneedfeed::Capture.call(
        base_url: options[:base_url],
        schema_path: options[:schema_path]
      )
    end

    desc(
      'server',
      'Run HTTP server.'
    )

    method_option(
      :schema_path,
      default: 'weneedfeed.yml',
      desc: 'Path to weneedfeed YAML schema file.',
      type: :string
    )

    def server
      schema = ::YAML.load_file(options[:schema_path])
      application = Weneedfeed::Application.new(schema: schema)
      ::Rack::Handler.default.run(application)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
weneedfeed-0.13.0 lib/weneedfeed/command.rb
weneedfeed-0.12.0 lib/weneedfeed/command.rb
weneedfeed-0.11.0 lib/weneedfeed/command.rb
weneedfeed-0.10.0 lib/weneedfeed/command.rb
weneedfeed-0.9.2 lib/weneedfeed/command.rb
weneedfeed-0.9.1 lib/weneedfeed/command.rb
weneedfeed-0.9.0 lib/weneedfeed/command.rb
weneedfeed-0.8.0 lib/weneedfeed/command.rb
weneedfeed-0.7.2 lib/weneedfeed/command.rb
weneedfeed-0.7.1 lib/weneedfeed/command.rb
weneedfeed-0.7.0 lib/weneedfeed/command.rb
weneedfeed-0.6.1 lib/weneedfeed/command.rb
weneedfeed-0.6.0 lib/weneedfeed/command.rb
weneedfeed-0.5.0 lib/weneedfeed/command.rb
weneedfeed-0.4.1 lib/weneedfeed/command.rb
weneedfeed-0.4.0 lib/weneedfeed/command.rb