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: fb8940858c1fdaa712d60cb4b79702cebbcdfcef
4
- data.tar.gz: db0274ce5f165d3daef24d5f4f38959dc0834b82
3
+ metadata.gz: cc188984afc3d543f4350dbd750ccd57a470b664
4
+ data.tar.gz: 507c97cdb444d0936f05dafa79e467714bfbff8a
5
5
  SHA512:
6
- metadata.gz: 8724eb33be119da8db638be2e3ff57ba3137377683a2e1954e79be8bcd626fe0465cda9debf66591a7f51c3b61986a3f3adf2055d1ea5afd96d1986632118d0a
7
- data.tar.gz: 835216657cdd7b8c731966e33204cfdd0dcf9e15af913e47139fe2148bcecc587cc645f9a53fbdd3762cee35b7668bacafdfa7ee61ae01646f711af3ebf3268d
6
+ metadata.gz: 06db174531943f8749c9b911fed499f2058d6d9c939ac490922660a8c1eb6f94341100174945403712d0795810a7adebea073ee0f7ec1d116d48d2f31467ebab
7
+ data.tar.gz: 8ed6a07ae457053bc2777a94e190aa5a1720007ea9e991e0c1c79b008d62eb638ab04c4039d8ecfe1ad73804c6afdfc6dc2a1464ed6e59e1e1e829d47a511367
@@ -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 = options
13
- self.constants = Hash.new { |h,k| h[k] = Set.new }
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"].each do |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, File.basename(storyboard, '.storyboard'), index + 1)
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
-
@@ -1,7 +1,7 @@
1
1
  module SBConstants
2
2
  Location = Struct.new(:node, :attribute, :context, :file, :line) do
3
3
  def key_path
4
- @key_path ||= "#{node}.#{attribute}"
4
+ @key_path ||= [node, attribute].compact.join('.')
5
5
  end
6
6
 
7
7
  def debug
@@ -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("#{default_templates_dir}/objc_body.erb").read, nil, '<>').result(binding)
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[constant].each do |location| %>
9
+ <%% constants[constant_name].each do |location| %>
10
10
  // info: <%%= location.debug %>
11
11
  // context: <%%= location.context %>
12
12
  //
@@ -1,3 +1,3 @@
1
1
  module SBConstants
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
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.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-01-22 00:00:00.000000000 Z
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: