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

Commit 085c8c4

Browse files
committed
Fixed small issues in coding standards.
1 parent a72ae73 commit 085c8c4

File tree

6 files changed

+46
-46
lines changed

6 files changed

+46
-46
lines changed

lib/apiary.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'rubygems'
2-
require "apiary/version"
3-
require "apiary/cli"
4-
require "apiary/common"
2+
require 'apiary/version'
3+
require 'apiary/cli'
4+
require 'apiary/common'
55

66
module Apiary
77
end

lib/apiary/cli.rb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
# encoding: utf-8
2-
require "thor"
3-
require "apiary/command/fetch"
4-
require "apiary/command/preview"
5-
require "apiary/command/publish"
2+
require 'thor'
3+
require 'apiary/command/fetch'
4+
require 'apiary/command/preview'
5+
require 'apiary/command/publish'
66

77
module Apiary
88
class CLI < Thor
99

10-
desc "fetch", "Fetch apiary.apib from API_NAME.apiary.io"
10+
desc 'fetch', 'Fetch apiary.apib from API_NAME.apiary.io'
1111
method_option :api_name, :type => :string, :required => true, :default => ''
12-
method_option :api_host, :type => :string, :banner => "HOST", :desc => "Specify apiary host"
13-
method_option :output, :type => :string, :banner => "FILE", :desc => "Write apiary.apib into specified file"
12+
method_option :api_host, :type => :string, :banner => 'HOST', :desc => 'Specify apiary host'
13+
method_option :output, :type => :string, :banner => 'FILE', :desc => 'Write apiary.apib into specified file'
1414

1515
def fetch
1616
cmd = Apiary::Command::Fetch.new options
1717
cmd.execute
1818
end
1919

20-
desc "preview", "Show API documentation in default browser"
21-
method_option :browser, :type => :string, :enum => %w(chrome safari firefox), :banner => "chrome|safari|firefox", :desc => "Show API documentation in specified browser"
22-
method_option :output, :type => :string, :banner => "FILE", :desc => "Write generated HTML into specified file"
23-
method_option :path, :type => :string, :desc => "Specify path to blueprint file", :default => 'apiary.apib'
24-
method_option :api_host, :type => :string, :banner => "HOST", :desc => "Specify apiary host"
25-
method_option :server, :type => :boolean, :desc => "Start standalone web server on port 8080"
26-
method_option :port, :type => :numeric, :banner => "PORT", :desc => "Set port for --server option"
20+
desc 'preview', 'Show API documentation in default browser'
21+
method_option :browser, :type => :string, :enum => %w(chrome safari firefox), :banner => 'chrome|safari|firefox', :desc => 'Show API documentation in specified browser'
22+
method_option :output, :type => :string, :banner => 'FILE', :desc => 'Write generated HTML into specified file'
23+
method_option :path, :type => :string, :desc => 'Specify path to blueprint file', :default => 'apiary.apib'
24+
method_option :api_host, :type => :string, :banner => 'HOST', :desc => 'Specify apiary host'
25+
method_option :server, :type => :boolean, :desc => 'Start standalone web server on port 8080'
26+
method_option :port, :type => :numeric, :banner => 'PORT', :desc => 'Set port for --server option'
2727

2828
def preview
2929
cmd = Apiary::Command::Preview.new options
3030
cmd.execute
3131
end
3232

33-
desc "publish", "Publish apiary.apib on docs.API_NAME.apiary.io"
34-
method_option :message, :type => :string, :banner => "COMMIT_MESSAGE", :desc => "Publish with custom commit message"
35-
method_option :path, :type => :string, :desc => "Specify path to blueprint file", :default => 'apiary.apib'
36-
method_option :api_host, :type => :string, :banner => "HOST", :desc => "Specify apiary host"
33+
desc 'publish', 'Publish apiary.apib on docs.API_NAME.apiary.io'
34+
method_option :message, :type => :string, :banner => 'COMMIT_MESSAGE', :desc => 'Publish with custom commit message'
35+
method_option :path, :type => :string, :desc => 'Specify path to blueprint file', :default => 'apiary.apib'
36+
method_option :api_host, :type => :string, :banner => 'HOST', :desc => 'Specify apiary host'
3737
method_option :api_name, :type => :string, :required => true, :default => ''
3838

3939
def publish
4040
cmd = Apiary::Command::Publish.new options
4141
cmd.execute
4242
end
4343

44-
desc "version", "Show version"
44+
desc 'version', 'Show version'
4545
method_option :aliases => "-v"
4646

4747
def version

lib/apiary/command/fetch.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ module Apiary
88
module Command
99
# Retrieve blueprint from apiary
1010
class Fetch
11-
1211
attr_reader :options
1312

1413
# TODO: use OpenStruct to store @options
@@ -43,10 +42,10 @@ def fetch_from_apiary
4342
end
4443

4544
response = self.query_apiary(@options.api_host, @options.path)
46-
unless @options.output
47-
response["code"]
48-
else
45+
if @options.output
4946
write_generated_path(response["code"], @options.output)
47+
else
48+
response["code"]
5049
end
5150
end
5251

lib/apiary/command/preview.rb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ class Preview
1919
PREVIEW_TEMPLATE_PATH = "#{File.expand_path File.dirname(__FILE__)}/../file_templates/preview.erb"
2020

2121
BROWSERS = {
22-
:safari => "Safari",
23-
:chrome => "Google Chrome",
24-
:firefox => "Firefox"
22+
:safari => 'Safari',
23+
:chrome => 'Google Chrome',
24+
:firefox => 'Firefox'
2525
}
2626

2727
attr_reader :options
2828

2929
def initialize(opts)
3030
@options = OpenStruct.new(opts)
31-
@options.path ||= "apiary.apib"
32-
@options.api_host ||= "api.apiary.io"
33-
@options.headers ||= {:accept => "text/html", :content_type => "text/plain"}
31+
@options.path ||= 'apiary.apib'
32+
@options.api_host ||= 'api.apiary.io'
33+
@options.headers ||= {:accept => 'text/html', :content_type => 'text/plain'}
3434
@options.port ||= 8080
3535
@options.proxy ||= ENV['http_proxy']
3636
@options.server ||= false
3737

38-
validate_apib_file()
38+
validate_apib_file
3939
end
4040

4141
def execute
@@ -75,7 +75,7 @@ def rack_app(&block)
7575

7676
def run_server
7777
app = self.rack_app do
78-
self.generate
78+
generate
7979
end
8080

8181
Rack::Server.start(:Port => @options.port, :app => app)
@@ -91,11 +91,11 @@ def write_generated_path(path, outfile)
9191
end
9292

9393
def generate
94-
template = load_preview_template()
94+
template = load_preview_template
9595

9696
data = {
97-
title: File.basename(@options.path, ".*"),
98-
blueprint: load_blueprint()
97+
title: File.basename(@options.path, '.*'),
98+
blueprint: load_blueprint
9999
}
100100

101101
template.result(binding)
@@ -104,27 +104,27 @@ def generate
104104
def generate_static
105105
preview_string = generate
106106

107-
File.open(preview_path, "w") do |file|
107+
File.open(preview_path, 'w') do |file|
108108
file.write preview_string
109109
file.flush
110110
@options.output ? write_generated_path(file.path, @options.output) : open_generated_page(file.path)
111111
end
112112
end
113113

114114
def load_blueprint
115-
file = File.open @options.path, "r"
115+
file = File.open @options.path, 'r'
116116
file.read
117117
end
118118

119119
def preview_path
120-
basename = File.basename(@options.path, ".*")
121-
temp = Dir.tmpdir()
120+
basename = File.basename(@options.path, '.*')
121+
temp = Dir.tmpdir
122122
"#{temp}/#{basename}-preview.html"
123123
end
124124

125125
def load_preview_template
126-
file = File.open(PREVIEW_TEMPLATE_PATH, "r")
127-
template_string = file.read()
126+
file = File.open(PREVIEW_TEMPLATE_PATH, 'r')
127+
template_string = file.read
128128
ERB.new(template_string)
129129
end
130130

lib/apiary/file_templates/preview.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
});
1313
</script>
1414
</body>
15-
</html>
15+
</html>

lib/apiary/helpers/javascript_helper.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
# encoding: utf-8
12
module Apiary
2-
module Helpers
3+
module Helpers
34
module JavascriptHelper
45
JS_ESCAPE_MAP = {
56
'\\' => '\\\\',
@@ -25,4 +26,4 @@ def escape_javascript(javascript)
2526
alias_method :j, :escape_javascript
2627
end
2728
end
28-
end
29+
end

0 commit comments

Comments
 (0)