xcoder 0.1.8 → 0.1.9

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.
data/README.md CHANGED
@@ -6,6 +6,10 @@ Xcoder is a ruby wrapper around various Xcode tools as well as providing project
6
6
 
7
7
  Full documentation can be found here: http://rayh.github.com/xcoder/
8
8
 
9
+ ## Requirements
10
+
11
+ Xcoder assumes you are using XCode 4.3 on Lion and ruby 1.9. You may have some degree of success with lesser versions, but they are not intentionally supported.
12
+
9
13
  ## Example Usage
10
14
 
11
15
  You will need to install the gem:
@@ -47,6 +51,11 @@ You can either use the user's login keychain, another named keychain, or simply
47
51
  # import certs into the keychain
48
52
  # perform builds within this keychain's context
49
53
  end # Keychain is deleted
54
+
55
+ Or, you can create a temporary keychain that will be deleted when the process exits:
56
+
57
+ keychain = Xcode::Keychain.temp
58
+
50
59
 
51
60
  #### Importing a certificate
52
61
 
@@ -285,7 +285,9 @@ module Xcode
285
285
  # @return [String,Array,Hash] the value stored for the specified configuration
286
286
  #
287
287
  def get(name)
288
- if Configuration.setting_name_to_property(name)
288
+ if respond_to?(name)
289
+ send(name)
290
+ elsif Configuration.setting_name_to_property(name)
289
291
  send Configuration.setting_name_to_property(name)
290
292
  else
291
293
  build_settings[name]
@@ -299,7 +301,9 @@ module Xcode
299
301
  # @param [String,Array,Hash] value the value to store for the specific setting
300
302
  #
301
303
  def set(name, value)
302
- if Configuration.setting_name_to_property(name)
304
+ if respond_to?(name)
305
+ send("#{name}=",value)
306
+ elsif Configuration.setting_name_to_property(name)
303
307
  send("#{Configuration.setting_name_to_property(name)}=",value)
304
308
  else
305
309
  build_settings[name] = value
@@ -313,12 +317,37 @@ module Xcode
313
317
  # @param [String,Array,Hash] value the value to store for the specific setting
314
318
  #
315
319
  def append(name, value)
316
- if Configuration.setting_name_to_property(name)
320
+
321
+ if respond_to?(name)
322
+ send("append_to_#{name}",value)
323
+ elsif Configuration.setting_name_to_property(name)
317
324
  send("append_to_#{Configuration.setting_name_to_property(name)}",value)
318
325
  else
319
- # @todo this will likely raise some errors if trying to append a string
320
- # to an array, but that likely means a new property should be defined.
321
- build_settings[name] = build_settings[name] + value
326
+
327
+ # @note this will likely raise some errors if trying to append a booleans
328
+ # to fixnums, strings to booleans, symbols + arrays, etc. but that likely
329
+ # means a new property should be defined so that the appending logic
330
+ # wil behave correctly.
331
+
332
+ if build_settings[name].is_a?(Array)
333
+
334
+ # Ensure that we are appending an array to the array; Array() does not
335
+ # work in this case in the event we were to pass in a Hash.
336
+ value = value.is_a?(Array) ? value : [ value ]
337
+ build_settings[name] = build_settings[name] + value.compact
338
+
339
+ else
340
+
341
+ # Ensure we handle the cases where a nil value is present that we append
342
+ # correctly to the value. We also need to try and leave intact boolean
343
+ # values which may be stored
344
+
345
+ value = "" unless value
346
+ build_settings[name] = "" unless build_settings[name]
347
+
348
+ build_settings[name] = build_settings[name] + value
349
+ end
350
+
322
351
  end
323
352
  end
324
353
 
@@ -28,10 +28,10 @@ module Xcode
28
28
  end
29
29
 
30
30
  def append(original,value)
31
- (Array(original) + Array(value)).uniq
31
+ (open(original) + Array(value)).uniq
32
32
  end
33
33
 
34
34
  end
35
35
 
36
36
  end
37
- end
37
+ end
@@ -36,11 +36,19 @@ module Xcode
36
36
  value.to_s =~ /^(?:NO|false)$/ ? "NO" : "YES"
37
37
  end
38
38
 
39
+ #
40
+ # @note Appending boolean properties has no real good default operation. What
41
+ # happens in this case is that whatever you decide to append will automatically
42
+ # override the previously existing settings.
43
+ #
44
+ # @param [Types] original the original value to be appended
45
+ # @param [Types] value Description
46
+ #
39
47
  def append(original,value)
40
- save(original) | save(value)
48
+ save(value)
41
49
  end
42
50
 
43
51
  end
44
52
 
45
53
  end
46
- end
54
+ end
@@ -32,11 +32,11 @@ module Xcode
32
32
  # back out to a key=value pair array.
33
33
  #
34
34
  def append(original,value)
35
- all_values = (Array(original) + Array(value)).map {|key_value| key_value.split("=") }.flatten
35
+ all_values = (open(original) + Array(value)).map {|key_value| key_value.split("=") }.flatten
36
36
  Hash[*all_values].map {|k,v| "#{k}=#{v}" }
37
37
  end
38
38
 
39
39
  end
40
40
 
41
41
  end
42
- end
42
+ end
@@ -26,11 +26,16 @@ module Xcode
26
26
  extend self
27
27
 
28
28
  #
29
+ # While the space delimited string can and is often stored in that way,
30
+ # it appears as though Xcode is now possibly storing these values in a format
31
+ # that the parser is returning as an Array. So if the raw value is an
32
+ # array, simply return that raw value instead of attempting to convert it.
33
+ #
29
34
  # @param [Nil,String] value stored within the build settings
30
35
  # @return [Array<String>] a list of the strings that are within this string
31
36
  #
32
37
  def open(value)
33
- value.to_s.split(" ")
38
+ value.is_a?(Array) ? value : value.to_s.split(" ")
34
39
  end
35
40
 
36
41
  #
@@ -41,11 +46,20 @@ module Xcode
41
46
  Array(value).join(" ")
42
47
  end
43
48
 
49
+ #
50
+ # Space Delimited Strings are not unlike arrays and those we assume that the
51
+ # inputs are going to be two arrays that will be joined and then ensured
52
+ # that only the unique values are saved.
53
+ #
54
+ # @param [Nil,String] original the original value stored within the field
55
+ # @param [Nil,String,Array] value the new values that will coerced into an array
56
+ # and joined with the original values.
57
+ #
44
58
  def append(original,value)
45
- save( ( open(original) + open(value) ).uniq )
59
+ save( ( open(original) + Array(value)).uniq )
46
60
  end
47
61
 
48
62
  end
49
63
 
50
64
  end
51
- end
65
+ end
@@ -20,10 +20,10 @@ module Xcode
20
20
  end
21
21
 
22
22
  def append(original,value)
23
- original.to_s + value.to_s
23
+ open(original) + value.to_s
24
24
  end
25
25
 
26
26
  end
27
27
 
28
28
  end
29
- end
29
+ end
@@ -67,8 +67,7 @@ module Xcode
67
67
  # @return [Hash] system framework properties
68
68
  #
69
69
  def self.system_framework(name,properties = {})
70
-
71
- name = name[/(.+)(?:\.framework)?$/,1]
70
+ name = name.gsub(File.extname(name),"")
72
71
 
73
72
  default_properties = { 'isa' => 'PBXFileReference',
74
73
  'lastKnownFileType' => 'wrapper.framework',
@@ -135,4 +134,4 @@ module Xcode
135
134
 
136
135
  end
137
136
 
138
- end
137
+ end
data/lib/xcode/group.rb CHANGED
@@ -98,7 +98,9 @@ module Xcode
98
98
  # if no matches were found.
99
99
  #
100
100
  def exists?(name)
101
- children.find_all {|child| child.name == name }
101
+ children.find_all do |child|
102
+ child.name ? (child.name == name) : (File.basename(child.path) == name)
103
+ end
102
104
  end
103
105
 
104
106
  #
@@ -144,11 +146,13 @@ module Xcode
144
146
  # found.
145
147
 
146
148
  find_file_by = file_properties['name'] || file_properties['path']
149
+
147
150
  found_or_created_file = exists?(find_file_by).first
148
151
 
149
152
  unless found_or_created_file
150
153
  found_or_created_file = create_child_object FileReference.file(file_properties)
151
154
  end
155
+
152
156
  found_or_created_file.supergroup = self
153
157
 
154
158
  found_or_created_file
@@ -292,4 +296,4 @@ module Xcode
292
296
 
293
297
  end
294
298
 
295
- end
299
+ end
@@ -52,6 +52,17 @@ module Xcode
52
52
  names
53
53
  end
54
54
 
55
+ #
56
+ # Secure the keychain
57
+ #
58
+ def lock
59
+ cmd = []
60
+ cmd << "security"
61
+ cmd << "lock-keychain"
62
+ cmd << "\"#{@path}\""
63
+ Xcode::Shell.execute(cmd)
64
+ end
65
+
55
66
  #
56
67
  # Unlock the keychain using the provided password
57
68
  #
@@ -14,7 +14,25 @@ module Xcode
14
14
  xml = `plutil -convert xml1 -o - "#{path}"`
15
15
  Plist::parse_xml(xml)
16
16
  end
17
+
18
+ #
19
+ # Save the outputed string data to the specified project file path and then
20
+ # formats that data to be prettier than the default output.
21
+ #
22
+ def save path,data
23
+
24
+ File.open(path,'w') do |file|
25
+ file.puts data
26
+ end
27
+
28
+ #
29
+
30
+ if File.exists?(path)
31
+ `pl -input #{path} -output #{path}`
32
+ end
33
+
34
+ end
17
35
 
18
36
  end
19
37
 
20
- end
38
+ end
data/lib/xcode/project.rb CHANGED
@@ -195,16 +195,15 @@ module Xcode
195
195
  # @param [String] path the path to save the project
196
196
  #
197
197
  def save(path)
198
- Dir.mkdir(path) unless File.exists?(path)
199
198
 
199
+ Dir.mkdir(path) unless File.exists?(path)
200
200
  project_filepath = "#{path}/project.pbxproj"
201
201
 
202
202
  # @toodo Save the workspace when the project is saved
203
203
  # FileUtils.cp_r "#{path}/project.xcworkspace", "#{path}/project.xcworkspace"
204
+
205
+ Xcode::PLUTILProjectParser.save "#{@path}/project.pbxproj", to_xcplist
204
206
 
205
- File.open(project_filepath,'w') do |file|
206
- file.puts to_xcplist
207
- end
208
207
  end
209
208
 
210
209
  #
@@ -46,7 +46,7 @@ module Xcode
46
46
  # identifier; false if it is not.
47
47
  #
48
48
  def self.is_identifier? value
49
- value =~ /^[0-9A-F]{24}$/
49
+ value =~ /^[0-9A-F]{24,}$/
50
50
  end
51
51
 
52
52
  #
data/lib/xcode/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Xcode
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -68,10 +68,17 @@ describe Xcode::Configuration do
68
68
 
69
69
  it "should append to existing settings" do
70
70
  subject.set 'OTHER_LDFLAGS', '-NONE'
71
- subject.append 'OTHER_LDFLAGS', '-FOR -ME'
71
+ subject.append 'OTHER_LDFLAGS', '-FOR'
72
+ subject.append 'OTHER_LDFLAGS', [ '-FOR' , '-ME' ]
72
73
  settings['OTHER_LDFLAGS'].should == "-NONE -FOR -ME"
73
74
  end
74
75
 
76
+ it "should append to existing settings" do
77
+ subject.set 'OTHER_LDFLAGS', '-NONE -FOR'
78
+ subject.append 'OTHER_LDFLAGS', '-FOR'
79
+ subject.append 'OTHER_LDFLAGS', [ '-FOR' , '-ME' ]
80
+ settings['OTHER_LDFLAGS'].should == "-FOR -ME"
81
+ end
75
82
  end
76
83
 
77
84
  describe "#get" do
@@ -331,4 +338,4 @@ describe Xcode::Configuration do
331
338
  end
332
339
  end
333
340
 
334
- end
341
+ end
@@ -26,6 +26,14 @@ describe Xcode::Keychain do
26
26
  kc.identities[0].should=="Test User"
27
27
  end
28
28
 
29
+ # FIXME: Need to surpress GUI dialog prompting to unlock keychain
30
+ # it "should lock the keychain" do
31
+ # kc = Xcode::Keychain.temp
32
+ # kc.lock
33
+ # kc.import "#{File.dirname(__FILE__)}/Provisioning/TestUser.p12", 'testpassword'
34
+ # kc.identities.size.should==0
35
+ # end
36
+
29
37
  it "should fetch the login keychain" do
30
38
  kc = Xcode::Keychain.login
31
39
  File.exists?(kc.path).should==true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcoder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-03-16 00:00:00.000000000Z
13
+ date: 2012-03-25 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
17
- requirement: &70302521954920 !ruby/object:Gem::Requirement
17
+ requirement: &70245902880760 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70302521954920
25
+ version_requirements: *70245902880760
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: plist
28
- requirement: &70302524739260 !ruby/object:Gem::Requirement
28
+ requirement: &70245902896700 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70302524739260
36
+ version_requirements: *70245902896700
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: nokogiri
39
- requirement: &70302524738840 !ruby/object:Gem::Requirement
39
+ requirement: &70245902896280 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70302524738840
47
+ version_requirements: *70245902896280
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: builder
50
- requirement: &70302524738420 !ruby/object:Gem::Requirement
50
+ requirement: &70245902895860 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *70302524738420
58
+ version_requirements: *70245902895860
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rest-client
61
- requirement: &70302524738000 !ruby/object:Gem::Requirement
61
+ requirement: &70245902895440 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,7 +66,7 @@ dependencies:
66
66
  version: '0'
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *70302524738000
69
+ version_requirements: *70245902895440
70
70
  description: Provides a ruby based object-model for parsing project structures and
71
71
  invoking builds
72
72
  email: