Skip to content

Commit

Permalink
Add Rubocop corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
jkmassel committed Aug 10, 2021
1 parent 4c7e7e5 commit d2fa329
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 40 deletions.
18 changes: 18 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Opt in to new cops by default
AllCops:
NewCops: enable

# Allow the Podspec filename to match the project
Naming/FileName:
Exclude:
- 'Gridicons.podspec'

# Override the maximum block length (some pods have long definitions)
Metrics/BlockLength:
Max: 256

# Override the maximum line length
Layout/LineLength:
Max: 160

require: rubocop-rake
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ source 'https://rubygems.org'
gem 'cocoapods', '~> 1.10'
gem 'cocoapods-check', '~> 1.1'
gem 'fastlane', '~> 2.189'
gem 'rubocop', '~> 1.18'
gem 'rake', '~> 13'
gem 'rubocop', '~> 1.18'
gem 'rubocop-rake', '~> 0.6.0'
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ GEM
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.9.1)
parser (>= 3.0.1.1)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
ruby-macho (1.4.0)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
Expand Down Expand Up @@ -294,6 +296,7 @@ DEPENDENCIES
fastlane (~> 2.189)
rake (~> 13)
rubocop (~> 1.18)
rubocop-rake (~> 0.6.0)

BUNDLED WITH
2.2.23
28 changes: 15 additions & 13 deletions Gridicons.podspec
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
# frozen_string_literal: true

Pod::Spec.new do |s|
s.name = "Gridicons"
s.version = "1.1.0"
s.name = 'Gridicons'
s.version = '1.1.0'

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

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

s.platform = :ios, "11.0"
s.platform = :ios, '11.0'
s.swift_version = '5.0'

s.source = { :git => "https://github.com/Automattic/Gridicons-iOS.git", :tag => s.version.to_s }
s.source_files = "Gridicons/Gridicons/**/*.swift"
s.source = { git: 'https://github.com/Automattic/Gridicons-iOS.git', tag: s.version.to_s }
s.source_files = 'Gridicons/Gridicons/**/*.swift'
s.resource_bundles = {
'Gridicons': [
'Gridicons/Gridicons/*.{xcassets}',
Gridicons: [
'Gridicons/Gridicons/*.{xcassets}'
]
}
end
56 changes: 30 additions & 26 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,85 +1,89 @@
SWIFTGEN_VERSION="6.1.0"
# frozen_string_literal: true

SWIFTGEN_VERSION = '6.1.0'

require 'fileutils'
require 'tmpdir'
require 'rake/clean'
PROJECT_DIR = File.expand_path(File.dirname(__FILE__))
PROJECT_DIR = __dir__

task default: %w[gen]

desc "Install required dependencies"
task :dependencies => %w[dependencies:check]
desc 'Install required dependencies'
task dependencies: %w[dependencies:check]

namespace :dependencies do
task :check => %w[gen:check]
task check: %w[gen:check]

namespace :gen do

desc 'Install SwiftGen if needed'
task :check do
if swiftgen_needs_install
dependency_failed("SwiftGen")
Rake::Task["dependencies:gen:install"].invoke
dependency_failed('SwiftGen')
Rake::Task['dependencies:gen:install'].invoke
end
end

desc 'Install SwiftGen'
task :install do
puts "Installing SwiftGen #{SWIFTGEN_VERSION} into #{swiftgen_path}"
Dir.mktmpdir do |tmpdir|
zipfile = "#{tmpdir}/swiftgen-#{SWIFTGEN_VERSION}.zip"
sh "curl --fail --location -o #{zipfile} https://github.com/SwiftGen/SwiftGen/releases/download/#{SWIFTGEN_VERSION}/swiftgen-#{SWIFTGEN_VERSION}.zip || true"
if File.exists?(zipfile)
source = "https://github.com/SwiftGen/SwiftGen/releases/download/#{SWIFTGEN_VERSION}/swiftgen-#{SWIFTGEN_VERSION}.zip"
sh "curl --fail --location -o #{zipfile} #{source} || true"
if File.exist?(zipfile)
zipdir = "#{tmpdir}/swiftgen-#{SWIFTGEN_VERSION}"
sh "unzip -q #{zipfile} -d #{zipdir}"
Dir.chdir(zipdir) do
puts "Copying SwiftGen #{SWIFTGEN_VERSION} into #{swiftgen_path}"
FileUtils.remove_entry_secure(swiftgen_path) if Dir.exist?(swiftgen_path)
FileUtils.mkdir_p("#{swiftgen_path}")
FileUtils.cp_r("#{zipdir}/lib", "#{swiftgen_path}")
FileUtils.cp_r("#{zipdir}/bin", "#{swiftgen_path}")
FileUtils.mkdir_p(swiftgen_path.to_s)
FileUtils.cp_r("#{zipdir}/lib", swiftgen_path.to_s)
FileUtils.cp_r("#{zipdir}/bin", swiftgen_path.to_s)
end
end
end
end
CLOBBER << "vendor/swiftgen"
CLOBBER << 'vendor/swiftgen'
end

end

CLOBBER << "vendor"
CLOBBER << 'vendor'

desc "Regenerates the master Gridicon enum from PDF assets"
task :gen => %w[dependencies:gen:check] do
desc 'Regenerates the master Gridicon enum from PDF assets'
task gen: %w[dependencies:gen:check] do
swiftgen %w[xcassets -p Gridicons.stencil Gridicons/Gridicons/Gridicons.xcassets]
puts "Done!"
puts 'Done!'
end

def swiftgen_path
"#{PROJECT_DIR}/vendor/swiftgen"
"#{PROJECT_DIR}/vendor/swiftgen"
end

def swiftgen(args)
args = [swiftgen_bin] + args
sh(*args.join(" ") + " > Gridicons/Gridicons/GridiconsGenerated.swift")
sh(["#{args.join(' ')} > Gridicons/Gridicons/GridiconsGenerated.swift"])
end

def swiftgen_bin
"#{swiftgen_path}/bin/swiftgen"
"#{swiftgen_path}/bin/swiftgen"
end

def swiftgen_needs_install
return true unless File.exist?(swiftgen_bin)

installed_version = `"#{swiftgen_bin}" --version | awk '{print $2}'`.chomp
installed_version.slice!(0)
return (installed_version != SWIFTGEN_VERSION)
(installed_version != SWIFTGEN_VERSION)
end

def dependency_failed(component)
msg = "#{component} dependencies missing or outdated. "
if ENV['DRY_RUN']
msg += "Run rake dependencies to install them."
fail msg
msg += 'Run rake dependencies to install them.'
raise msg
else
msg += "Installing..."
msg += 'Installing...'
puts msg
end
end

0 comments on commit d2fa329

Please sign in to comment.