-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
68 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |