constraintClean 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c1caf259f62c8fc228cfb09c73f609a8137449c
4
- data.tar.gz: f887ce4da91cd691db6603851b532d421645ea30
3
+ metadata.gz: 02d826589694201014e9e6ac9521dcc3656d06fc
4
+ data.tar.gz: 81c183a68d6dc294702ccf56aefe5ff56abd3e7d
5
5
  SHA512:
6
- metadata.gz: a65d53a17f183a5f40f47a4a642178b77c4c42edf273dbe01c73942ed97e0fd962f3479dea28ae8495707c669ef77b93568bd3e37b6a42460a80ef0670cc5862
7
- data.tar.gz: f62606f5945b5e058fd62a018f53ed3ec3bbbd1ac7a32f797301ade26c6fa792ab55682e8f929d174971435d003d00e449e78a69631af32ba68fa8b774c8ef74
6
+ metadata.gz: 1c1e0b5935f6cf1098a940a69034cfeb67c0619ad4abdc4a1eae00fc54d4e2a5c3801364529b01c88569aec5787766488a610b75716924d62a7f47e24b69f924
7
+ data.tar.gz: 5a92bad7dbaebf2a623508cd9a49dda047729bcbf0a80cf22253618b8fe4e12860e854ef653bf2a934504457e19be224f3241c6661f17e85214547f3fc00e283
data/bin/constraintClean CHANGED
@@ -7,8 +7,6 @@ notifyAboutUpdates
7
7
 
8
8
  files = Dir.glob("**/*.{storyboard,xib}")
9
9
  files.each{ |file| cleanupConstraints(file)}
10
- print "\r"
11
- STDOUT.flush
12
10
 
13
11
  if files.count == 0
14
12
  p "There is no any 'storyboard' or 'xib' files"
@@ -1,3 +1,3 @@
1
1
  module ConstraintClean
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
@@ -2,26 +2,51 @@ require "constraintClean/version"
2
2
  require 'nokogiri'
3
3
 
4
4
  def cleanupConstraints(file)
5
-
6
- print "\r #{file}"
7
- STDOUT.flush
8
-
5
+
9
6
  f = File.open(file)
10
7
  doc = Nokogiri::XML(f)
11
8
  f.close
12
-
13
- excluded = doc.xpath('//exclude')
14
- included = doc.xpath('//include')
9
+
10
+ excluded = []
11
+ variations = doc.xpath('//variation')
12
+
13
+ included = doc.xpath('//include')
14
+ outlets = doc.xpath('//outlet')
15
+
16
+ variations.each do |variation|
17
+ if variation.attr('key') == "default"
18
+ ch = variation.children
19
+ ch.each do |mask|
20
+ constraints = mask.children
21
+ constraints.each do |constraint|
22
+ if constraint.name == 'exclude'
23
+ excluded.push(constraint)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
15
29
 
16
30
  result = []
17
31
  excluded.each do |node|
18
32
  found = false
19
33
  for includedNode in included
34
+ p node
20
35
  if node.attr('reference') == includedNode.attr('reference')
21
36
  found = true
22
37
  break
23
38
  end
24
39
  end
40
+
41
+ if !found
42
+ for outlet in outlets
43
+ if node.attr('reference') == outlet.attr('destination')
44
+ found = true
45
+ break
46
+ end
47
+ end
48
+ end
49
+
25
50
  if !found
26
51
  result.push(node)
27
52
  nodeID = node.attr('reference')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: constraintClean
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Kohtenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-03 00:00:00.000000000 Z
11
+ date: 2015-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -107,4 +107,3 @@ signing_key:
107
107
  specification_version: 4
108
108
  summary: Simple gem to cleanup all your storyboard and xib files from useless constraints.
109
109
  test_files: []
110
- has_rdoc: