cocoaseeds 0.0.5 → 0.0.6

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: 3f3433a51f3e7393a8d018c462d0d62839830334
4
- data.tar.gz: 5a4264434da64f6c04376056c8733ef61f3efe33
3
+ metadata.gz: 0d0c7b367ac3f9e070093e852bd6feaeebf37380
4
+ data.tar.gz: 2485e3e4561c01713cd5d89215c6c1637b7b711a
5
5
  SHA512:
6
- metadata.gz: 7090d075190b340e8c71db3d5cec71a330f81000e9de3e562a1a2d1a653b5a405a458c580146e9be1f3bba4238bdab8ca2bc5aa972ed817a4ed6a0d6a3a71620
7
- data.tar.gz: ebd2667fc734c4b2192aac7b67d824ff4725765b95e892d59d989809020d647be69a1dfaac2f615958b087eedf739e7116c7ff2add7155746a528509a106f6d8
6
+ metadata.gz: ec7d40fab0e7a5312f36d786634c453ef7ebdcd5368d6b505cb35f2f777c9f7eb23745db55f1169b24a33190c3f8e1ce995ff840b80753218704c1ad096c61a6
7
+ data.tar.gz: eb28719ea77e6bcea502a2b36f5952ede136a10d9dad717e91b1c57682f379335cbd8c4692471d8689775e35f8602719a33cddc9633786b5c42e99bb98a71720
@@ -1,12 +1,81 @@
1
1
  module Seeds
2
2
  class Core
3
+
4
+ # @return [String] project folder path
5
+ #
6
+ attr_reader :root_path
7
+
8
+ # @return [Boolean] whether display outputs
9
+ #
3
10
  attr_accessor :mute
4
11
 
5
- attr_reader :root_path, :seedfile_path, :lockfile_path
6
- attr_accessor :project, :seedfile, :lockfile
7
- attr_reader :seeds, :locks, :targets
8
- attr_reader :source_files, :file_references
12
+ # @return [String] Seedfile path
13
+ #
14
+ # @!visibility private
15
+ #
16
+ attr_reader :seedfile_path
17
+
18
+ # @return [String] Seedfile.lock path
19
+ #
20
+ # @!visibility private
21
+ #
22
+ attr_reader :lockfile_path
23
+
24
+ # @return [Xcodeproj::Project] Xcode project
25
+ #
26
+ # @!visibility private
27
+ #
28
+ attr_accessor :project
29
+
30
+ # @return [String] content of Seedfile
31
+ #
32
+ # @!visibility private
33
+ #
34
+ attr_accessor :seedfile
35
+
36
+ # @return [String] content of Seedfile.lock
37
+ #
38
+ # @!visibility private
39
+ #
40
+ attr_accessor :lockfile
41
+
42
+ # @return [Hash{Sting => Seeds::Seed}] seeds by seed name
43
+ #
44
+ # @!visibility private
45
+ #
46
+ attr_reader :seeds
9
47
 
48
+ # @return [Hash{Sting => Seeds::Seed}] locked dependencies by seed name
49
+ #
50
+ # @!visibility private
51
+ #
52
+ attr_reader :locks
53
+
54
+ # @return [Hash{Sting => String}] target name by seed name
55
+ #
56
+ # @!visibility private
57
+ #
58
+ attr_reader :targets
59
+
60
+ # @return [Hash{Sting => Seeds::Seed}] source file paths by seed name
61
+ #
62
+ # @!visibility private
63
+ #
64
+ attr_reader :source_files
65
+
66
+ # @return [Array<Xcodeproj::Project::Object::PBXFileReference>]
67
+ # file references that will be added to project
68
+ #
69
+ # @!visibility private
70
+ #
71
+ attr_reader :file_references
72
+
73
+ # @param [String] root_path
74
+ # The path provided will be used for detecting Xcode project and
75
+ # Seedfile.
76
+ #
77
+ # @see #root_path
78
+ #
10
79
  def initialize(root_path)
11
80
  @root_path = root_path
12
81
  @seedfile_path = File.join(root_path, "Seedfile")
@@ -18,6 +87,11 @@ module Seeds
18
87
  @file_references = []
19
88
  end
20
89
 
90
+ # Read Seedfile and install dependencies. An exception will be raised if
91
+ # there is no .xcodeproj file or Seedfile in the {#root_path}.
92
+ #
93
+ # @see #root_path
94
+ #
21
95
  def install
22
96
  self.prepare_requirements
23
97
  self.analyze_dependencies
@@ -35,6 +109,13 @@ module Seeds
35
109
  @file_references = []
36
110
  end
37
111
 
112
+ # Read Xcode project, Seedfile and lockfile. An exception will be raised if
113
+ # there is no .xcodeproj file or Seedfile in the {#root_path}.
114
+ #
115
+ # @see #root_path
116
+ #
117
+ # @!visibility private
118
+ #
38
119
  def prepare_requirements
39
120
  # .xcodeproj
40
121
  project_filename = Dir.glob("#{root_path}/*.xcodeproj")[0]
@@ -57,6 +138,12 @@ module Seeds
57
138
  end
58
139
  end
59
140
 
141
+ # Parses Seedfile.lockfile into {#lockfile}.
142
+ #
143
+ # @see #lockfile
144
+ #
145
+ # @!visibility private
146
+ #
60
147
  def analyze_dependencies
61
148
  say "Anaylizing dependencies"
62
149
 
@@ -72,28 +159,47 @@ module Seeds
72
159
  end
73
160
  end
74
161
 
162
+ # Executes {#seedfile} using `eval`
163
+ #
164
+ # @!visibility private
165
+ #
75
166
  def execute_seedfile
167
+ @current_target_name = nil
168
+
169
+ # Sets `@current_target_name` and executes code block.
170
+ #
171
+ # @param [String] names The name of target.
172
+ #
173
+ # @!scope method
174
+ # @!visibility private
175
+ #
76
176
  def target(*names, &code)
77
177
  names.each do |name|
78
178
  name = name.to_s # use string instead of symbol
79
- @current_target_name = name
80
-
81
179
  target = self.project.target_named(name)
82
180
  if not target
83
181
  raise Seeds::Exception.new\
84
182
  "#{self.project.path.basename} doesn't have a target `#{name}`"
85
183
  end
86
184
 
185
+ @current_target_name = name
87
186
  code.call()
88
187
  end
188
+ @current_target_name = nil
89
189
  end
90
190
 
191
+ # Creates a new instance of {#Seeds::Seed::GitHub} and adds to {#seeds}.
192
+ #
193
+ # @see #Seeds::Seed::GitHub
194
+ #
195
+ # @!scope method
196
+ # @!visibility private
197
+ #
91
198
  def github(repo, tag, options={})
92
199
  if not @current_target_name # apply to all targets
93
200
  target *self.project.targets.map(&:name) do
94
201
  send(__callee__, repo, tag, options)
95
202
  end
96
- @current_target_name = nil
97
203
  else
98
204
  seed = Seeds::Seed::GitHub.new
99
205
  seed.url = "https://github.com/#{repo}"
@@ -104,15 +210,18 @@ module Seeds
104
210
  seed.files = [seed.files]
105
211
  end
106
212
  self.seeds[seed.name] = seed
107
- self.targets[@current_target_name] ||= []
108
- self.targets[@current_target_name] << seed
213
+ self.targets[seed.name] ||= []
214
+ self.targets[seed.name] << @current_target_name.to_s
109
215
  end
110
216
  end
111
217
 
112
218
  eval seedfile
113
- @current_target_name = nil
114
219
  end
115
220
 
221
+ # Removes disused seeds.
222
+ #
223
+ # @!visibility private
224
+ #
116
225
  def remove_seeds
117
226
  removings = self.locks.keys - self.seeds.keys
118
227
  removings.each do |name|
@@ -122,6 +231,10 @@ module Seeds
122
231
  end
123
232
  end
124
233
 
234
+ # Installs new seeds or updates existing seeds.
235
+ #
236
+ # @!visibility private
237
+ #
125
238
  def install_seeds
126
239
  self.seeds.sort.each do |name, seed|
127
240
  dirname = File.join(self.root_path, "Seeds", name)
@@ -159,6 +272,13 @@ module Seeds
159
272
  end
160
273
  end
161
274
 
275
+ # Adds source files to the group 'Seeds' and save its reference to
276
+ # {#file_references} and removes disused sources files,
277
+ #
278
+ # @see #file_references
279
+ #
280
+ # @!visibility private
281
+ #
162
282
  def configure_project
163
283
  say "Configuring #{self.project.path.basename}"
164
284
 
@@ -197,35 +317,59 @@ module Seeds
197
317
  end
198
318
  end
199
319
 
320
+ # Adds file references to the 'Sources Build Phase'.
321
+ #
322
+ # @!visibility private
323
+ #
200
324
  def configure_phase
201
- self.targets.each do |target_name, seeds|
202
- target = self.project.target_named(target_name)
325
+ self.project.targets.each do |target|
203
326
  phase = target.sources_build_phase
204
- if not phase
205
- raise Seeds::Exception.new\
206
- "Target `#{target}` doesn't have build phase 'Compile Sources'."
207
- end
327
+ next if not phase
208
328
 
209
- # remove zombie file references
210
- phase.files_references.each do |file_reference|
329
+ # remove zombie build files
330
+ phase.files_references.each do |file|
211
331
  begin
212
- file_reference.real_path
332
+ file.real_path
213
333
  rescue
214
- phase.remove_file_reference(file_reference)
334
+ phase.files.each do |build_file|
335
+ phase.files.delete(build_file) if build_file.file_ref == file
336
+ end
337
+ end
338
+ end
339
+
340
+ removings = [] # name of seeds going to be removed from the target
341
+ addings = [] # name of seeds going to be added to the target
342
+
343
+ self.targets.keys.sort.each do |seed_name|
344
+ target_names = self.targets[seed_name]
345
+ if not target_names.include?(target.name)
346
+ removings << seed_name if not removings.include?(seed_name)
347
+ else
348
+ addings << seed_name if not addings.include?(seed_name)
215
349
  end
216
350
  end
217
351
 
218
- # add file references to sources build phase
219
- seed_names = seeds.map { |seed| seed.name }
220
352
  self.file_references.each do |file|
221
- if not phase.include?(file) and seed_names.include?(file.parent.name)
222
- uuid = Digest::MD5.hexdigest("#{target_name}:#{file.name}").upcase
353
+ removings.each do |seed_names|
354
+ next if not seed_names.include?(file.parent.name)
355
+ phase.files.each do |build_file|
356
+ phase.files.delete(build_file) if build_file.file_ref == file
357
+ end
358
+ end
359
+
360
+ addings.each do |seed_names|
361
+ next if not seed_names.include?(file.parent.name)
362
+ uuid = Digest::MD5.hexdigest("#{target.name}:#{file.name}").upcase
223
363
  phase.add_file_reference_with_uuid(file, uuid, true)
224
364
  end
225
365
  end
226
366
  end
227
367
  end
228
368
 
369
+ # Writes Seedfile.lock file.
370
+ #
371
+ # @!visibility private
372
+ #
229
373
  def build_lockfile
230
374
  if self.seeds.length > 0
231
375
  tree = { "SEEDS" => [] }
@@ -236,6 +380,10 @@ module Seeds
236
380
  end
237
381
  end
238
382
 
383
+ # Prints a message if {#mute} is `false`.
384
+ #
385
+ # @see #mute
386
+ #
239
387
  def say(*strings)
240
388
  puts strings.join(" ") if not @mute
241
389
  end
@@ -1,14 +1,33 @@
1
1
  module Seeds
2
2
  class Seed
3
- attr_accessor :name, :version, :url, :files
4
3
 
4
+ # @return [String] the name of the seed
5
+ #
6
+ attr_accessor :name
7
+
8
+ # @return [String] the version of the seed
9
+ #
10
+ attr_accessor :version
11
+
12
+ # @return [String] the url of the seed
13
+ #
14
+ attr_accessor :url
15
+
16
+ # @return [Array<String>] the source file patterns of the seed
17
+ #
18
+ attr_accessor :files
19
+
20
+ # @return [String] lockfile-formatted string
21
+ #
22
+ # @example JLToast (1.2.2)
23
+ #
5
24
  def to_s
6
25
  "#{self.name} (#{self.version})"
7
26
  end
8
27
 
9
28
  class GitHub < Seed
10
29
  def to_s
11
- "#{self.name} (#{self.version}) #{files}"
30
+ "#{self.name} (#{self.version})"
12
31
  end
13
32
  end
14
33
  end
@@ -1,3 +1,3 @@
1
1
  module Seeds
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -2,6 +2,10 @@ module Xcodeproj
2
2
 
3
3
  class Project
4
4
 
5
+ # Creates a new object with given UUID.
6
+ #
7
+ # @param [String] uuid UUID of the object.
8
+ #
5
9
  def new_with_uuid(klass, uuid)
6
10
  if klass.is_a?(String)
7
11
  klass = Object.const_get(klass)
@@ -11,10 +15,17 @@ module Xcodeproj
11
15
  object
12
16
  end
13
17
 
18
+ # Creates a new group with given UUID.
19
+ #
20
+ # @param [String] uuid UUID of the object.
21
+ #
14
22
  def new_group_with_uuid(name, uuid, path = nil, source_tree = :group)
15
23
  main_group.new_group_with_uuid(name, uuid, path, source_tree)
16
24
  end
17
25
 
26
+ # @param [String] name The name of target.
27
+ # @return the target with given name
28
+ #
18
29
  def target_named(name)
19
30
  self.targets.each do |target|
20
31
  if target.name == name.to_s
@@ -31,6 +42,11 @@ end
31
42
  module Xcodeproj::Project::Object
32
43
 
33
44
  class PBXGroup
45
+
46
+ # Creates a new group with given UUID.
47
+ #
48
+ # @param [String] uuid UUID of the object.
49
+ #
34
50
  def new_group_with_uuid(name, uuid, path = nil, source_tree = :group)
35
51
  group = project.new_with_uuid(PBXGroup, uuid)
36
52
  children << group
@@ -40,6 +56,11 @@ module Xcodeproj::Project::Object
40
56
  group
41
57
  end
42
58
 
59
+
60
+ # Creates a file reference with given UUID.
61
+ #
62
+ # @param [String] uuid UUID of the object.
63
+ #
43
64
  def new_reference_with_uuid(path, uuid, source_tree = :group)
44
65
  # customize `FileReferencesFactory.new_file_reference`
45
66
  path = Pathname.new(path)
@@ -62,6 +83,9 @@ module Xcodeproj::Project::Object
62
83
  end
63
84
 
64
85
  class PBXNativeTarget
86
+
87
+ # @return 'Sources Build Phase' or `nil`
88
+ #
65
89
  def sources_build_phase()
66
90
  self.build_phases.each do |phase|
67
91
  if phase.kind_of?(Xcodeproj::Project::Object::PBXSourcesBuildPhase)
@@ -73,6 +97,11 @@ module Xcodeproj::Project::Object
73
97
  end
74
98
 
75
99
  class PBXSourcesBuildPhase
100
+
101
+ # Adds the file reference with given UUID.
102
+ #
103
+ # @param [String] uuid UUID of the object.
104
+ #
76
105
  def add_file_reference_with_uuid(file_ref, uuid, avoid_duplicates = false)
77
106
  if avoid_duplicates && existing = build_file(file_ref)
78
107
  existing
@@ -84,18 +113,15 @@ module Xcodeproj::Project::Object
84
113
  end
85
114
  end
86
115
 
116
+ # @return whether the file names match the pattern.
117
+ # @param [Regexp] pattern The pattern of file name.
118
+ #
87
119
  def include_filename?(pattern)
88
- filenames = self.file_display_names
89
- if filenames.length == 0 and pattern
90
- return false
120
+ self.file_display_names.each do |filename|
121
+ return true if filename.match pattern
91
122
  end
92
- filenames.each do |filename|
93
- if not filename.match pattern
94
- return false
95
- end
96
- end
97
- return true
123
+ false
98
124
  end
99
- end
100
125
 
126
+ end
101
127
  end
data/lib/cocoaseeds.rb CHANGED
@@ -6,7 +6,7 @@ require 'yaml'
6
6
 
7
7
  module Seeds
8
8
  require 'cocoaseeds/version'
9
- require_relative 'cocoaseeds/xcodehelper'
9
+ require 'cocoaseeds/xcodehelper'
10
10
 
11
11
  autoload :Command, 'cocoaseeds/command'
12
12
  autoload :Core, 'cocoaseeds/core'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoaseeds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Suyeol Jeon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-11 00:00:00.000000000 Z
11
+ date: 2015-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj
@@ -16,29 +16,32 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 0.24.1
19
+ version: '0.24'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 0.24.1
26
+ version: '0.24'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: colorize
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 0.7.7
33
+ version: '0.7'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: 0.7.7
41
- description: Git Submodule Alternative for Cocoa.
40
+ version: '0.7'
41
+ description: |-
42
+ Git Submodule Alternative for Cocoa.
43
+
44
+ iOS 7 projects are not available to use Swift librariesfrom CocoaPods or Carthage. CocoaSeeds just downloads thesource code and add to your Xcode project. No staticlibraries, no dynamic frameworks at all. It can be usedwith CocoaPods and Carthage.
42
45
  email: devxoul@gmail.com
43
46
  executables:
44
47
  - seed
@@ -80,3 +83,4 @@ signing_key:
80
83
  specification_version: 4
81
84
  summary: Git Submodule Alternative for Cocoa.
82
85
  test_files: []
86
+ has_rdoc: