Skip to content

Commit bf18609

Browse files
author
James Moriarty
committed
rubocop: fixes.
1 parent dd047b9 commit bf18609

37 files changed

+155
-132
lines changed

.rubocop.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Documentation:
2+
Enabled: false
3+
Metrics/LineLength:
4+
Max: 120

Gemfile

+8-7
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@ source 'https://rubygems.org'
22

33
ruby '2.3.0'
44

5-
gem 'sinatra', '~> 1'
5+
gem 'aws-sdk'
6+
gem 'google-cloud-storage'
67
gem 'grape', '~> 0.11'
7-
gem 'roar', '~> 1'
88
gem 'grape-roar', '~> 0.3'
9-
gem 'aws-sdk', '~> 2'
10-
gem 'google-cloud-storage'
119
gem 'mini_magick'
1210
gem 'puma'
11+
gem 'roar'
12+
gem 'sinatra'
1313

1414
group 'test' do
15-
gem 'rake', '~> 10.0'
15+
gem 'codeclimate-test-reporter'
1616
gem 'pry'
17-
gem 'rspec'
1817
gem 'rack-test'
18+
gem 'rake', '~> 10.0'
19+
gem 'rspec'
20+
gem 'rubocop', require: false
1921
gem 'simplecov'
20-
gem 'codeclimate-test-reporter'
2122
end

Gemfile.lock

+17-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ GEM
88
tzinfo (~> 1.1)
99
addressable (2.5.0)
1010
public_suffix (~> 2.0, >= 2.0.2)
11+
ast (2.3.0)
1112
aws-sdk (2.5.5)
1213
aws-sdk-resources (= 2.5.5)
1314
aws-sdk-core (2.5.5)
@@ -95,6 +96,9 @@ GEM
9596
mustermann19 (0.4.4)
9697
enumerable-lazy
9798
os (0.9.6)
99+
parser (2.3.3.0)
100+
ast (~> 2.2)
101+
powerpack (0.1.1)
98102
pry (0.10.3)
99103
coderay (~> 1.1.0)
100104
method_source (~> 0.8.1)
@@ -108,6 +112,7 @@ GEM
108112
rack
109113
rack-test (0.6.3)
110114
rack (>= 1.0)
115+
rainbow (2.1.0)
111116
rake (10.5.0)
112117
representable (2.3.0)
113118
uber (~> 0.0.7)
@@ -127,6 +132,13 @@ GEM
127132
diff-lcs (>= 1.2.0, < 2.0)
128133
rspec-support (~> 3.4.0)
129134
rspec-support (3.4.1)
135+
rubocop (0.46.0)
136+
parser (>= 2.3.1.1, < 3.0)
137+
powerpack (~> 0.1)
138+
rainbow (>= 1.99.1, < 3.0)
139+
ruby-progressbar (~> 1.7)
140+
unicode-display_width (~> 1.0, >= 1.0.1)
141+
ruby-progressbar (1.8.1)
130142
signet (0.7.3)
131143
addressable (~> 2.3)
132144
faraday (~> 0.9)
@@ -147,6 +159,7 @@ GEM
147159
tzinfo (1.2.2)
148160
thread_safe (~> 0.1)
149161
uber (0.0.15)
162+
unicode-display_width (1.1.1)
150163
virtus (1.0.5)
151164
axiom-types (~> 0.1)
152165
coercible (~> 1.0)
@@ -157,7 +170,7 @@ PLATFORMS
157170
ruby
158171

159172
DEPENDENCIES
160-
aws-sdk (~> 2)
173+
aws-sdk
161174
codeclimate-test-reporter
162175
google-cloud-storage
163176
grape (~> 0.11)
@@ -167,10 +180,11 @@ DEPENDENCIES
167180
puma
168181
rack-test
169182
rake (~> 10.0)
170-
roar (~> 1)
183+
roar
171184
rspec
185+
rubocop
172186
simplecov
173-
sinatra (~> 1)
187+
sinatra
174188

175189
BUNDLED WITH
176190
1.11.2

Rakefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ begin
33

44
RSpec::Core::RakeTask.new(:spec)
55

6-
task :default => :spec
6+
task default: :spec
77
rescue LoadError
8-
# no rspec available
8+
puts 'no rspec available'
99
end

bin/console

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env ruby
22

3-
require "bundler/setup"
4-
require "poto"
3+
require 'bundler/setup'
4+
require 'poto'
55

66
# You can add fixtures and/or initialization code here to make experimenting
77
# with your gem easier. You can also use a different console, if you like.
88

9-
require "pry"
9+
require 'pry'
1010
Pry.start

bin/poto-aws-s3

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env ruby
22

3-
require "rack"
3+
require 'rack'
44

5-
app, options = Rack::Builder.new_from_string <<-EOF
5+
app, _options = Rack::Builder.new_from_string <<-EOF
66
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
77
88
require "poto"
@@ -25,5 +25,5 @@ EOF
2525

2626
Rack::Server.start(
2727
app: app,
28-
Port: ENV.fetch("PORT", 9292)
28+
Port: ENV.fetch('PORT', 9292)
2929
)

bin/poto-google-cloud-storage

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env ruby
22

3-
require "rack"
3+
require 'rack'
44

5-
app, options = Rack::Builder.new_from_string <<-EOF
5+
app, _options = Rack::Builder.new_from_string <<-EOF
66
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
77
88
require "poto"
@@ -30,5 +30,5 @@ EOF
3030

3131
Rack::Server.start(
3232
app: app,
33-
Port: ENV.fetch("PORT", 9292)
33+
Port: ENV.fetch('PORT', 9292)
3434
)

lib/poto.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
$LOAD_PATH.unshift File.dirname(__FILE__)
22

3-
require "active_support"
4-
require "active_support/core_ext/object/to_param"
5-
require "active_support/core_ext/object/try"
6-
require "poto/version"
7-
require "poto/api"
8-
require "poto/image_proxy"
9-
require "poto/app"
3+
require 'active_support'
4+
require 'active_support/core_ext/object/to_param'
5+
require 'active_support/core_ext/object/try'
6+
require 'poto/version'
7+
require 'poto/api'
8+
require 'poto/image_proxy'
9+
require 'poto/app'
1010

1111
module Poto; end

lib/poto/api.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
require "base64"
2-
require "grape"
3-
require "grape/roar"
4-
require "poto/file_repository/proxy"
5-
require "poto/representers/file_representer"
6-
require "poto/representers/file_collection_representer"
1+
require 'base64'
2+
require 'grape'
3+
require 'grape/roar'
4+
require 'poto/file_repository/proxy'
5+
require 'poto/representers/file_representer'
6+
require 'poto/representers/file_collection_representer'
77

88
module Poto
99
class API < Grape::API
10-
content_type :json, "application/hal+json"
10+
content_type :json, 'application/hal+json'
1111
format :json
1212
formatter :json, Grape::Formatter::Roar
1313

@@ -30,10 +30,10 @@ def url_for(opts, path, query = {})
3030
URI::Generic.build(
3131
host: request.host,
3232
port: request.port,
33-
path: File.join(opts[:env]["SCRIPT_NAME"], path),
33+
path: File.join(opts[:env]['SCRIPT_NAME'], path),
3434
query: query.to_param,
3535
scheme: request.scheme
36-
).to_s.gsub(/\?$/, "")
36+
).to_s.gsub(/\?$/, '')
3737
end
3838

3939
def id

lib/poto/app.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
require "sinatra"
1+
require 'sinatra'
22

33
module Poto
44
class App < Sinatra::Base
5-
set :public_folder, File.join(File.dirname(__FILE__), "..", "..", "public")
5+
set :public_folder, File.join(File.dirname(__FILE__), '..', '..', 'public')
66

7-
get("/") do
8-
File.read(File.join("public", "index.html"))
7+
get('/') do
8+
File.read(File.join('public', 'index.html'))
99
end
1010
end
1111
end

lib/poto/ext/open_uri.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module OpenURI
22
class << self
3-
def redirectable?(*); true; end
3+
def redirectable?(*)
4+
true
5+
end
46
end
57
end

lib/poto/file_repository/aws/s3.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
require "base64"
2-
require "poto/file_repository/aws/s3/client"
3-
require "poto/file_repository/aws/s3/file_collection_mapper"
1+
require 'base64'
2+
require 'poto/file_repository/aws/s3/client'
3+
require 'poto/file_repository/aws/s3/file_collection_mapper'
44

55
module Poto
66
module FileRepository
@@ -21,7 +21,7 @@ def all(prefix:, page:, per_page:)
2121
objects = client.objects(
2222
page: page,
2323
per_page: per_page,
24-
prefix: prefix,
24+
prefix: prefix
2525
)
2626

2727
FileCollectionMapper.new(objects).call

lib/poto/file_repository/aws/s3/client.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require "aws-sdk"
1+
require 'aws-sdk'
22

33
module Poto
44
module FileRepository
@@ -16,7 +16,7 @@ def objects(prefix:, page:, per_page:)
1616
bucket: bucket,
1717
marker: page,
1818
max_keys: per_page,
19-
prefix: prefix,
19+
prefix: prefix
2020
)
2121
end
2222

lib/poto/file_repository/aws/s3/file_collection_mapper.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
require "poto/file_repository/aws/s3/file_mapper"
2-
require "poto/file_repository/file_collection"
1+
require 'poto/file_repository/aws/s3/file_mapper'
2+
require 'poto/file_repository/file_collection'
33

44
module Poto
55
module FileRepository

lib/poto/file_repository/aws/s3/file_mapper.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
require "base64"
1+
require 'base64'
22

3-
require "poto/file_repository/file"
3+
require 'poto/file_repository/file'
44

55
module Poto
66
module FileRepository

lib/poto/file_repository/file.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Poto
22
module FileRepository
3-
File = Struct.new("File", :id, :name, :size)
3+
File = Struct.new('File', :id, :name, :size)
44
end
55
end
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Poto
22
module FileRepository
3-
FileCollection = Struct.new("FileCollection", :files, :page, :next_page)
3+
FileCollection = Struct.new('FileCollection', :files, :page, :next_page)
44
end
55
end

lib/poto/file_repository/google/cloud/storage.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
require "base64"
2-
require "google/cloud/storage"
1+
require 'base64'
2+
require 'google/cloud/storage'
33

4-
require "poto/file_repository/google/cloud/storage/file_collection_mapper"
4+
require 'poto/file_repository/google/cloud/storage/file_collection_mapper'
55

66
module Poto
77
module FileRepository

lib/poto/file_repository/google/cloud/storage/file_collection_mapper.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
require "base64"
1+
require 'base64'
22

3-
require "poto/file_repository/file_collection"
4-
require "poto/file_repository/google/cloud/storage/file_mapper"
3+
require 'poto/file_repository/file_collection'
4+
require 'poto/file_repository/google/cloud/storage/file_mapper'
55

66
module Poto
77
module FileRepository

lib/poto/file_repository/google/cloud/storage/file_mapper.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
require "base64"
1+
require 'base64'
22

3-
require "poto/file_repository/file"
3+
require 'poto/file_repository/file'
44

55
module Poto
66
module FileRepository

lib/poto/file_repository/proxy.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require "poto/file_repository/dsl"
1+
require 'poto/file_repository/dsl'
22

33
module Poto
44
module FileRepository

lib/poto/image_proxy.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
require "sinatra"
2-
require "tmpdir"
1+
require 'sinatra'
2+
require 'tmpdir'
33

4-
require "poto/services/download"
5-
require "poto/services/file_cache"
6-
require "poto/services/resize"
4+
require 'poto/services/download'
5+
require 'poto/services/file_cache'
6+
require 'poto/services/resize'
77

88
module Poto
99
class ImageProxy < Sinatra::Base
1010
set :cache_path, Dir.tmpdir
1111

1212
helpers do
1313
def src
14-
URI(params["src"].gsub(/\A\/\//, "http://"))
14+
URI(params['src'].gsub(%r{\A\/\/}, 'http://'))
1515
end
1616

1717
def width
18-
params["width"].to_i
18+
params['width'].to_i
1919
end
2020

2121
def height
22-
params["height"].to_i
22+
params['height'].to_i
2323
end
2424

2525
def cache(key, &set)
@@ -35,7 +35,7 @@ def resize(path, height, width)
3535
end
3636
end
3737

38-
get("/") do
38+
get('/') do
3939
src_path = cache(src.path) { download(src) }
4040
dst_path = cache("#{src_path}#{width}x#{height}") { resize(src_path, height, width) }
4141

0 commit comments

Comments
 (0)