xcode-yamlizer 0.0.2 → 0.0.3

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.
@@ -4,6 +4,7 @@ require 'xcode-yamlizer/dumpers'
4
4
  require 'rugged'
5
5
  require 'pathname'
6
6
 
7
+ require 'find'
7
8
 
8
9
  $KCODE = 'UTF8' unless RUBY_VERSION >= '1.9'
9
10
  require 'pp'
@@ -11,7 +12,7 @@ require 'pp'
11
12
 
12
13
  YAML_FORMATS = [".yaml", ".yml"]
13
14
  PLIST_FORMATS = [".pbxproj"]
14
- XML_FORMATS = [".xib", ".storyboard", /(.*).xcdatamodeld\/(.*).xcdatamodel\/contents/]
15
+ XML_FORMATS = [".xib", ".storyboard", /(.*).xcdatamodeld\/(.*).xcdatamodel\/contents$/]
15
16
 
16
17
 
17
18
  XCODE_FORMATS = PLIST_FORMATS + XML_FORMATS
@@ -67,10 +68,9 @@ def repo_add_files(files)
67
68
  files.each do |file|
68
69
  if not index.get_entry(file)
69
70
  #puts "Adding: #{file}"
70
- index.add(file)
71
+ `git add '#{file}'`
71
72
  end
72
73
  end
73
- index.write()
74
74
  end
75
75
 
76
76
  def repo_remove_files(files)
@@ -80,10 +80,9 @@ def repo_remove_files(files)
80
80
  files.each do |file|
81
81
  if index.get_entry(file)
82
82
  #puts "Removing: #{file}"
83
- index.remove(file)
83
+ `git rm --cached '#{file}'`
84
84
  end
85
85
  end
86
- index.write()
87
86
  end
88
87
 
89
88
  def repo_gitignore_add_files(files)
@@ -95,7 +94,6 @@ def repo_gitignore_add_files(files)
95
94
  already_ignored = []
96
95
  end
97
96
 
98
-
99
97
  new_ignored = files - already_ignored
100
98
 
101
99
  if new_ignored.count > 0
@@ -124,28 +122,34 @@ end
124
122
 
125
123
 
126
124
  module XcodeYamlizer
127
- def self.convert_directory(dir, to_xcode)
128
- puts "Conventering directory '#{dir}'..."
125
+ def self.convert_directory(dir, to_xcode, verbose=false, ignore_paths=[])
126
+ puts "Conventering directory '#{dir}'..." if verbose
129
127
  files = []
130
128
  formats = to_xcode ? YAML_FORMATS : XCODE_FORMATS
131
129
 
132
- Dir.glob(dir+"**/*").each do |filename|
133
- if formats.include_filename? filename
134
- files += [filename]
135
-
130
+ Find.find(dir) do |path|
131
+ name = File.basename(path)
132
+ if FileTest.directory?(path)
133
+ if ignore_paths.include?(name)
134
+ Find.prune
135
+ else
136
+ next
137
+ end
138
+ else
139
+ files += [path] if formats.include_filename? name
136
140
  end
137
141
  end
138
-
139
- puts "Found:"
140
- puts files
142
+
143
+ puts "Found:" if verbose
144
+ puts files if verbose
141
145
  new_files = files.map do |file|
142
- convert_file file
146
+ convert_file file, verbose
143
147
  end
144
- puts "Finished!"
148
+ puts "Finished!" if verbose
145
149
  return files, new_files
146
150
  end
147
151
 
148
- def self.convert_file(input)
152
+ def self.convert_file(input, verbose=false)
149
153
  result = nil
150
154
  if YAML_FORMATS.include_filename? input
151
155
  output = input.chomp(File.extname(input))
@@ -156,7 +160,7 @@ module XcodeYamlizer
156
160
  result = load(input)
157
161
  dump(output, result)
158
162
  if result
159
- puts "#{input} => #{output}"
163
+ puts "#{input} => #{output}" if verbose
160
164
  return output
161
165
  else
162
166
  puts "Don't know what to do with '#{input}'"
@@ -173,9 +177,22 @@ module XcodeYamlizer
173
177
  end
174
178
  end
175
179
 
180
+ def self.find_submodules
181
+ paths = `git submodule foreach --quiet 'echo $path'`
182
+ paths.lines.map do |line|
183
+ line.chomp
184
+ end
185
+ end
186
+
176
187
  def self.run_pre_commit
177
188
  chroot_to_repo()
178
- files_remove, files_add = convert_directory('./', false)
189
+ paths_to_ignore = find_submodules
190
+
191
+
192
+ files_remove, files_add = convert_directory('./', \
193
+ false, \
194
+ false, \
195
+ paths_to_ignore)
179
196
  files_remove = make_filepaths_non_relative files_remove
180
197
  files_add = make_filepaths_non_relative files_add
181
198
  repo_add_files files_add
@@ -186,7 +203,8 @@ module XcodeYamlizer
186
203
 
187
204
  def self.run_post_merge
188
205
  chroot_to_repo()
189
- convert_directory('./', true)
206
+ paths_to_ignore = find_submodules
207
+ convert_directory('./', true, false, paths_to_ignore)
190
208
  end
191
209
 
192
210
 
@@ -1,3 +1,3 @@
1
1
  module XcodeYamlizer
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcode-yamlizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: