Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
fix: rubocop warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Tully committed Jul 19, 2016
1 parent 8be576a commit 78640ed
Show file tree
Hide file tree
Showing 20 changed files with 269 additions and 289 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)
task :default => :spec
task default: :spec

def gemspec
@gemspec ||= eval(File.read('apiary.gemspec'), binding, '.gemspec')
Expand Down
46 changes: 23 additions & 23 deletions apiary.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'apiary/version'

Gem::Specification.new do |gem|
gem.name = "apiaryio"
gem.name = 'apiaryio'
gem.version = Apiary::VERSION
gem.authors = ["Apiary Ltd."]
gem.email = ["team@apiary.io"]
gem.authors = ['Apiary Ltd.']
gem.email = ['team@apiary.io']

gem.description = %q{Apiary.io CLI}
gem.summary = %q{Apiary.io CLI}
gem.homepage = "http://apiary.io"
gem.license = "MIT"
gem.description = 'Apiary.io CLI'
gem.summary = 'Apiary.io CLI'
gem.homepage = 'http://apiary.io'
gem.license = 'MIT'

gem.files = `git ls-files`.split($\)
gem.bindir = "bin"
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
gem.bindir = 'bin'
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]
gem.require_paths = ['lib']

gem.add_dependency "rest-client", "~> 1.8"
gem.add_dependency "rack", "~> 1.6.4"
gem.add_dependency "thor", "~> 0.19.1"
gem.add_dependency 'rest-client', '~> 1.8'
gem.add_dependency 'rack', '~> 1.6.4'
gem.add_dependency 'thor', '~> 0.19.1'

gem.add_runtime_dependency "json", "~> 1.8"
gem.add_runtime_dependency 'json', '~> 1.8'

gem.add_development_dependency "bundler", "~> 1.12"
gem.add_development_dependency "rake", "~> 10.0"
gem.add_development_dependency "rspec", "~> 3.4"
gem.add_development_dependency "webmock", "~> 2.0"
gem.add_development_dependency "yard", "~> 0.8"
gem.add_development_dependency "aruba", "~> 0.14"
gem.add_development_dependency "cucumber", "~> 2.0"
gem.add_development_dependency "rubocop", "~> 0.41.2"
gem.add_development_dependency 'bundler', '~> 1.12'
gem.add_development_dependency 'rake', '~> 10.0'
gem.add_development_dependency 'rspec', '~> 3.4'
gem.add_development_dependency 'webmock', '~> 2.0'
gem.add_development_dependency 'yard', '~> 0.8'
gem.add_development_dependency 'aruba', '~> 0.14'
gem.add_development_dependency 'cucumber', '~> 2.0'
gem.add_development_dependency 'rubocop', '~> 0.41.2'
end
2 changes: 1 addition & 1 deletion bin/apiary
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..','lib')))
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
require 'apiary'

Apiary::CLI.start
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ dependencies:

test:
override:
- bundle exec rubocop
- bundle exec rubocop --config .rubocop_todo.yml
- bundle exec rspec spec
- bundle exec cucumber
4 changes: 2 additions & 2 deletions features/step_definitions/file_content_step.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Then /^the output should contain the content of file "(.*)"$/ do |filename|
Then(/^the output should contain the content of file "(.*)"$/) do |filename|
expected = nil
cd('../../spec/fixtures') do
expected = File.read(filename)
end

actual = all_commands.map { |c| c.output }.join("\n")
actual = all_commands.map(&:output).join("\n")

expect(unescape_text(actual)).to include(unescape_text(expected))
end
14 changes: 7 additions & 7 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
@aruba_timeout_seconds = 45
end

Around('@needs_apiary_api_key') do |scenario, block|
Around('@needs_apiary_api_key') do |_scenario, block|
# DEBUG puts "Scenario #{scenario.name} wants APIARY_API_KEY."
original_value = ENV.delete("APIARY_API_KEY");
ENV["APIARY_API_KEY"] = "340bda135034529ab2abf341295c3aa2" # XXX
original_value = ENV.delete('APIARY_API_KEY')
ENV['APIARY_API_KEY'] = '340bda135034529ab2abf341295c3aa2' # XXX
block.call
ENV["APIARY_API_KEY"] = original_value
ENV['APIARY_API_KEY'] = original_value
end

Around('@doesnt_need_apiary_api_key') do |scenario, block|
Around('@doesnt_need_apiary_api_key') do |_scenario, block|
# DEBUG puts "Scenario #{scenario.name} doesn't want APIARY_API_KEY."
original_value = ENV.delete("APIARY_API_KEY");
original_value = ENV.delete('APIARY_API_KEY')
block.call
ENV["APIARY_API_KEY"] = original_value
ENV['APIARY_API_KEY'] = original_value
end
2 changes: 1 addition & 1 deletion lib/apiary/agent.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Apiary
USER_AGENT = "apiaryio-gem/#{Apiary::VERSION} (#{RUBY_PLATFORM}) ruby/#{RUBY_VERSION}"
USER_AGENT = "apiaryio-gem/#{Apiary::VERSION} (#{RUBY_PLATFORM}) ruby/#{RUBY_VERSION}".freeze

module_function

Expand Down
31 changes: 15 additions & 16 deletions lib/apiary/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,43 @@

module Apiary
class CLI < Thor

desc 'fetch', 'Fetch API Description Document from API_NAME.apiary.io'
method_option :api_name, :type => :string, :required => true
method_option :api_host, :type => :string, :banner => 'HOST', :desc => 'Specify apiary host'
method_option :output, :type => :string, :banner => 'FILE', :desc => 'Write API Description Document into specified file'
method_option :api_name, type: :string, required: true
method_option :api_host, type: :string, banner: 'HOST', desc: 'Specify apiary host'
method_option :output, type: :string, banner: 'FILE', desc: 'Write API Description Document into specified file'

def fetch
cmd = Apiary::Command::Fetch.new options
cmd.execute
end

desc 'preview', 'Show API documentation in default browser'
method_option :browser, :type => :string, :enum => %w(chrome safari firefox), :banner => 'chrome|safari|firefox', :desc => 'Show API documentation in specified browser'
method_option :output, :type => :string, :banner => 'FILE', :desc => 'Write generated HTML into specified file'
method_option :path, :type => :string, :desc => 'Specify path to API Description Document. When given a directory, it will look for apiary.apib or swagger.yaml file'
method_option :api_host, :type => :string, :banner => 'HOST', :desc => 'Specify apiary host'
method_option :server, :type => :boolean, :desc => 'Start standalone web server on port 8080'
method_option :port, :type => :numeric, :banner => 'PORT', :desc => 'Set port for --server option'
method_option :host, :type => :string, :desc => 'Set host for --server option'
method_option :browser, type: :string, enum: %w(chrome safari firefox), banner: 'chrome|safari|firefox', desc: 'Show API documentation in specified browser'
method_option :output, type: :string, banner: 'FILE', desc: 'Write generated HTML into specified file'
method_option :path, type: :string, desc: 'Specify path to API Description Document. When given a directory, it will look for apiary.apib or swagger.yaml file'
method_option :api_host, type: :string, banner: 'HOST', desc: 'Specify apiary host'
method_option :server, type: :boolean, desc: 'Start standalone web server on port 8080'
method_option :port, type: :numeric, banner: 'PORT', desc: 'Set port for --server option'
method_option :host, type: :string, desc: 'Set host for --server option'

def preview
cmd = Apiary::Command::Preview.new options
cmd.execute
end

desc 'publish', 'Publish API Description Document on docs.API_NAME.apiary.io'
method_option :message, :type => :string, :banner => 'COMMIT_MESSAGE', :desc => 'Publish with custom commit message'
method_option :path, :type => :string, :desc => 'Specify path to API Description Document. When given a directory, it will look for apiary.apib or swagger.yaml file'
method_option :api_host, :type => :string, :banner => 'HOST', :desc => 'Specify apiary host'
method_option :api_name, :type => :string, :required => true
method_option :message, type: :string, banner: 'COMMIT_MESSAGE', desc: 'Publish with custom commit message'
method_option :path, type: :string, desc: 'Specify path to API Description Document. When given a directory, it will look for apiary.apib or swagger.yaml file'
method_option :api_host, type: :string, banner: 'HOST', desc: 'Specify apiary host'
method_option :api_name, type: :string, required: true

def publish
cmd = Apiary::Command::Publish.new options
cmd.execute
end

desc 'version', 'Show version'
method_option :aliases => "-v"
method_option aliases: '-v'

def version
puts Apiary::VERSION
Expand Down
16 changes: 8 additions & 8 deletions lib/apiary/command/fetch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@
module Apiary::Command
# Retrieve blueprint from apiary
class Fetch

def initialize(opts)
@options = OpenStruct.new(opts)
@options.api_host ||= 'api.apiary.io'
@options.api_name ||= false
@options.api_key ||= ENV['APIARY_API_KEY']
@options.proxy ||= ENV['http_proxy']
@options.headers ||= {
:accept => 'text/html',
:content_type => 'text/plain',
:authentication => "Token #{@options.api_key}",
:user_agent => Apiary.user_agent
accept: 'text/html',
content_type: 'text/plain',
authentication: "Token #{@options.api_key}",
user_agent: Apiary.user_agent
}
end

def execute
response = fetch_from_apiary
if response.instance_of? String
puts response
end

return unless response.instance_of? String

puts response
end

def fetch_from_apiary
Expand Down
Loading

0 comments on commit 78640ed

Please sign in to comment.