xcodeproj 0.2.0 → 0.3.0

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.
@@ -7,12 +7,12 @@ module Xcodeproj
7
7
  # @param [Hash, File, String] xcconfig_hash_or_file Initial data.
8
8
  require 'set'
9
9
 
10
- attr_accessor :attributes, :frameworks ,:libraries
10
+ attr_accessor :attributes, :frameworks, :weak_frameworks ,:libraries
11
11
 
12
12
  def initialize(xcconfig_hash_or_file = {})
13
13
  @attributes = {}
14
14
  @includes = []
15
- @frameworks, @libraries = Set.new, Set.new
15
+ @frameworks, @weak_frameworks, @libraries = Set.new, Set.new, Set.new
16
16
  merge!(extract_hash(xcconfig_hash_or_file))
17
17
  end
18
18
 
@@ -23,6 +23,7 @@ module Xcodeproj
23
23
  flags = flags.dup.strip
24
24
  flags << libraries.to_a.sort.reduce('') {| memo, l | memo << " -l#{l}" }
25
25
  flags << frameworks.to_a.sort.reduce('') {| memo, f | memo << " -framework #{f}" }
26
+ flags << weak_frameworks.to_a.sort.reduce('') {| memo, f | memo << " -weak_framework #{f}" }
26
27
  hash['OTHER_LDFLAGS'] = flags.strip
27
28
  hash.delete('OTHER_LDFLAGS') if flags.strip.empty?
28
29
  hash
@@ -63,6 +64,7 @@ module Xcodeproj
63
64
  @attributes.merge!(xcconfig.attributes) { |key, v1, v2| "#{v1} #{v2}" }
64
65
  @libraries.merge xcconfig.libraries
65
66
  @frameworks.merge xcconfig.frameworks
67
+ @weak_frameworks.merge xcconfig.weak_frameworks
66
68
  else
67
69
  @attributes.merge!(xcconfig.to_hash) { |key, v1, v2| "#{v1} #{v2}" }
68
70
  # Parse frameworks and libraries. Then remove the from the linker flags
@@ -70,12 +72,15 @@ module Xcodeproj
70
72
  return unless flags
71
73
 
72
74
  frameworks = flags.scan(/-framework\s+([^\s]+)/).map { |m| m[0] }
75
+ weak_frameworks = flags.scan(/-weak_framework\s+([^\s]+)/).map { |m| m[0] }
73
76
  libraries = flags.scan(/-l ?([^\s]+)/).map { |m| m[0] }
74
77
  @frameworks.merge frameworks
78
+ @weak_frameworks.merge weak_frameworks
75
79
  @libraries.merge libraries
76
80
 
77
81
  new_flags = flags.dup
78
82
  frameworks.each {|f| new_flags.gsub!("-framework #{f}", "") }
83
+ weak_frameworks.each {|f| new_flags.gsub!("-weak_framework #{f}", "") }
79
84
  libraries.each {|l| new_flags.gsub!("-l#{l}", ""); new_flags.gsub!("-l #{l}", "") }
80
85
  @attributes['OTHER_LDFLAGS'] = new_flags.gsub("\w*", ' ').strip
81
86
  end
@@ -1,5 +1,3 @@
1
- require 'xcodeproj/inflector'
2
-
3
1
  module Xcodeproj
4
2
  class Project
5
3
  module Object
@@ -13,9 +13,6 @@ module Xcodeproj
13
13
  'ALWAYS_SEARCH_USER_PATHS' => 'NO',
14
14
  'GCC_C_LANGUAGE_STANDARD' => 'gnu99',
15
15
  'INSTALL_PATH' => "$(BUILT_PRODUCTS_DIR)",
16
- 'GCC_WARN_ABOUT_MISSING_PROTOTYPES' => 'YES',
17
- 'GCC_WARN_ABOUT_RETURN_TYPE' => 'YES',
18
- 'GCC_WARN_UNUSED_VARIABLE' => 'YES',
19
16
  'OTHER_LDFLAGS' => '',
20
17
  'COPY_PHASE_STRIP' => 'YES',
21
18
  }.freeze,
@@ -35,7 +32,6 @@ module Xcodeproj
35
32
  :osx => {
36
33
  'ARCHS' => "$(ARCHS_STANDARD_64_BIT)",
37
34
  'GCC_ENABLE_OBJC_EXCEPTIONS' => 'YES',
38
- 'GCC_WARN_64_TO_32_BIT_CONVERSION' => 'YES',
39
35
  'GCC_VERSION' => 'com.apple.compilers.llvm.clang.1_0',
40
36
  'MACOSX_DEPLOYMENT_TARGET' => '10.7',
41
37
  'SDKROOT' => 'macosx',
@@ -92,11 +92,31 @@ module Xcodeproj
92
92
  groups.new("name" => name)
93
93
  end
94
94
 
95
+ def version_groups
96
+ children.list_by_class(XCVersionGroup)
97
+ end
98
+
95
99
  def <<(child)
96
100
  children << child
97
101
  end
98
102
  end
99
103
 
104
+ class XCVersionGroup < PBXGroup
105
+
106
+ attribute :version_group_type
107
+ attribute :current_version
108
+
109
+ def self.new_xcdatamodel_group(project, xcdatamodel_path)
110
+ group = new(project, nil, 'versionGroupType' => 'wrapper.xcdatamodel')
111
+ file = group.files.new(
112
+ 'path' => xcdatamodel_path.sub(/xcdatamodeld$/, 'xcdatamodel'),
113
+ 'lastKnownFileType' => 'wrapper.xcdatamodel'
114
+ )
115
+ group.current_version = file.uuid
116
+ group
117
+ end
118
+ end
119
+
100
120
  end
101
121
  end
102
122
  end
@@ -1,4 +1,4 @@
1
- require 'xcodeproj/inflector'
1
+ require 'active_support/inflector'
2
2
 
3
3
  module Xcodeproj
4
4
  class Project
@@ -167,16 +167,21 @@ module Xcodeproj
167
167
  # directory.
168
168
  # @return [PBXFileReference] The file reference object.
169
169
  def add_system_framework(name)
170
- group = groups.where('name' => 'Frameworks') || groups.new('name' => 'Frameworks')
171
- group.files.new({
172
- 'name' => "#{name}.framework",
173
- 'path' => "System/Library/Frameworks/#{name}.framework",
174
- 'sourceTree' => 'SDKROOT'
175
- })
170
+ path = "System/Library/Frameworks/#{name}.framework"
171
+ if file = files.where(:path => path)
172
+ file
173
+ else
174
+ group = groups.where('name' => 'Frameworks') || groups.new('name' => 'Frameworks')
175
+ group.files.new({
176
+ 'name' => "#{name}.framework",
177
+ 'path' => path,
178
+ 'sourceTree' => 'SDKROOT'
179
+ })
180
+ end
176
181
  end
177
182
 
178
- # @return [PBXObjectList<XCBuildConfiguration] A list of project wide
179
- # build configurations.
183
+ # @return [PBXObjectList<XCBuildConfiguration>] A list of project wide
184
+ # build configurations.
180
185
  def build_configurations
181
186
  root_object.build_configuration_list.build_configurations
182
187
  end
data/lib/xcodeproj.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Xcodeproj
2
- VERSION = '0.2.0'
3
-
2
+ VERSION = '0.3.0'
3
+
4
4
  autoload :Config, 'xcodeproj/config'
5
5
  autoload :Project, 'xcodeproj/project'
6
6
  autoload :Workspace, 'xcodeproj/workspace'
metadata CHANGED
@@ -1,27 +1,46 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: xcodeproj
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Eloy Duran
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2012-07-01 00:00:00.000000000 Z
13
- dependencies: []
14
- description: Xcodeproj lets you create and modify Xcode projects from Ruby. Script
15
- boring management tasks or build Xcode-friendly libraries. Also includes support
16
- for Xcode workspaces (.xcworkspace) and configuration files (.xcconfig).
16
+
17
+ date: 2012-07-14 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: activesupport
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 3
29
+ - 2
30
+ - 6
31
+ version: 3.2.6
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: Xcodeproj lets you create and modify Xcode projects from Ruby. Script boring management tasks or build Xcode-friendly libraries. Also includes support for Xcode workspaces (.xcworkspace) and configuration files (.xcconfig).
17
35
  email: eloy.de.enige@gmail.com
18
36
  executables: []
19
- extensions:
37
+
38
+ extensions:
20
39
  - ext/xcodeproj/extconf.rb
21
40
  extra_rdoc_files: []
22
- files:
41
+
42
+ files:
23
43
  - lib/xcodeproj/config.rb
24
- - lib/xcodeproj/inflector.rb
25
44
  - lib/xcodeproj/project/association/has_many.rb
26
45
  - lib/xcodeproj/project/association/has_one.rb
27
46
  - lib/xcodeproj/project/association/reflection.rb
@@ -40,31 +59,36 @@ files:
40
59
  - ext/xcodeproj/xcodeproj_ext.c
41
60
  - README.md
42
61
  - LICENSE
62
+ has_rdoc: true
43
63
  homepage: https://github.com/cocoapods/xcodeproj
44
- licenses:
64
+ licenses:
45
65
  - MIT
46
66
  post_install_message:
47
67
  rdoc_options: []
48
- require_paths:
68
+
69
+ require_paths:
49
70
  - ext
50
71
  - lib
51
- required_ruby_version: !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ! '>='
55
- - !ruby/object:Gem::Version
56
- version: '0'
57
- required_rubygems_version: !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ! '>='
61
- - !ruby/object:Gem::Version
62
- version: '0'
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ segments:
77
+ - 0
78
+ version: "0"
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
85
+ version: "0"
63
86
  requirements: []
87
+
64
88
  rubyforge_project:
65
- rubygems_version: 1.8.23
89
+ rubygems_version: 1.3.6
66
90
  signing_key:
67
91
  specification_version: 3
68
92
  summary: Create and modify Xcode projects from Ruby.
69
93
  test_files: []
70
- has_rdoc:
94
+
@@ -1,453 +0,0 @@
1
- # encoding: utf-8
2
-
3
- # This is part of ActiveSupport, which is available under the MIT license>
4
- #
5
- # Copyright (c) 2005-2010 David Heinemeier Hansson
6
- #
7
- # From files:
8
- # * https://raw.github.com/rails/rails/2-3-stable/activesupport/lib/active_support/inflector.rb
9
- # * https://raw.github.com/rails/rails/2-3-stable/activesupport/lib/active_support/inflections.rb
10
- # * https://raw.github.com/rails/rails/2-3-stable/activesupport/lib/active_support/core_ext/string/inflections.rb
11
-
12
- require 'singleton'
13
-
14
- module Xcodeproj
15
- module ActiveSupport
16
- # The Inflector transforms words from singular to plural, class names to table names, modularized class names to ones without,
17
- # and class names to foreign keys. The default inflections for pluralization, singularization, and uncountable words are kept
18
- # in inflections.rb.
19
- #
20
- # The Rails core team has stated patches for the inflections library will not be accepted
21
- # in order to avoid breaking legacy applications which may be relying on errant inflections.
22
- # If you discover an incorrect inflection and require it for your application, you'll need
23
- # to correct it yourself (explained below).
24
- module Inflector
25
- extend self
26
-
27
- # A singleton instance of this class is yielded by Inflector.inflections, which can then be used to specify additional
28
- # inflection rules. Examples:
29
- #
30
- # ActiveSupport::Inflector.inflections do |inflect|
31
- # inflect.plural /^(ox)$/i, '\1\2en'
32
- # inflect.singular /^(ox)en/i, '\1'
33
- #
34
- # inflect.irregular 'octopus', 'octopi'
35
- #
36
- # inflect.uncountable "equipment"
37
- # end
38
- #
39
- # New rules are added at the top. So in the example above, the irregular rule for octopus will now be the first of the
40
- # pluralization and singularization rules that is runs. This guarantees that your rules run before any of the rules that may
41
- # already have been loaded.
42
- class Inflections
43
- include Singleton
44
-
45
- attr_reader :plurals, :singulars, :uncountables, :humans
46
-
47
- def initialize
48
- @plurals, @singulars, @uncountables, @humans = [], [], [], []
49
- end
50
-
51
- # Specifies a new pluralization rule and its replacement. The rule can either be a string or a regular expression.
52
- # The replacement should always be a string that may include references to the matched data from the rule.
53
- def plural(rule, replacement)
54
- @uncountables.delete(rule) if rule.is_a?(String)
55
- @uncountables.delete(replacement)
56
- @plurals.insert(0, [rule, replacement])
57
- end
58
-
59
- # Specifies a new singularization rule and its replacement. The rule can either be a string or a regular expression.
60
- # The replacement should always be a string that may include references to the matched data from the rule.
61
- def singular(rule, replacement)
62
- @uncountables.delete(rule) if rule.is_a?(String)
63
- @uncountables.delete(replacement)
64
- @singulars.insert(0, [rule, replacement])
65
- end
66
-
67
- # Specifies a new irregular that applies to both pluralization and singularization at the same time. This can only be used
68
- # for strings, not regular expressions. You simply pass the irregular in singular and plural form.
69
- #
70
- # Examples:
71
- # irregular 'octopus', 'octopi'
72
- # irregular 'person', 'people'
73
- def irregular(singular, plural)
74
- @uncountables.delete(singular)
75
- @uncountables.delete(plural)
76
- if singular[0,1].upcase == plural[0,1].upcase
77
- plural(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"), '\1' + plural[1..-1])
78
- singular(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + singular[1..-1])
79
- else
80
- plural(Regexp.new("#{singular[0,1].upcase}(?i)#{singular[1..-1]}$"), plural[0,1].upcase + plural[1..-1])
81
- plural(Regexp.new("#{singular[0,1].downcase}(?i)#{singular[1..-1]}$"), plural[0,1].downcase + plural[1..-1])
82
- singular(Regexp.new("#{plural[0,1].upcase}(?i)#{plural[1..-1]}$"), singular[0,1].upcase + singular[1..-1])
83
- singular(Regexp.new("#{plural[0,1].downcase}(?i)#{plural[1..-1]}$"), singular[0,1].downcase + singular[1..-1])
84
- end
85
- end
86
-
87
- # Add uncountable words that shouldn't be attempted inflected.
88
- #
89
- # Examples:
90
- # uncountable "money"
91
- # uncountable "money", "information"
92
- # uncountable %w( money information rice )
93
- def uncountable(*words)
94
- (@uncountables << words).flatten!
95
- end
96
-
97
- # Specifies a humanized form of a string by a regular expression rule or by a string mapping.
98
- # When using a regular expression based replacement, the normal humanize formatting is called after the replacement.
99
- # When a string is used, the human form should be specified as desired (example: 'The name', not 'the_name')
100
- #
101
- # Examples:
102
- # human /_cnt$/i, '\1_count'
103
- # human "legacy_col_person_name", "Name"
104
- def human(rule, replacement)
105
- @humans.insert(0, [rule, replacement])
106
- end
107
-
108
- # Clears the loaded inflections within a given scope (default is <tt>:all</tt>).
109
- # Give the scope as a symbol of the inflection type, the options are: <tt>:plurals</tt>,
110
- # <tt>:singulars</tt>, <tt>:uncountables</tt>, <tt>:humans</tt>.
111
- #
112
- # Examples:
113
- # clear :all
114
- # clear :plurals
115
- def clear(scope = :all)
116
- case scope
117
- when :all
118
- @plurals, @singulars, @uncountables = [], [], []
119
- else
120
- instance_variable_set "@#{scope}", []
121
- end
122
- end
123
- end
124
-
125
- # Yields a singleton instance of Inflector::Inflections so you can specify additional
126
- # inflector rules.
127
- #
128
- # Example:
129
- # ActiveSupport::Inflector.inflections do |inflect|
130
- # inflect.uncountable "rails"
131
- # end
132
- def inflections
133
- if block_given?
134
- yield Inflections.instance
135
- else
136
- Inflections.instance
137
- end
138
- end
139
-
140
- # Returns the plural form of the word in the string.
141
- #
142
- # Examples:
143
- # "post".pluralize # => "posts"
144
- # "octopus".pluralize # => "octopi"
145
- # "sheep".pluralize # => "sheep"
146
- # "words".pluralize # => "words"
147
- # "CamelOctopus".pluralize # => "CamelOctopi"
148
- def pluralize(word)
149
- result = word.to_s.dup
150
-
151
- if word.empty? || inflections.uncountables.include?(result.downcase)
152
- result
153
- else
154
- inflections.plurals.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
155
- result
156
- end
157
- end
158
-
159
- # The reverse of +pluralize+, returns the singular form of a word in a string.
160
- #
161
- # Examples:
162
- # "posts".singularize # => "post"
163
- # "octopi".singularize # => "octopus"
164
- # "sheep".singluarize # => "sheep"
165
- # "word".singularize # => "word"
166
- # "CamelOctopi".singularize # => "CamelOctopus"
167
- def singularize(word)
168
- result = word.to_s.dup
169
-
170
- if inflections.uncountables.any? { |inflection| result =~ /#{inflection}\Z/i }
171
- result
172
- else
173
- inflections.singulars.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
174
- result
175
- end
176
- end
177
-
178
- # By default, +camelize+ converts strings to UpperCamelCase. If the argument to +camelize+
179
- # is set to <tt>:lower</tt> then +camelize+ produces lowerCamelCase.
180
- #
181
- # +camelize+ will also convert '/' to '::' which is useful for converting paths to namespaces.
182
- #
183
- # Examples:
184
- # "active_record".camelize # => "ActiveRecord"
185
- # "active_record".camelize(:lower) # => "activeRecord"
186
- # "active_record/errors".camelize # => "ActiveRecord::Errors"
187
- # "active_record/errors".camelize(:lower) # => "activeRecord::Errors"
188
- def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
189
- if first_letter_in_uppercase
190
- lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
191
- else
192
- lower_case_and_underscored_word[0,1].downcase + camelize(lower_case_and_underscored_word)[1..-1]
193
- end
194
- end
195
-
196
- # Capitalizes all the words and replaces some characters in the string to create
197
- # a nicer looking title. +titleize+ is meant for creating pretty output. It is not
198
- # used in the Rails internals.
199
- #
200
- # +titleize+ is also aliased as as +titlecase+.
201
- #
202
- # Examples:
203
- # "man from the boondocks".titleize # => "Man From The Boondocks"
204
- # "x-men: the last stand".titleize # => "X Men: The Last Stand"
205
- def titleize(word)
206
- humanize(underscore(word)).gsub(/\b('?[a-z])/) { $1.capitalize }
207
- end
208
-
209
- # The reverse of +camelize+. Makes an underscored, lowercase form from the expression in the string.
210
- #
211
- # Changes '::' to '/' to convert namespaces to paths.
212
- #
213
- # Examples:
214
- # "ActiveRecord".underscore # => "active_record"
215
- # "ActiveRecord::Errors".underscore # => active_record/errors
216
- def underscore(camel_cased_word)
217
- camel_cased_word.to_s.gsub(/::/, '/').
218
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
219
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
220
- tr("-", "_").
221
- downcase
222
- end
223
-
224
- # Replaces underscores with dashes in the string.
225
- #
226
- # Example:
227
- # "puni_puni" # => "puni-puni"
228
- def dasherize(underscored_word)
229
- underscored_word.gsub(/_/, '-')
230
- end
231
-
232
- # Capitalizes the first word and turns underscores into spaces and strips a
233
- # trailing "_id", if any. Like +titleize+, this is meant for creating pretty output.
234
- #
235
- # Examples:
236
- # "employee_salary" # => "Employee salary"
237
- # "author_id" # => "Author"
238
- def humanize(lower_case_and_underscored_word)
239
- result = lower_case_and_underscored_word.to_s.dup
240
-
241
- inflections.humans.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
242
- result.gsub(/_id$/, "").gsub(/_/, " ").capitalize
243
- end
244
-
245
- # Removes the module part from the expression in the string.
246
- #
247
- # Examples:
248
- # "ActiveRecord::CoreExtensions::String::Inflections".demodulize # => "Inflections"
249
- # "Inflections".demodulize # => "Inflections"
250
- def demodulize(class_name_in_module)
251
- class_name_in_module.to_s.gsub(/^.*::/, '')
252
- end
253
-
254
- # Create a class name from a plural table name like Rails does for table names to models.
255
- # Note that this returns a string and not a Class. (To convert to an actual class
256
- # follow +classify+ with +constantize+.)
257
- #
258
- # Examples:
259
- # "egg_and_hams".classify # => "EggAndHam"
260
- # "posts".classify # => "Post"
261
- #
262
- # Singular names are not handled correctly:
263
- # "business".classify # => "Busines"
264
- def classify(table_name)
265
- # strip out any leading schema name
266
- camelize(singularize(table_name.to_s.sub(/.*\./, '')))
267
- end
268
-
269
- # Turns a number into an ordinal string used to denote the position in an
270
- # ordered sequence such as 1st, 2nd, 3rd, 4th.
271
- #
272
- # Examples:
273
- # ordinalize(1) # => "1st"
274
- # ordinalize(2) # => "2nd"
275
- # ordinalize(1002) # => "1002nd"
276
- # ordinalize(1003) # => "1003rd"
277
- def ordinalize(number)
278
- if (11..13).include?(number.to_i % 100)
279
- "#{number}th"
280
- else
281
- case number.to_i % 10
282
- when 1; "#{number}st"
283
- when 2; "#{number}nd"
284
- when 3; "#{number}rd"
285
- else "#{number}th"
286
- end
287
- end
288
- end
289
- end
290
-
291
- Inflector.inflections do |inflect|
292
- inflect.plural(/$/, 's')
293
- inflect.plural(/s$/i, 's')
294
- inflect.plural(/(ax|test)is$/i, '\1es')
295
- inflect.plural(/(octop|vir)us$/i, '\1i')
296
- inflect.plural(/(alias|status)$/i, '\1es')
297
- inflect.plural(/(bu)s$/i, '\1ses')
298
- inflect.plural(/(buffal|tomat)o$/i, '\1oes')
299
- inflect.plural(/([ti])um$/i, '\1a')
300
- inflect.plural(/sis$/i, 'ses')
301
- inflect.plural(/(?:([^f])fe|([lr])f)$/i, '\1\2ves')
302
- inflect.plural(/(hive)$/i, '\1s')
303
- inflect.plural(/([^aeiouy]|qu)y$/i, '\1ies')
304
- inflect.plural(/(x|ch|ss|sh)$/i, '\1es')
305
- inflect.plural(/(matr|vert|ind)(?:ix|ex)$/i, '\1ices')
306
- inflect.plural(/([m|l])ouse$/i, '\1ice')
307
- inflect.plural(/^(ox)$/i, '\1en')
308
- inflect.plural(/(quiz)$/i, '\1zes')
309
-
310
- inflect.singular(/s$/i, '')
311
- inflect.singular(/(n)ews$/i, '\1ews')
312
- inflect.singular(/([ti])a$/i, '\1um')
313
- inflect.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i, '\1\2sis')
314
- inflect.singular(/(^analy)ses$/i, '\1sis')
315
- inflect.singular(/([^f])ves$/i, '\1fe')
316
- inflect.singular(/(hive)s$/i, '\1')
317
- inflect.singular(/(tive)s$/i, '\1')
318
- inflect.singular(/([lr])ves$/i, '\1f')
319
- inflect.singular(/([^aeiouy]|qu)ies$/i, '\1y')
320
- inflect.singular(/(s)eries$/i, '\1eries')
321
- inflect.singular(/(m)ovies$/i, '\1ovie')
322
- inflect.singular(/(x|ch|ss|sh)es$/i, '\1')
323
- inflect.singular(/([m|l])ice$/i, '\1ouse')
324
- inflect.singular(/(bus)es$/i, '\1')
325
- inflect.singular(/(o)es$/i, '\1')
326
- inflect.singular(/(shoe)s$/i, '\1')
327
- inflect.singular(/(cris|ax|test)es$/i, '\1is')
328
- inflect.singular(/(octop|vir)i$/i, '\1us')
329
- inflect.singular(/(alias|status)es$/i, '\1')
330
- inflect.singular(/^(ox)en/i, '\1')
331
- inflect.singular(/(vert|ind)ices$/i, '\1ex')
332
- inflect.singular(/(matr)ices$/i, '\1ix')
333
- inflect.singular(/(quiz)zes$/i, '\1')
334
- inflect.singular(/(database)s$/i, '\1')
335
-
336
- inflect.irregular('person', 'people')
337
- inflect.irregular('man', 'men')
338
- inflect.irregular('child', 'children')
339
- inflect.irregular('sex', 'sexes')
340
- inflect.irregular('move', 'moves')
341
- inflect.irregular('cow', 'kine')
342
-
343
- inflect.uncountable(%w(equipment information rice money species series fish sheep jeans))
344
- end
345
- end
346
- end
347
-
348
- # String inflections define new methods on the String class to transform names for different purposes.
349
- class String
350
- include Xcodeproj::ActiveSupport
351
-
352
- # Returns the plural form of the word in the string.
353
- #
354
- # "post".pluralize # => "posts"
355
- # "octopus".pluralize # => "octopi"
356
- # "sheep".pluralize # => "sheep"
357
- # "words".pluralize # => "words"
358
- # "the blue mailman".pluralize # => "the blue mailmen"
359
- # "CamelOctopus".pluralize # => "CamelOctopi"
360
- def pluralize
361
- Inflector.pluralize(self)
362
- end
363
-
364
- # The reverse of +pluralize+, returns the singular form of a word in a string.
365
- #
366
- # "posts".singularize # => "post"
367
- # "octopi".singularize # => "octopus"
368
- # "sheep".singularize # => "sheep"
369
- # "word".singularize # => "word"
370
- # "the blue mailmen".singularize # => "the blue mailman"
371
- # "CamelOctopi".singularize # => "CamelOctopus"
372
- def singularize
373
- Inflector.singularize(self)
374
- end
375
-
376
- # By default, +camelize+ converts strings to UpperCamelCase. If the argument to camelize
377
- # is set to <tt>:lower</tt> then camelize produces lowerCamelCase.
378
- #
379
- # +camelize+ will also convert '/' to '::' which is useful for converting paths to namespaces.
380
- #
381
- # "active_record".camelize # => "ActiveRecord"
382
- # "active_record".camelize(:lower) # => "activeRecord"
383
- # "active_record/errors".camelize # => "ActiveRecord::Errors"
384
- # "active_record/errors".camelize(:lower) # => "activeRecord::Errors"
385
- def camelize(first_letter = :upper)
386
- case first_letter
387
- when :upper then Inflector.camelize(self, true)
388
- when :lower then Inflector.camelize(self, false)
389
- end
390
- end
391
- alias_method :camelcase, :camelize
392
-
393
- # Capitalizes all the words and replaces some characters in the string to create
394
- # a nicer looking title. +titleize+ is meant for creating pretty output. It is not
395
- # used in the Rails internals.
396
- #
397
- # +titleize+ is also aliased as +titlecase+.
398
- #
399
- # "man from the boondocks".titleize # => "Man From The Boondocks"
400
- # "x-men: the last stand".titleize # => "X Men: The Last Stand"
401
- def titleize
402
- Inflector.titleize(self)
403
- end
404
- alias_method :titlecase, :titleize
405
-
406
- # The reverse of +camelize+. Makes an underscored, lowercase form from the expression in the string.
407
- #
408
- # +underscore+ will also change '::' to '/' to convert namespaces to paths.
409
- #
410
- # "ActiveRecord".underscore # => "active_record"
411
- # "ActiveRecord::Errors".underscore # => active_record/errors
412
- def underscore
413
- Inflector.underscore(self)
414
- end
415
-
416
- # Replaces underscores with dashes in the string.
417
- #
418
- # "puni_puni" # => "puni-puni"
419
- def dasherize
420
- Inflector.dasherize(self)
421
- end
422
-
423
- # Removes the module part from the constant expression in the string.
424
- #
425
- # "ActiveRecord::CoreExtensions::String::Inflections".demodulize # => "Inflections"
426
- # "Inflections".demodulize # => "Inflections"
427
- def demodulize
428
- Inflector.demodulize(self)
429
- end
430
-
431
- # Create a class name from a plural table name like Rails does for table names to models.
432
- # Note that this returns a string and not a class. (To convert to an actual class
433
- # follow +classify+ with +constantize+.)
434
- #
435
- # "egg_and_hams".classify # => "EggAndHam"
436
- # "posts".classify # => "Post"
437
- #
438
- # Singular names are not handled correctly.
439
- #
440
- # "business".classify # => "Busines"
441
- def classify
442
- Inflector.classify(self)
443
- end
444
-
445
- # Capitalizes the first word, turns underscores into spaces, and strips '_id'.
446
- # Like +titleize+, this is meant for creating pretty output.
447
- #
448
- # "employee_salary" # => "Employee salary"
449
- # "author_id" # => "Author"
450
- def humanize
451
- Inflector.humanize(self)
452
- end
453
- end