constraintClean 1.0.0

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/cleanup.rb +39 -0
  3. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 76e0c9eb76502dd194921731916332e7f302f0b5
4
+ data.tar.gz: cc83cb500abec11de436061aba3b80f8c06ca5cb
5
+ SHA512:
6
+ metadata.gz: 7f1a17ace7532b6969c67e7b5c0f6cb68db2e62b0ab8ffa863240feb46e76d8421c5a2b535faa8af37306dd2dfc6917ce91ea8773d8a4f68804f821b1657913e
7
+ data.tar.gz: d73b4035eaa185ed66a6337ed26bbaf1bed4b4bad24e0b037848dc7dbfea34c11dd809d0b364a05acc867a7ac604d800b630494d6580cd27c76c800970569bdd
data/lib/cleanup.rb ADDED
@@ -0,0 +1,39 @@
1
+ require 'nokogiri'
2
+
3
+ def cleanupConstraints(file)
4
+
5
+ f = File.open(file)
6
+ doc = Nokogiri::XML(f)
7
+ f.close
8
+
9
+
10
+ excluded = doc.xpath('//exclude')
11
+ included = doc.xpath('//include')
12
+
13
+ result = []
14
+ excluded.each do |node|
15
+ found = false
16
+ for includedNode in included
17
+ if node.attr('reference') == includedNode.attr('reference')
18
+ found = true
19
+ break
20
+ end
21
+ end
22
+ if !found
23
+ result.push(node)
24
+ nodeID = node.attr('reference')
25
+ constraints = doc.xpath("//constraint[@id='#{nodeID}']")
26
+ result += constraints
27
+ end
28
+ end
29
+ if result.count > 0
30
+ f1 = File.open(file, 'w')
31
+ result.each{ |node| node.remove }
32
+ f1.write(doc.to_xml)
33
+ f1.close
34
+
35
+ p "removed #{result.count} constraint(s) from #{file}"
36
+ end
37
+ end
38
+
39
+ Dir.glob("**/*.{storyboard,xib}").each{ |file| cleanupConstraints(file)}
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: constraintClean
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Oleg Kohtenko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-30 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Simple gem to cleanup all your storyboard and xib files from useless
14
+ constraints.
15
+ email: kohtenko@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/cleanup.rb
21
+ homepage: http://rubygems.org/gems/cleanup
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.4.8
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Simple gem to cleanup all your storyboard and xib files from useless constraints.
45
+ test_files: []
46
+ has_rdoc: