sbconstants 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc188984afc3d543f4350dbd750ccd57a470b664
|
4
|
+
data.tar.gz: 507c97cdb444d0936f05dafa79e467714bfbff8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06db174531943f8749c9b911fed499f2058d6d9c939ac490922660a8c1eb6f94341100174945403712d0795810a7adebea073ee0f7ec1d116d48d2f31467ebab
|
7
|
+
data.tar.gz: 8ed6a07ae457053bc2777a94e190aa5a1720007ea9e991e0c1c79b008d62eb638ab04c4039d8ecfe1ad73804c6afdfc6dc2a1464ed6e59e1e1e829d47a511367
|
data/lib/sbconstants/cli.rb
CHANGED
@@ -2,15 +2,16 @@ require 'set'
|
|
2
2
|
|
3
3
|
module SBConstants
|
4
4
|
class CLI
|
5
|
-
attr_accessor :options, :constants, :sections
|
5
|
+
attr_accessor :options, :constants, :sections, :storyboards
|
6
6
|
|
7
7
|
def self.run argv
|
8
8
|
new(Options.parse(argv)).run
|
9
9
|
end
|
10
10
|
|
11
11
|
def initialize options
|
12
|
-
self.options
|
13
|
-
self.constants
|
12
|
+
self.options = options
|
13
|
+
self.constants = Hash.new { |h,k| h[k] = Set.new }
|
14
|
+
self.storyboards = Array.new
|
14
15
|
end
|
15
16
|
|
16
17
|
def run
|
@@ -65,14 +66,21 @@ To resolve the issue remove the ambiguity in naming - search your storyboards fo
|
|
65
66
|
#
|
66
67
|
# A constant key can potentially exist in many files so locations is a collection
|
67
68
|
def parse_storyboards
|
68
|
-
Dir["#{options.source_dir}/**/*.storyboard"].
|
69
|
+
Dir["#{options.source_dir}/**/*.storyboard"].each_with_index do |storyboard, storyboard_index|
|
70
|
+
|
71
|
+
filename = File.basename(storyboard, '.storyboard')
|
72
|
+
storyboards << filename
|
73
|
+
|
74
|
+
constants[filename] << Location.new('storyboardNames', nil, storyboard, filename, storyboard_index + 1)
|
75
|
+
|
76
|
+
|
69
77
|
File.readlines(storyboard).each_with_index do |line, index|
|
70
78
|
options.queries.each do |query|
|
71
79
|
next unless value = line[query.regex, 1]
|
72
80
|
next if value.strip.empty?
|
73
81
|
next unless value.start_with?(options.prefix) if options.prefix
|
74
82
|
|
75
|
-
constants[value] << Location.new(query.node, query.attribute, line.strip,
|
83
|
+
constants[value] << Location.new(query.node, query.attribute, line.strip, filename, index + 1)
|
76
84
|
end
|
77
85
|
end
|
78
86
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
---
|
2
2
|
segue: identifier
|
3
|
-
tableViewCell: reuseIdentifier
|
4
|
-
collectionViewCell: reuseIdentifier
|
5
3
|
view: restorationIdentifier
|
4
|
+
? - tableViewCell
|
5
|
+
- collectionViewCell
|
6
|
+
: - reuseIdentifier
|
6
7
|
? - navigationController
|
7
8
|
- viewController
|
8
9
|
- tableViewController
|
9
10
|
- collectionViewController
|
10
11
|
: - storyboardIdentifier
|
11
12
|
- restorationIdentifier
|
12
|
-
|
data/lib/sbconstants/location.rb
CHANGED
@@ -22,7 +22,7 @@ module SBConstants
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def header
|
25
|
-
template_with_file "\n", File.open(template_file_path("objc_header.erb")).read
|
25
|
+
template_with_file "#import <Foundation/Foundation.h>\n\n", File.open(template_file_path("objc_header.erb")).read
|
26
26
|
end
|
27
27
|
|
28
28
|
def implementation
|
@@ -33,7 +33,7 @@ module SBConstants
|
|
33
33
|
def template_with_file head, body
|
34
34
|
@head = head
|
35
35
|
@body = body
|
36
|
-
pre_processed_template = ERB.new(File.open("
|
36
|
+
pre_processed_template = ERB.new(File.open(template_file_path("objc_body.erb")).read, nil, '<>').result(binding)
|
37
37
|
ERB.new(pre_processed_template, nil, '<>').result(binding)
|
38
38
|
end
|
39
39
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<%% present_constants(section).each do |constant_name, constant_value| %>
|
7
7
|
<%% if options.verbose %>
|
8
8
|
//
|
9
|
-
<%% constants[
|
9
|
+
<%% constants[constant_name].each do |location| %>
|
10
10
|
// info: <%%= location.debug %>
|
11
11
|
// context: <%%= location.context %>
|
12
12
|
//
|
data/lib/sbconstants/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sbconstants
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Samuels
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-04-02 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Generate constants from storyboards in ObjC and Swift.
|
15
15
|
email:
|