zewo-dev 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -1
  3. data/lib/zewo/version.rb +1 -1
  4. data/lib/zewo.rb +55 -42
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c44e142dac8ba152c983e0af01c2b666762beaf1
4
- data.tar.gz: 9eb785b29a27335363d8bf9b0629c40a4ca6bbac
3
+ metadata.gz: b3d02c82f775cdbabc993627c1d1bf48f1873eaf
4
+ data.tar.gz: 42abaab6c40f194d92c6e79b7ba79dbe71933654
5
5
  SHA512:
6
- metadata.gz: f8d280d746810ffe639d9dc4bdc64308677d4faa59de4a76aa795fc0467958a9d854e928545d4b1d56fba68e69fa0fbc3ca26050bdfd9b054c82a237f2177b69
7
- data.tar.gz: 6e7600763780ecda4420e8047a9d45e734fca4ab62fde6ffaf7e759f1e3a201f8c2856e189b70514a46ee893b1d7cc408f64d24ec5b3dd2bdfebe0dbd1451e85
6
+ metadata.gz: 02aafd101f9a033d4fccb8908b0d2f54c8e8dfe299fa4b4ddbc7c580e6a640ec9a5407a5a20d663ad01dac95d2d74102d4bbeefd847dc0e431e47eaf02c1883e
7
+ data.tar.gz: d0e53a47dc369b03ccecf831a6ae38cbb7c20cf703ab6c39e15de1cc39196c4f5517744d7ec06588ffb235ea0d52e1dfbe2ff0109fa06677bc7c37a13d2a2148
data/README.md CHANGED
@@ -35,4 +35,7 @@ Run `zewodev make_projects` to generate Xcode projects for all Swift modules. Ev
35
35
  Lastly, you'll be prompted to push your changes.
36
36
 
37
37
  ## Push & pull
38
- `zewodev push` and `zewodev pull` will push and pull changes for all Swift modules.
38
+ `zewodev push` and `zewodev pull` will push and pull changes for all Swift modules.
39
+
40
+ ## Unit testing
41
+ If you create a folder called `Tests` in the same directory as your `Sources` directory, the tool will create a `<ModuleName>-tests` target and add the test files to that target.
data/lib/zewo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Zewo
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.2"
3
3
  end
data/lib/zewo.rb CHANGED
@@ -41,16 +41,31 @@ module Zewo
41
41
  xcode_project.native_targets.find { |t| t.name == target_name } || xcode_project.new_target(:bundle, target_name, :osx)
42
42
  end
43
43
 
44
- def tests_dir
44
+ def dir(ext = nil)
45
+ r = name
46
+ r = "#{r}/#{ext}" if ext
47
+ r
48
+ end
49
+
50
+ def tests_dirname
45
51
  "Tests"
46
52
  end
47
53
 
48
- def xcode_dir
49
- "#{name}/XcodeDevelopment"
54
+ def xcode_dirname
55
+ "XcodeDevelopment"
50
56
  end
51
57
 
52
58
  def xcode_project_path
53
- "#{xcode_dir}/#{name}.xcodeproj"
59
+ dir("#{xcode_dirname}/#{name}.xcodeproj")
60
+ end
61
+
62
+ def sources_dirname
63
+ if File.directory?(dir('Sources'))
64
+ return 'Sources'
65
+ elsif File.directory?(dir('Source'))
66
+ return 'Source'
67
+ end
68
+ nil
54
69
  end
55
70
 
56
71
  def xcode_project
@@ -63,15 +78,6 @@ module Zewo
63
78
  @xcodeproj
64
79
  end
65
80
 
66
- def sources_dir
67
- if File.directory?("#{name}/Sources")
68
- return 'Sources'
69
- elsif File.directory?("#{name}/Source")
70
- return 'Source'
71
- end
72
- nil
73
- end
74
-
75
81
  def add_files(direc, current_group, main_target)
76
82
  Dir.glob(direc) do |item|
77
83
  next if item == '.' || item == '.DS_Store'
@@ -90,7 +96,7 @@ module Zewo
90
96
 
91
97
  def build_dependencies
92
98
  puts "Configuring dependencies for #{name}".green
93
- dependency_repos = File.read("#{name}/Package.swift").scan(/(?<=Zewo\/)(.*?)(?=\.git)/).map(&:first)
99
+ dependency_repos = File.read(dir('Package.swift')).scan(/(?<=Zewo\/)(.*?)(?=\.git)/).map(&:first)
94
100
 
95
101
  group = xcode_project.new_group('Subprojects')
96
102
  dependency_repos.each do |repo_name|
@@ -108,32 +114,45 @@ module Zewo
108
114
 
109
115
  def configure_xcode_project
110
116
  @xcodeproj = nil
111
- silent_cmd("rm -rf #{xcode_dir}")
117
+ silent_cmd("rm -rf #{dir(xcode_dirname)}")
112
118
 
113
119
  puts "Creating Xcode project #{name}".green
114
120
 
115
121
  framework_target.build_configurations.each do |configuration|
116
122
  framework_target.build_settings(configuration.name)['HEADER_SEARCH_PATHS'] = '/usr/local/include'
117
123
  framework_target.build_settings(configuration.name)['LIBRARY_SEARCH_PATHS'] = '/usr/local/lib'
124
+ framework_target.build_settings(configuration.name)['ENABLE_TESTABILITY'] = 'YES'
118
125
 
119
- if File.exist?("#{name}/module.modulemap")
126
+ if File.exist?(dir('module.modulemap'))
120
127
  framework_target.build_settings(configuration.name)['MODULEMAP_FILE'] = '../module.modulemap'
121
128
  end
122
129
  end
123
130
 
124
- xcode_project.new_file('../module.modulemap') if File.exist?("#{name}/module.modulemap")
131
+ framework_target.frameworks_build_phase.clear
125
132
 
126
- if sources_dir
127
- group = xcode_project.new_group(sources_dir)
128
- add_files("#{name}/#{sources_dir}/*", group, framework_target)
133
+ xcode_project.new_file('../module.modulemap') if File.exist?(dir('module.modulemap'))
134
+
135
+ if sources_dirname
136
+ group = xcode_project.new_group(sources_dirname)
137
+ add_files(dir("#{sources_dirname}/*"), group, framework_target)
129
138
  end
130
139
 
131
- if File.directory?("#{name}/#{tests_dir}")
132
- group = xcode_project.new_group(tests_dir)
133
- add_files("#{name}/#{tests_dir}/*", group, test_target)
140
+ test_target.resources_build_phase
141
+ test_target.add_dependency(framework_target)
142
+
143
+ test_target.build_configurations.each do |configuration|
144
+ test_target.build_settings(configuration.name)['WRAPPER_EXTENSION'] = 'xctest'
145
+ test_target.build_settings(configuration.name)['LD_RUNPATH_SEARCH_PATHS'] = '$(inherited) @executable_path/../../Frameworks @loader_path/../Frameworks'
134
146
  end
135
147
 
148
+ group = xcode_project.new_group(tests_dirname)
149
+ add_files(dir("#{tests_dirname}/*"), group, test_target)
150
+
136
151
  xcode_project.save
152
+
153
+ scheme = Xcodeproj::XCScheme.new()
154
+ scheme.configure_with_targets(framework_target, test_target)
155
+ scheme.save_as(xcode_project.path, framework_target.name, true)
137
156
  end
138
157
  end
139
158
 
@@ -149,15 +168,12 @@ module Zewo
149
168
  'Core',
150
169
  'GrandCentralDispatch',
151
170
  'JSONParserMiddleware',
152
- 'Levee',
153
171
  'LoggerMiddleware',
154
172
  'Middleware',
155
- 'Mustache',
156
- 'POSIXRegex',
157
173
  'SSL',
158
- 'Sideburns',
159
174
  'SwiftZMQ',
160
- 'WebSocket'
175
+ 'WebSocket',
176
+ 'HTTPMiddleware'
161
177
  ]
162
178
 
163
179
  response = http.request(request)
@@ -165,14 +181,13 @@ module Zewo
165
181
  if response.code == '200'
166
182
  result = JSON.parse(response.body).sort_by { |hsh| hsh['name'] }
167
183
 
168
-
169
184
  result.each do |doc|
170
185
  next if blacklist.include?(doc['name'])
171
186
  repo = Repo.new(doc['name'], doc)
172
187
  yield repo
173
188
  end
174
189
  else
175
- puts 'Error loading repositories'
190
+ puts 'Error loading repositories'.red
176
191
  end
177
192
  end
178
193
 
@@ -188,8 +203,7 @@ module Zewo
188
203
 
189
204
  def each_code_repo
190
205
  each_repo do |repo|
191
- unless File.exist?("#{repo.name}/Package.swift")
192
- print "No Package.swift for #{repo.name}. Skipping." + "\n"
206
+ unless File.exist?(repo.dir('Package.swift'))
193
207
  next
194
208
  end
195
209
  yield repo
@@ -209,7 +223,7 @@ module Zewo
209
223
  def verify_branches
210
224
  last_branch_name = nil
211
225
  each_repo do |repo|
212
- branch_name = `cd #{repo.name}; git rev-parse --abbrev-ref HEAD`.gsub("\n", '')
226
+ branch_name = `cd #{repo.dir}; git rev-parse --abbrev-ref HEAD`.gsub("\n", '')
213
227
  if !last_branch_name.nil? && branch_name != last_branch_name
214
228
  puts "Branch mismatch. Branch of #{repo.name} does not match previous branch #{branch_name}".red
215
229
  return false
@@ -257,15 +271,15 @@ module Zewo
257
271
 
258
272
  desc :pull, 'git pull on all repos'
259
273
  def pull
274
+ print "Updating all repositories..." + "\n"
260
275
  each_code_repo_async do |repo|
261
- print "Updating #{repo.name}..." + "\n"
262
276
  if uncommited_changes?(repo.name)
263
277
  print "Uncommitted changes in #{repo.name}. Not updating.".red + "\n"
264
278
  next
265
279
  end
266
280
  system("cd #{repo.name}; git pull")
267
- print "Updated #{repo.name}".green + "\n"
268
281
  end
282
+ puts 'Done!'
269
283
  end
270
284
 
271
285
  desc :push, 'git push on all repos'
@@ -289,7 +303,7 @@ module Zewo
289
303
  print "Checking #{repo.name}..." + "\n"
290
304
  unless File.directory?(repo.name)
291
305
  print "Cloning #{repo.name}...".green + "\n"
292
- silent_cmd("git clone #{repo.data['ssh_url']}")
306
+ silent_cmd("git clone #{repo.data['clone_url']}")
293
307
  end
294
308
  end
295
309
  puts 'Done!'
@@ -298,14 +312,14 @@ module Zewo
298
312
  desc :build, 'Clones all Zewo repositories'
299
313
  def build
300
314
  each_code_repo do |repo|
301
- unless File.directory?("#{repo.name}/Xcode")
315
+ unless File.directory?(repo.dir(repo.xcode_dirname))
302
316
  puts "Skipping #{repo.name}. No Xcode project".yellow
303
317
  end
304
318
  puts "Building #{repo.name}...".green
305
319
 
306
- if system("cd #{repo.name}/Xcode; set -o pipefail && xcodebuild -scheme \"#{repo.name}\" -sdk \"macosx\" -toolchain /Library/Developer/Toolchains/swift-latest.xctoolchain | xcpretty") == false
320
+ if system("cd #{repo.dir(repo.xcode_dirname)}; set -o pipefail && xcodebuild -scheme \"#{repo.framework_target.name}\" -sdk \"macosx\" -toolchain \"/Library/Developer/Toolchains/swift-latest.xctoolchain\" | xcpretty") == false
307
321
  puts "Error building. Maybe you're using the wrong Xcode? Try `sudo xcode-select -s /Applications/Xcode-Beta.app/Contents/Developer` if you have a beta-version of Xcode installed.".red
308
-
322
+ return
309
323
  end
310
324
  end
311
325
  end
@@ -319,14 +333,13 @@ module Zewo
319
333
  puts repo.name
320
334
  puts '--------------------------------------------------------------'
321
335
  if uncommited_changes?(repo.name)
322
- puts 'Status:'.yellow
323
- system("cd #{repo.name}; git status")
336
+ system("cd #{repo.dir}; git status")
324
337
  return unless prompt("Proceed with #{repo.name}?")
325
338
  end
326
339
  end
327
340
 
328
341
  each_code_repo do |repo|
329
- system("cd #{repo.name}; git add --all; git commit -am \"#{message}\"")
342
+ system("cd #{repo.dir}; git add --all; git commit -am \"#{message}\"")
330
343
  puts "Commited #{repo.name}\n".green
331
344
  end
332
345
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zewo-dev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Ask