umbrellalinter 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/umbrellalinter.rb +10 -6
- data/lib/umbrellalinter/cli.rb +3 -1
- data/lib/umbrellalinter/validator.rb +38 -4
- data/lib/umbrellalinter/version.rb +1 -1
- data/lib/umbrellalinter/xcodeprojparser.rb +10 -3
- data/pkg/umbrellalinter-0.1.0.gem +0 -0
- data/umbrellalinter.gemspec +1 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f455c4ed49c5dd52f11a9d911c990428d1d88bc7
|
4
|
+
data.tar.gz: dd0d28572c3414a042f9bf54d292fbe965119bdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa96a3164613beb7d8e0a4e07fdaba9fe0cb012edc0ccdea2cf7e7604a76fc633c5bfa2a02d32a9244166842cd81fd3e4e0cdc96ee15cdfa6c1b4935760f7e0c
|
7
|
+
data.tar.gz: 50f949b1a61c911b09619a93950b64c05eb0b4712bc944a3b74ffd55b58cd2f8577cdec07e2bf4ae1c3aaa48ab88130dc6004153a434afebd7f7f7efc6c3606b
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# Umbrella Helper Linter
|
2
2
|
|
3
3
|
__Umbrella Header Linter__ is a linter for iOS/macOS/tvOS/watchOS Frameworks.
|
4
4
|
Since Xcode doesn't provide a good way to identify at pre/post compile time that the umbrella header is missing files, or files are missing its Public scope, I decided to build this gem to help with the development of Frameworks.
|
@@ -26,9 +26,9 @@ Or install it yourself as:
|
|
26
26
|
|
27
27
|
`umbrellalinter lint FrameworkTargetName` to lint your Framework Target.
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
`umbrellalinter lint FrameworkTargetName --fix` to lint and fix your umbrella header and the file's scopes.
|
31
30
|
|
31
|
+
__NOTE__: Take in consideration we don't know what files you want public or private, we don't know the aritecture of your application or your public API. We base our linting and fixing based on what is declared on your umbrella header or what is missing on it(Files with public scope).
|
32
32
|
|
33
33
|
## Contributing
|
34
34
|
|
data/lib/umbrellalinter.rb
CHANGED
@@ -4,33 +4,37 @@ require "umbrellalinter/xcodeprojparser"
|
|
4
4
|
|
5
5
|
module Umbrella
|
6
6
|
class Linter
|
7
|
-
attr_reader :framework_target_name
|
7
|
+
attr_reader :framework_target_name, :fix
|
8
8
|
|
9
9
|
def self.perform(options)
|
10
10
|
new(options).perform
|
11
11
|
end
|
12
12
|
|
13
13
|
def initialize(options)
|
14
|
-
|
14
|
+
@framework_target_name = options.fetch(:framework_target_name)
|
15
|
+
@fix = options.fetch(:fix)
|
15
16
|
end
|
16
17
|
|
17
18
|
def run
|
18
19
|
# The directories containing the umbrella header(should only be 1, so we will take the last).
|
19
20
|
directories = Dir.glob("./**/" + @framework_target_name + ".h")
|
20
21
|
file = File.read(directories.last)
|
21
|
-
|
22
|
+
umbrella_header = directories.last
|
22
23
|
import_files = []
|
23
|
-
IO.readlines(
|
24
|
+
IO.readlines(umbrella_header).each do |line|
|
24
25
|
if line.start_with?("#import <" + framework_target_name + "/")
|
25
26
|
filename = line.partition("#import <" + framework_target_name + "/").last
|
26
27
|
#remove last 2 characters(/n and >)
|
27
|
-
filename = filename.chop
|
28
|
+
filename = filename.chop
|
28
29
|
#Add import files to array.
|
29
30
|
import_files.push(filename)
|
30
31
|
end
|
31
32
|
end
|
32
33
|
Umbrella::XcodeProjParser.new({
|
33
|
-
:import_files => import_files
|
34
|
+
:import_files => import_files,
|
35
|
+
:fix => fix,
|
36
|
+
:umbrella_header => umbrella_header,
|
37
|
+
:framework_target_name => @framework_target_name
|
34
38
|
}).parse
|
35
39
|
end
|
36
40
|
end
|
data/lib/umbrellalinter/cli.rb
CHANGED
@@ -4,9 +4,11 @@
|
|
4
4
|
module Umbrella
|
5
5
|
class CLI < Thor
|
6
6
|
desc "lint FrameworkTargetName", "Lints the umbrella header of the Framework"
|
7
|
+
option :fix, :type => :boolean
|
7
8
|
def lint(name)
|
8
9
|
Umbrella::Linter.new({
|
9
|
-
:framework_target_name => name
|
10
|
+
:framework_target_name => name,
|
11
|
+
:fix => options[:fix]
|
10
12
|
}).run
|
11
13
|
end
|
12
14
|
|
@@ -1,9 +1,12 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'colorize'
|
3
|
+
require 'Xcodeproj'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'tempfile'
|
3
6
|
|
4
7
|
module Umbrella
|
5
8
|
class Validator
|
6
|
-
attr_reader :project_files, :import_files
|
9
|
+
attr_reader :project_files, :import_files, :fix, :project_file_path, :umbrella_header, :framework_target_name
|
7
10
|
|
8
11
|
def self.perform(options)
|
9
12
|
new(options).perform
|
@@ -12,18 +15,49 @@ module Umbrella
|
|
12
15
|
def initialize(options)
|
13
16
|
@import_files = options.fetch(:import_files)
|
14
17
|
@project_files = options.fetch(:project_files)
|
18
|
+
@fix = options.fetch(:fix)
|
19
|
+
@project_file_path = options.fetch(:project_file_path)
|
20
|
+
@umbrella_header = options.fetch(:umbrella_header)
|
21
|
+
@framework_target_name = options.fetch(:framework_target_name)
|
15
22
|
end
|
16
23
|
|
17
|
-
def validate
|
24
|
+
def validate
|
25
|
+
xcodeproj_path = ""
|
18
26
|
# First we need to validate that all the import files in umbrella header are set as public.
|
19
27
|
@import_files.each { |filename|
|
20
28
|
unless @project_files.key?(filename)
|
21
|
-
|
29
|
+
if @fix
|
30
|
+
t_file = Tempfile.new('filename_temp.txt')
|
31
|
+
File.open(@project_file_path, 'r') do |f|
|
32
|
+
f.each_line{|line|
|
33
|
+
if line.include? filename.chop + " */;"
|
34
|
+
puts "Changing the scope of " + filename.chop + " to" +" Public".green
|
35
|
+
newline = line.slice(0..(line.index(filename.chop + " */;")))
|
36
|
+
newline = newline + filename.chop + " */;" + " settings = {ATTRIBUTES = (Public, ); }; };"
|
37
|
+
t_file.puts newline
|
38
|
+
else
|
39
|
+
t_file.puts line
|
40
|
+
end
|
41
|
+
}
|
42
|
+
end
|
43
|
+
t_file.close
|
44
|
+
FileUtils.mv(t_file.path, @project_file_path)
|
45
|
+
else
|
46
|
+
puts filename.red + " needs to be set as Public or your consumers won't be able to import it.".red
|
47
|
+
end
|
22
48
|
end
|
23
49
|
}
|
24
50
|
@project_files.each do |filename, scope|
|
25
51
|
unless @import_files.include? filename
|
26
|
-
|
52
|
+
if @fix
|
53
|
+
unless filename.include? File.basename( umbrella_header )
|
54
|
+
puts "Adding ".green + filename.green + " to Umbrella Header".green
|
55
|
+
File.open(@umbrella_header, 'a') do |f1| f1.write("\n#import <" + File.basename( umbrella_header, ".*" ) + "/" + filename + ">")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
else
|
59
|
+
puts filename.red + "is Public and needs to be added to the umbrella header".red
|
60
|
+
end
|
27
61
|
end
|
28
62
|
end
|
29
63
|
end
|
@@ -4,7 +4,7 @@ require "umbrellalinter/validator"
|
|
4
4
|
|
5
5
|
module Umbrella
|
6
6
|
class XcodeProjParser
|
7
|
-
attr_reader :import_files
|
7
|
+
attr_reader :import_files, :fix, :umbrella_header, :framework_target_name
|
8
8
|
|
9
9
|
def self.perform(options)
|
10
10
|
new(options).perform
|
@@ -12,6 +12,9 @@ module Umbrella
|
|
12
12
|
|
13
13
|
def initialize(options)
|
14
14
|
@import_files = options.fetch(:import_files)
|
15
|
+
@fix = options.fetch(:fix)
|
16
|
+
@umbrella_header = options.fetch(:umbrella_header)
|
17
|
+
@framework_target_name = options.fetch(:framework_target_name)
|
15
18
|
@project_files = {}
|
16
19
|
end
|
17
20
|
|
@@ -25,13 +28,17 @@ module Umbrella
|
|
25
28
|
if line.include? "in Headers"
|
26
29
|
if line.include? "settings = {ATTRIBUTES = (Public"
|
27
30
|
filename = line.split(/\/\* (.*?)in Headers \*\//)[1]
|
28
|
-
@project_files[filename] = "Public"
|
31
|
+
@project_files[filename.chop] = "Public"
|
29
32
|
end
|
30
33
|
end
|
31
34
|
end
|
32
35
|
Umbrella::Validator.new({
|
33
36
|
:import_files => @import_files,
|
34
|
-
:project_files => @project_files
|
37
|
+
:project_files => @project_files,
|
38
|
+
:fix => @fix,
|
39
|
+
:project_file_path => project_file_path,
|
40
|
+
:umbrella_header => @umbrella_header,
|
41
|
+
:framework_target_name => @framework_target_name
|
35
42
|
}).validate
|
36
43
|
end
|
37
44
|
end
|
Binary file
|
data/umbrellalinter.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: umbrellalinter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc Terns
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: xcodeproj
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: This ruby gem allows iOS/watchOS/tvOS Framework developers to lint and
|
84
98
|
fix their umbrella headers
|
85
99
|
email:
|