zimt 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,23 @@
1
+ Zimt manages your Objective C dependencies. It
2
+
3
+ * autoupdates your .xcodeproj when you add a library
4
+ * downloads the files for your
5
+
6
+
7
+ Usage
8
+ =====
9
+
10
+ cd ~/projects/AwesomeApp/
11
+ zimt add TTTAttributedLabel
12
+
13
+ Installation
14
+ ============
15
+
16
+ If you don't have a custom Ruby installed:
17
+
18
+ sudo gem install zimt
19
+
20
+ If you use RVM, rbenv or just installed your own Ruby your probably know what do to ;)
21
+
22
+ gem install zimt
23
+
@@ -12,6 +12,10 @@ module Zimt
12
12
  @buffer
13
13
  end
14
14
 
15
+
16
+ FILE_FORMATS = { '.png' => 'image.png',
17
+ '.plist' => 'text.plist.xml' }
18
+
15
19
  # Documentation on PBXObjectId by @tjw
16
20
  # http://lists.apple.com/archives/projectbuilder-users/2003/Jan/msg00263.html
17
21
  #
@@ -30,15 +34,18 @@ module Zimt
30
34
  def uuid
31
35
  # TODO
32
36
  @prefix ||= randhex(4)
33
- @suffix ||= Time.now.to_i.to_s(16).upcase + randhex(8)
34
- @count ||= rand(16**4)
37
+ @suffix ||= randhex(16)
38
+ @count ||= randhex(4).to_i(16)
35
39
  @count += 1
36
- if @count.to_s(16).length < 4
37
- @count = @count * 16
40
+ if @count.to_s(16).length > 4
41
+ @count = randhex(4).to_i(16)
38
42
  end
39
43
  uuid = "#{@prefix}#{@count.to_s(16).upcase}#{@suffix}"
40
44
  if uuid.length != 24
41
45
  puts "uuid length wrong: #{uuid}"
46
+ puts @prefix
47
+ puts @suffix
48
+ puts @count
42
49
  exit
43
50
  end
44
51
  uuid
@@ -69,6 +76,20 @@ module Zimt
69
76
  self.root.mainGroup.children.select{ |g| g.path == 'Zimt' }.first
70
77
  end
71
78
 
79
+ def license_file
80
+ return unless self.zimt_group
81
+ self.zimt_group.children.select { |g| g.path == '3rdPartyLicenses.txt' }
82
+ end
83
+
84
+ def ensure_license_file
85
+ self.ensure_zimt_group
86
+ FileUtils.mkdir "Zimt" if not File.exists? "Zimt"
87
+ if self.license_file.first.nil?
88
+ self.add_resource_file('3rdPartyLicenses.txt')
89
+ FileUtils.touch('Zimt/3rdPartyLicenses.txt')
90
+ end
91
+ end
92
+
72
93
  def ensure_zimt_group
73
94
  zimt_group = self.zimt_group
74
95
  if zimt_group.nil?
@@ -132,9 +153,9 @@ module Zimt
132
153
  # C5D0CB021406C3AA002E631F /* Hans.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Hans.h; sourceTree = "<group>"; };
133
154
  #/* End PBXFileReference section */
134
155
  def add_file(file, file_type)
135
- zimt_group_id = self.zimt_group.pbxid
156
+ @position = 0
136
157
  # Add file to Zimt group
137
- groupid = self.root.mainGroup.pbxid
158
+ zimt_group_id = self.zimt_group.pbxid
138
159
  scan_to "\t\t#{zimt_group_id}"
139
160
  scan_to "\t\t\t);"
140
161
  newgroup = self.uuid
@@ -179,14 +200,21 @@ module Zimt
179
200
 
180
201
  def add_m_file(file)
181
202
  fileref = self.add_file(file, "sourcecode.c.objc")
182
- buildfileref = self.add_buildfile(file, fileref)
183
- add_buildfileref_to_build_phase(file, buildfileref)
203
+ buildfileref = self.add_buildfile(file, fileref, "Sources")
204
+ add_buildfileref_to_build_phase(file, buildfileref, "Sources")
205
+ end
206
+
207
+ def add_resource_file(file)
208
+ file_type = FILE_FORMATS[Pathname.new(file).extname.downcase] || 'text'
209
+ fileref = self.add_file(file, file_type)
210
+ buildfileref = self.add_buildfile(file, fileref, "Resources")
211
+ add_buildfileref_to_build_phase(file, buildfileref, "Resources")
184
212
  end
185
213
 
186
214
  #/* Begin PBXBuildFile section */
187
215
  # C53D93B21406F98300F4CDDE /* Hans.m in Sources */ = {isa = PBXBuildFile; fileRef = C53D93B11406F98300F4CDDE /* Hans.m */; };
188
216
  #/* End PBXBuildFile section */
189
- def add_buildfile(file, fileref)
217
+ def add_buildfile(file, fileref, filetype)
190
218
  newgroup = self.uuid
191
219
  # Find position for Zimt reference in PBXGRoup section
192
220
  @position = 0
@@ -207,7 +235,7 @@ module Zimt
207
235
 
208
236
  # Add Zimt Group
209
237
  self.content.insert(@position,
210
- "\t\t#{newgroup} /* #{file} in Sources */ = {isa = PBXBuildFile; fileRef = #{fileref} /* #{file} */; };\n")
238
+ "\t\t#{newgroup} /* #{file} in #{filetype} */ = {isa = PBXBuildFile; fileRef = #{fileref} /* #{file} */; };\n")
211
239
 
212
240
  self.save!
213
241
  self.parse
@@ -221,11 +249,11 @@ module Zimt
221
249
  # );
222
250
  # C56D96C81385E71800070608 /* Sources */ = {
223
251
  #/* End PBXSourcesBuildPhase section */
224
- def add_buildfileref_to_build_phase(file, buildfileref)
252
+ def add_buildfileref_to_build_phase(file, buildfileref, phase_name)
225
253
  @position = 0
226
- scan_to "/* Begin PBXSourcesBuildPhase section */"
254
+ scan_to "/* Begin PBX#{phase_name}BuildPhase section */"
227
255
  begin_position = @position
228
- scan_to "/* End PBXSourcesBuildPhase section */"
256
+ scan_to "/* End PBX#{phase_name}BuildPhase section */"
229
257
  end_position = @position
230
258
 
231
259
  @position = begin_position
@@ -235,7 +263,7 @@ module Zimt
235
263
  old_position = @position
236
264
  scan_to(" );\n")
237
265
  self.content.insert(@position,
238
- " #{buildfileref} /* #{file} in Sources */,\n")
266
+ " #{buildfileref} /* #{file} in #{phase_name} */,\n")
239
267
  @position = old_position + 1 # offset for added line
240
268
  break
241
269
  end
@@ -1,6 +1,27 @@
1
1
  module Zimt
2
2
  class Sprinkle
3
- attr_accessor :name, :url, :files
3
+ attr_accessor :name, :url, :files, :spec
4
+
5
+ LICENSES = {}
6
+ LICENSES["MIT"] = <<EOF
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
24
+ EOF
4
25
 
5
26
  def self.get(name)
6
27
  if name.start_with?('http://') || name.start_with?('https://')
@@ -21,7 +42,6 @@ module Zimt
21
42
 
22
43
  def install
23
44
  puts "Installing #{name}"
24
- FileUtils.mkdir "Zimt" if not File.exists? "Zimt"
25
45
  Zimt.pbxproj.ensure_zimt_group
26
46
  files.each do |url|
27
47
  file = Pathname.new(URI.parse(url).path).basename('.sprinkle.yml').to_s
@@ -31,10 +51,26 @@ module Zimt
31
51
  end
32
52
  if file.end_with? ".m"
33
53
  Zimt.pbxproj.add_m_file(file)
34
- else
54
+ elsif file.end_with? ".h"
35
55
  Zimt.pbxproj.add_h_file(file)
56
+ else
57
+ Zimt.pbxproj.add_resource_file(file)
36
58
  end
37
59
  end
60
+
61
+ if(spec["license"] || spec["copyright"])
62
+ puts "Licensed under #{spec["license"]}"
63
+ Zimt.pbxproj.ensure_license_file
64
+ open(Pathname.new("Zimt").join("3rdPartyLicenses.txt"), "a") do |io|
65
+ io.write "License for #{name}:\n\n"
66
+ io.write spec["copyright"]
67
+ io.write "\n\n"
68
+ license = LICENSES[spec["license"]] || "#{spec["license"]}\n"
69
+ io.write license
70
+ io.write "\n----------\n\n"
71
+ end
72
+ end
73
+
38
74
  puts "All done"
39
75
  end
40
76
  end
@@ -1,3 +1,3 @@
1
1
  module Zimt
2
- VERSION = "0.0.4" # See http://semver.org/
2
+ VERSION = "0.0.5" # See http://semver.org/
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 4
9
- version: 0.0.4
8
+ - 5
9
+ version: 0.0.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Martin Schu\xCC\x88rrer"
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-08-29 00:00:00 +02:00
17
+ date: 2011-09-08 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -86,6 +86,7 @@ files:
86
86
  - .gitignore
87
87
  - .rvmrc
88
88
  - Gemfile
89
+ - README.md
89
90
  - Rakefile
90
91
  - bin/zimt
91
92
  - lib/zimt.rb