rxcode 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ require 'rxcode/spec/rake_task'
2
+
3
+ RXCode::Spec::RakeTask.new("rxcode:spec")
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rxcode'
4
+ gem 'rspec', '~>2.5.0'
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'rxcode/tasks'
3
+
4
+ task :default => "rxcode:spec"
@@ -0,0 +1,14 @@
1
+ require 'rxcode/spec_helper'
2
+
3
+ # Requires supporting ruby files with custom matchers and macros, etc, in spec/support/ and its subdirectories.
4
+ Dir[ File.expand_path("../support/**/*.rb", __FILE__) ].each { |f| require f }
5
+
6
+ # Add any external framework requirements here, using MacRuby's 'framework' method like so:
7
+ #
8
+ # framework 'Cocoa'
9
+ # framework 'Quartz'
10
+ #
11
+ # To load a framework from your project or workspace, use RXCode.framework:
12
+ #
13
+ # RXCode.framework('MyFramework')
14
+ #
@@ -0,0 +1,173 @@
1
+ module RXCode
2
+
3
+ class Workspace
4
+
5
+ def initialize(workspace_path)
6
+ unless self.class.is_workspace_at_path?(workspace_path)
7
+ raise "#{workspace_path.inspect} is not a valid XCode workspace path"
8
+ end
9
+
10
+ @path = workspace_path
11
+ end
12
+
13
+ # ===== WORKSPACE DISCOVERY ========================================================================================
14
+
15
+ WORKSPACE_EXTENSION = '.xcworkspace'
16
+
17
+ def self.is_workspace_at_path?(path)
18
+ File.extname(path) == WORKSPACE_EXTENSION && File.directory?(path)
19
+ end
20
+
21
+ # ===== PATH =======================================================================================================
22
+
23
+ attr_reader :path
24
+
25
+ def root
26
+ if project_dependent?
27
+ File.expand_path('../..', path)
28
+ else
29
+ File.dirname(path)
30
+ end
31
+ end
32
+
33
+ def resolve_file_reference(location)
34
+ if location =~ /^(?:container|group):(.*)$/
35
+ File.expand_path("../#{$1}", path)
36
+ else
37
+ location
38
+ end
39
+ end
40
+
41
+ def name
42
+ File.basename(path, '.xcworkspace')
43
+ end
44
+
45
+ # ===== PROJECTS ===================================================================================================
46
+
47
+ def project_dependent?
48
+ name == 'project' && RXCode::Project.is_project_at_path?(File.dirname(path))
49
+ end
50
+
51
+ def enclosing_product_path
52
+ File.dirname(path) if project_dependent?
53
+ end
54
+
55
+ def project_independent?
56
+ !project_dependent?
57
+ end
58
+
59
+ def projects
60
+ @projects ||= project_paths.map { |project_path| Project.new(project_path, :workspace => self) }
61
+ end
62
+
63
+ def project_paths
64
+ require 'nokogiri'
65
+
66
+ if project_dependent?
67
+
68
+ [ File.dirname(path) ]
69
+
70
+ elsif File.exist?(contents_path)
71
+ document = Nokogiri::XML(File.read(contents_path))
72
+
73
+ document.xpath('/Workspace/FileRef').collect { |element|
74
+ resolve_file_reference(element['location']) if element['location'] =~ /\.xcodeproj$/
75
+ }.compact
76
+
77
+ else
78
+ []
79
+ end
80
+ end
81
+
82
+ # ===== CONTENTS ===================================================================================================
83
+
84
+ def contents_path
85
+ @contents_path ||= File.join(path, 'contents.xcworkspacedata').freeze
86
+ end
87
+
88
+ # ===== BUILD LOCATION =============================================================================================
89
+
90
+ def derived_data_location
91
+ derived_data_style = value_for_setting('IDEWorkspaceUserSettings_DerivedDataLocationStyle')
92
+ custom_derived_data_location = value_for_setting('IDEWorkspaceUserSettings_DerivedDataCustomLocation')
93
+
94
+ if derived_data_style == 2 # 2 is the code for 'Workspace-relative path'
95
+ File.expand_path(custom_derived_data_location, self.root)
96
+ else
97
+
98
+ prefs = RXCode.xcode_preferences
99
+ if prefs.derived_data_location_is_relative_to_workspace?
100
+ File.expand_path(prefs.derived_data_location, self.root)
101
+ else
102
+ prefs.derived_data_location
103
+ end
104
+
105
+ end
106
+ end
107
+
108
+ def build_location
109
+ Dir[File.join(derived_data_location, '*/info.plist')].each do |info_plist_path|
110
+ build_location_data = Plist::parse_xml(info_plist_path)
111
+ workspace_path = build_location_data['WorkspacePath']
112
+
113
+ if workspace_path == self.path || (project_dependent? && workspace_path == enclosing_product_path)
114
+ return File.dirname(info_plist_path)
115
+ end
116
+ end
117
+
118
+ nil
119
+ end
120
+
121
+ def built_products_dir
122
+ if build_root = build_location
123
+ File.join(build_root, "Build/Products")
124
+ end
125
+ end
126
+
127
+ # ===== SETTINGS ===================================================================================================
128
+
129
+ def shared_data_directory
130
+ File.join(self.path, "xcshareddata")
131
+ end
132
+
133
+ def shared_settings_file
134
+ File.join(shared_data_directory, "WorkspaceSettings.xcsettings")
135
+ end
136
+
137
+ def shared_settings
138
+ settings_file = shared_settings_file
139
+ if File.file?(settings_file)
140
+ Plist::parse_xml(settings_file)
141
+ else
142
+ {}
143
+ end
144
+ end
145
+
146
+ def user_data_directory_for_user(user_name)
147
+ File.join(path, "xcuserdata", "#{user_name}.xcuserdatad")
148
+ end
149
+
150
+ def settings_file_for_user(user_name)
151
+ File.join(user_data_directory_for_user(user_name), "WorkspaceSettings.xcsettings")
152
+ end
153
+
154
+ def settings_for_user(user_name)
155
+ settings_file = settings_file_for_user(user_name)
156
+ if File.file?(settings_file)
157
+ Plist::parse_xml(settings_file)
158
+ else
159
+ {}
160
+ end
161
+ end
162
+
163
+ def user_settings
164
+ settings_for_user(ENV['USER'])
165
+ end
166
+
167
+ def value_for_setting(setting_name)
168
+ user_settings[setting_name] || shared_settings[setting_name]
169
+ end
170
+
171
+ end
172
+
173
+ end
metadata ADDED
@@ -0,0 +1,184 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rxcode
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.5
6
+ platform: ruby
7
+ authors:
8
+ - Christian Niles
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-06-14 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: plist
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: trollop
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: nokogiri
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: gemcutter
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 0.7.0
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: rspec
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 2.6.0
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: bundler
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: 1.0.0
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: jeweler
84
+ requirement: &id007 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 1.6.2
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: rcov
95
+ requirement: &id008 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: "0"
101
+ type: :development
102
+ prerelease: false
103
+ version_requirements: *id008
104
+ description: A Ruby interface for working with XCode projects.
105
+ email: christian@nerdyc.com
106
+ executables:
107
+ - rxcode
108
+ - rxcode
109
+ extensions: []
110
+
111
+ extra_rdoc_files:
112
+ - LICENSE.txt
113
+ - README.md
114
+ files:
115
+ - Gemfile
116
+ - LICENSE.txt
117
+ - README.md
118
+ - Rakefile
119
+ - VERSION
120
+ - bin/rxcode
121
+ - lib/rxcode.rb
122
+ - lib/rxcode/command.rb
123
+ - lib/rxcode/commands.rb
124
+ - lib/rxcode/commands/env.rb
125
+ - lib/rxcode/commands/init.rb
126
+ - lib/rxcode/commands/unwrap.rb
127
+ - lib/rxcode/environment.rb
128
+ - lib/rxcode/macruby.rb
129
+ - lib/rxcode/models.rb
130
+ - lib/rxcode/models/archive.rb
131
+ - lib/rxcode/models/archived_object.rb
132
+ - lib/rxcode/models/build_configuration.rb
133
+ - lib/rxcode/models/build_configuration_list.rb
134
+ - lib/rxcode/models/file_reference.rb
135
+ - lib/rxcode/models/model.rb
136
+ - lib/rxcode/models/project.rb
137
+ - lib/rxcode/models/target.rb
138
+ - lib/rxcode/preferences.rb
139
+ - lib/rxcode/spec/nserror_helpers.rb
140
+ - lib/rxcode/spec/rake_ext.rb
141
+ - lib/rxcode/spec/rake_task.rb
142
+ - lib/rxcode/spec_helper.rb
143
+ - lib/rxcode/tasks.rb
144
+ - lib/rxcode/tasks/bridge_support.rb
145
+ - lib/rxcode/tasks/ios_framework.rb
146
+ - lib/rxcode/tasks/spec.rb
147
+ - lib/rxcode/templates/Gemfile
148
+ - lib/rxcode/templates/Rakefile
149
+ - lib/rxcode/templates/spec/spec_helper.rb
150
+ - lib/rxcode/templates/spec/support/.gitkeep
151
+ - lib/rxcode/workspace.rb
152
+ has_rdoc: true
153
+ homepage: http://github.com/vulpinelabs/rxcode
154
+ licenses:
155
+ - MIT
156
+ post_install_message:
157
+ rdoc_options: []
158
+
159
+ require_paths:
160
+ - lib
161
+ required_ruby_version: !ruby/object:Gem::Requirement
162
+ none: false
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ hash: -765993797625968619
167
+ segments:
168
+ - 0
169
+ version: "0"
170
+ required_rubygems_version: !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: "0"
176
+ requirements: []
177
+
178
+ rubyforge_project:
179
+ rubygems_version: 1.6.2
180
+ signing_key:
181
+ specification_version: 3
182
+ summary: A Ruby interface for working with XCode projects.
183
+ test_files: []
184
+