Skip to content

Commit d2fa329

Browse files
committed
Add Rubocop corrections
1 parent 4c7e7e5 commit d2fa329

File tree

5 files changed

+68
-40
lines changed

5 files changed

+68
-40
lines changed

.rubocop.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Opt in to new cops by default
2+
AllCops:
3+
NewCops: enable
4+
5+
# Allow the Podspec filename to match the project
6+
Naming/FileName:
7+
Exclude:
8+
- 'Gridicons.podspec'
9+
10+
# Override the maximum block length (some pods have long definitions)
11+
Metrics/BlockLength:
12+
Max: 256
13+
14+
# Override the maximum line length
15+
Layout/LineLength:
16+
Max: 160
17+
18+
require: rubocop-rake

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ source 'https://rubygems.org'
55
gem 'cocoapods', '~> 1.10'
66
gem 'cocoapods-check', '~> 1.1'
77
gem 'fastlane', '~> 2.189'
8-
gem 'rubocop', '~> 1.18'
98
gem 'rake', '~> 13'
9+
gem 'rubocop', '~> 1.18'
10+
gem 'rubocop-rake', '~> 0.6.0'

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ GEM
240240
unicode-display_width (>= 1.4.0, < 3.0)
241241
rubocop-ast (1.9.1)
242242
parser (>= 3.0.1.1)
243+
rubocop-rake (0.6.0)
244+
rubocop (~> 1.0)
243245
ruby-macho (1.4.0)
244246
ruby-progressbar (1.11.0)
245247
ruby2_keywords (0.0.5)
@@ -294,6 +296,7 @@ DEPENDENCIES
294296
fastlane (~> 2.189)
295297
rake (~> 13)
296298
rubocop (~> 1.18)
299+
rubocop-rake (~> 0.6.0)
297300

298301
BUNDLED WITH
299302
2.2.23

Gridicons.podspec

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1+
# frozen_string_literal: true
2+
13
Pod::Spec.new do |s|
2-
s.name = "Gridicons"
3-
s.version = "1.1.0"
4+
s.name = 'Gridicons'
5+
s.version = '1.1.0'
46

5-
s.summary = "Gridicons is a tiny framework which generates Gridicon images at any resolution."
7+
s.summary = 'Gridicons is a tiny framework which generates Gridicon images at any resolution.'
68
s.description = <<-DESC
79
This framework contains a pack of icons – mainly ones used in the WordPress apps –
810
that can be reused and scaled at any resolution.
9-
DESC
11+
DESC
1012

11-
s.homepage = "https://github.com/Automattic/Gridicons-iOS"
12-
s.license = { :type => "GPLv2", :file => "LICENSE.md" }
13-
s.author = { "Automattic" => "[email protected]" }
14-
s.social_media_url = "https://twitter.com/automattic"
13+
s.homepage = 'https://github.com/Automattic/Gridicons-iOS'
14+
s.license = { type: 'GPLv2', file: 'LICENSE.md' }
15+
s.author = { 'Automattic' => '[email protected]' }
16+
s.social_media_url = 'https://twitter.com/automattic'
1517

16-
s.platform = :ios, "11.0"
18+
s.platform = :ios, '11.0'
1719
s.swift_version = '5.0'
1820

19-
s.source = { :git => "https://github.com/Automattic/Gridicons-iOS.git", :tag => s.version.to_s }
20-
s.source_files = "Gridicons/Gridicons/**/*.swift"
21+
s.source = { git: 'https://github.com/Automattic/Gridicons-iOS.git', tag: s.version.to_s }
22+
s.source_files = 'Gridicons/Gridicons/**/*.swift'
2123
s.resource_bundles = {
22-
'Gridicons': [
23-
'Gridicons/Gridicons/*.{xcassets}',
24+
Gridicons: [
25+
'Gridicons/Gridicons/*.{xcassets}'
2426
]
2527
}
2628
end

Rakefile

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,89 @@
1-
SWIFTGEN_VERSION="6.1.0"
1+
# frozen_string_literal: true
2+
3+
SWIFTGEN_VERSION = '6.1.0'
24

35
require 'fileutils'
46
require 'tmpdir'
57
require 'rake/clean'
6-
PROJECT_DIR = File.expand_path(File.dirname(__FILE__))
8+
PROJECT_DIR = __dir__
79

810
task default: %w[gen]
911

10-
desc "Install required dependencies"
11-
task :dependencies => %w[dependencies:check]
12+
desc 'Install required dependencies'
13+
task dependencies: %w[dependencies:check]
1214

1315
namespace :dependencies do
14-
task :check => %w[gen:check]
16+
task check: %w[gen:check]
1517

1618
namespace :gen do
17-
19+
desc 'Install SwiftGen if needed'
1820
task :check do
1921
if swiftgen_needs_install
20-
dependency_failed("SwiftGen")
21-
Rake::Task["dependencies:gen:install"].invoke
22+
dependency_failed('SwiftGen')
23+
Rake::Task['dependencies:gen:install'].invoke
2224
end
2325
end
2426

27+
desc 'Install SwiftGen'
2528
task :install do
2629
puts "Installing SwiftGen #{SWIFTGEN_VERSION} into #{swiftgen_path}"
2730
Dir.mktmpdir do |tmpdir|
2831
zipfile = "#{tmpdir}/swiftgen-#{SWIFTGEN_VERSION}.zip"
29-
sh "curl --fail --location -o #{zipfile} https://github.com/SwiftGen/SwiftGen/releases/download/#{SWIFTGEN_VERSION}/swiftgen-#{SWIFTGEN_VERSION}.zip || true"
30-
if File.exists?(zipfile)
32+
source = "https://github.com/SwiftGen/SwiftGen/releases/download/#{SWIFTGEN_VERSION}/swiftgen-#{SWIFTGEN_VERSION}.zip"
33+
sh "curl --fail --location -o #{zipfile} #{source} || true"
34+
if File.exist?(zipfile)
3135
zipdir = "#{tmpdir}/swiftgen-#{SWIFTGEN_VERSION}"
3236
sh "unzip -q #{zipfile} -d #{zipdir}"
3337
Dir.chdir(zipdir) do
3438
puts "Copying SwiftGen #{SWIFTGEN_VERSION} into #{swiftgen_path}"
3539
FileUtils.remove_entry_secure(swiftgen_path) if Dir.exist?(swiftgen_path)
36-
FileUtils.mkdir_p("#{swiftgen_path}")
37-
FileUtils.cp_r("#{zipdir}/lib", "#{swiftgen_path}")
38-
FileUtils.cp_r("#{zipdir}/bin", "#{swiftgen_path}")
40+
FileUtils.mkdir_p(swiftgen_path.to_s)
41+
FileUtils.cp_r("#{zipdir}/lib", swiftgen_path.to_s)
42+
FileUtils.cp_r("#{zipdir}/bin", swiftgen_path.to_s)
3943
end
4044
end
4145
end
4246
end
43-
CLOBBER << "vendor/swiftgen"
47+
CLOBBER << 'vendor/swiftgen'
4448
end
45-
4649
end
4750

48-
CLOBBER << "vendor"
51+
CLOBBER << 'vendor'
4952

50-
desc "Regenerates the master Gridicon enum from PDF assets"
51-
task :gen => %w[dependencies:gen:check] do
53+
desc 'Regenerates the master Gridicon enum from PDF assets'
54+
task gen: %w[dependencies:gen:check] do
5255
swiftgen %w[xcassets -p Gridicons.stencil Gridicons/Gridicons/Gridicons.xcassets]
53-
puts "Done!"
56+
puts 'Done!'
5457
end
5558

5659
def swiftgen_path
57-
"#{PROJECT_DIR}/vendor/swiftgen"
60+
"#{PROJECT_DIR}/vendor/swiftgen"
5861
end
5962

6063
def swiftgen(args)
6164
args = [swiftgen_bin] + args
62-
sh(*args.join(" ") + " > Gridicons/Gridicons/GridiconsGenerated.swift")
65+
sh(["#{args.join(' ')} > Gridicons/Gridicons/GridiconsGenerated.swift"])
6366
end
6467

6568
def swiftgen_bin
66-
"#{swiftgen_path}/bin/swiftgen"
69+
"#{swiftgen_path}/bin/swiftgen"
6770
end
6871

6972
def swiftgen_needs_install
7073
return true unless File.exist?(swiftgen_bin)
74+
7175
installed_version = `"#{swiftgen_bin}" --version | awk '{print $2}'`.chomp
7276
installed_version.slice!(0)
73-
return (installed_version != SWIFTGEN_VERSION)
77+
(installed_version != SWIFTGEN_VERSION)
7478
end
7579

7680
def dependency_failed(component)
7781
msg = "#{component} dependencies missing or outdated. "
7882
if ENV['DRY_RUN']
79-
msg += "Run rake dependencies to install them."
80-
fail msg
83+
msg += 'Run rake dependencies to install them.'
84+
raise msg
8185
else
82-
msg += "Installing..."
86+
msg += 'Installing...'
8387
puts msg
8488
end
8589
end

0 commit comments

Comments
 (0)