metric_fu 4.1.2 → 4.1.3

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.
Files changed (76) hide show
  1. data/.travis.yml +7 -4
  2. data/.yardopts +5 -0
  3. data/CONTRIBUTING.md +28 -13
  4. data/Gemfile +7 -3
  5. data/HISTORY.md +12 -0
  6. data/README.md +17 -0
  7. data/TODO.md +74 -79
  8. data/lib/metric_fu.rb +8 -0
  9. data/lib/metric_fu/configuration.rb +8 -3
  10. data/lib/metric_fu/core_ext.rb +2 -0
  11. data/lib/metric_fu/core_ext/inflector/inflections.rb +214 -0
  12. data/lib/metric_fu/core_ext/inflector/methods.rb +153 -0
  13. data/lib/metric_fu/core_ext/object.rb +3 -0
  14. data/lib/metric_fu/core_ext/object/blank.rb +106 -0
  15. data/lib/metric_fu/core_ext/object/to_json.rb +12 -0
  16. data/lib/metric_fu/core_ext/string.rb +2 -0
  17. data/lib/metric_fu/core_ext/string/inflections.rb +195 -0
  18. data/lib/metric_fu/initial_requires.rb +0 -8
  19. data/lib/metric_fu/metrics/base_template.rb +28 -1
  20. data/lib/metric_fu/metrics/churn/churn.rb +2 -2
  21. data/lib/metric_fu/metrics/churn/template_awesome/churn.html.erb +8 -6
  22. data/lib/metric_fu/metrics/hotspots/analysis/code_issue.rb +6 -0
  23. data/lib/metric_fu/metrics/hotspots/init.rb +1 -0
  24. data/lib/metric_fu/reporting/templates/awesome/awesome_template.rb +37 -20
  25. data/lib/metric_fu/reporting/templates/awesome/css/bluff.css +15 -0
  26. data/lib/metric_fu/reporting/templates/awesome/css/default.css +0 -48
  27. data/lib/metric_fu/reporting/templates/awesome/css/rcov.css +32 -0
  28. data/lib/metric_fu/reporting/templates/awesome/index.html.erb +4 -32
  29. data/lib/metric_fu/reporting/templates/awesome/layout.html.erb +2 -0
  30. data/lib/metric_fu/version.rb +1 -1
  31. data/metric_fu.gemspec +23 -11
  32. data/spec/cli/helper_spec.rb +38 -28
  33. data/spec/metric_fu/configuration_spec.rb +35 -22
  34. data/spec/metric_fu/metrics/base_template_spec.rb +7 -7
  35. data/spec/metric_fu/metrics/churn/churn_spec.rb +9 -2
  36. data/spec/metric_fu/metrics/flog/flog_spec.rb +57 -55
  37. data/spec/metric_fu/metrics/hotspots/hotspot_analyzer_spec.rb +0 -2
  38. data/spec/run_spec.rb +0 -8
  39. data/spec/support/suite.rb +3 -1
  40. metadata +74 -125
  41. data/home_page/back_all.jpg +0 -0
  42. data/home_page/cc.rb.gif +0 -0
  43. data/home_page/churn.gif +0 -0
  44. data/home_page/cruise_control_1.gif +0 -0
  45. data/home_page/cyclomatic.gif +0 -0
  46. data/home_page/flay.gif +0 -0
  47. data/home_page/flog.gif +0 -0
  48. data/home_page/flog2.gif +0 -0
  49. data/home_page/footer.gif +0 -0
  50. data/home_page/header.jpg +0 -0
  51. data/home_page/hotspot.gif +0 -0
  52. data/home_page/img09.gif +0 -0
  53. data/home_page/index.html +0 -138
  54. data/home_page/rcov.gif +0 -0
  55. data/home_page/reek.gif +0 -0
  56. data/home_page/robots.txt +0 -5
  57. data/home_page/roodi.gif +0 -0
  58. data/home_page/saikuro.gif +0 -0
  59. data/home_page/stats.gif +0 -0
  60. data/home_page/styles.css +0 -245
  61. data/home_page/title.gif +0 -0
  62. data/home_page/title_back.gif +0 -0
  63. data/lib/metric_fu/metrics/cane/template_standard/cane.html.erb +0 -95
  64. data/lib/metric_fu/metrics/churn/template_standard/churn.html.erb +0 -31
  65. data/lib/metric_fu/metrics/flay/template_standard/flay.html.erb +0 -34
  66. data/lib/metric_fu/metrics/flog/template_standard/flog.html.erb +0 -57
  67. data/lib/metric_fu/metrics/hotspots/template_standard/hotspots.html.erb +0 -54
  68. data/lib/metric_fu/metrics/rails_best_practices/template_standard/rails_best_practices.html.erb +0 -29
  69. data/lib/metric_fu/metrics/rcov/template_standard/rcov.html.erb +0 -43
  70. data/lib/metric_fu/metrics/reek/template_standard/reek.html.erb +0 -42
  71. data/lib/metric_fu/metrics/roodi/template_standard/roodi.html.erb +0 -29
  72. data/lib/metric_fu/metrics/saikuro/template_standard/saikuro.html.erb +0 -84
  73. data/lib/metric_fu/metrics/stats/template_standard/stats.html.erb +0 -55
  74. data/lib/metric_fu/reporting/templates/standard/default.css +0 -64
  75. data/lib/metric_fu/reporting/templates/standard/index.html.erb +0 -44
  76. data/lib/metric_fu/reporting/templates/standard/standard_template.rb +0 -26
@@ -0,0 +1,153 @@
1
+ # https://raw.github.com/rails/rails/20768176292cbcb883ab152b4aa9ed8c664771cd/activesupport/lib/active_support/inflector/methods.rb
2
+ # not https://github.com/rails/rails/blob/e8727d37fc49d5bf9976c3cb5c46badb92cf4ced/activesupport/lib/active_support/inflector/methods.rb
3
+ module ActiveSupport
4
+ # The Inflector transforms words from singular to plural, class names to table names, modularized class names to ones without,
5
+ # and class names to foreign keys. The default inflections for pluralization, singularization, and uncountable words are kept
6
+ # in inflections.rb.
7
+ #
8
+ # The Rails core team has stated patches for the inflections library will not be accepted
9
+ # in order to avoid breaking legacy applications which may be relying on errant inflections.
10
+ # If you discover an incorrect inflection and require it for your application, you'll need
11
+ # to correct it yourself (explained below).
12
+ module Inflector
13
+ extend self
14
+
15
+ # By default, +camelize+ converts strings to UpperCamelCase. If the argument to +camelize+
16
+ # is set to <tt>:lower</tt> then +camelize+ produces lowerCamelCase.
17
+ #
18
+ # +camelize+ will also convert '/' to '::' which is useful for converting paths to namespaces.
19
+ #
20
+ # Examples:
21
+ # "active_record".camelize # => "ActiveRecord"
22
+ # "active_record".camelize(:lower) # => "activeRecord"
23
+ # "active_record/errors".camelize # => "ActiveRecord::Errors"
24
+ # "active_record/errors".camelize(:lower) # => "activeRecord::Errors"
25
+ #
26
+ # As a rule of thumb you can think of +camelize+ as the inverse of +underscore+,
27
+ # though there are cases where that does not hold:
28
+ #
29
+ # "SSLError".underscore.camelize # => "SslError"
30
+ def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
31
+ if first_letter_in_uppercase
32
+ lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
33
+ else
34
+ lower_case_and_underscored_word.to_s[0].chr.downcase + camelize(lower_case_and_underscored_word)[1..-1]
35
+ end
36
+ end
37
+
38
+ # Makes an underscored, lowercase form from the expression in the string.
39
+ #
40
+ # Changes '::' to '/' to convert namespaces to paths.
41
+ #
42
+ # Examples:
43
+ # "ActiveRecord".underscore # => "active_record"
44
+ # "ActiveRecord::Errors".underscore # => active_record/errors
45
+ #
46
+ # As a rule of thumb you can think of +underscore+ as the inverse of +camelize+,
47
+ # though there are cases where that does not hold:
48
+ #
49
+ # "SSLError".underscore.camelize # => "SslError"
50
+ def underscore(camel_cased_word)
51
+ word = camel_cased_word.to_s.dup
52
+ word.gsub!(/::/, '/')
53
+ word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
54
+ word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
55
+ word.tr!("-", "_")
56
+ word.downcase!
57
+ word
58
+ end
59
+
60
+ # Replaces underscores with dashes in the string.
61
+ #
62
+ # Example:
63
+ # "puni_puni" # => "puni-puni"
64
+ def dasherize(underscored_word)
65
+ underscored_word.gsub(/_/, '-')
66
+ end
67
+
68
+ # Removes the module part from the expression in the string.
69
+ #
70
+ # Examples:
71
+ # "ActiveRecord::CoreExtensions::String::Inflections".demodulize # => "Inflections"
72
+ # "Inflections".demodulize # => "Inflections"
73
+ def demodulize(class_name_in_module)
74
+ class_name_in_module.to_s.gsub(/^.*::/, '')
75
+ end
76
+
77
+ # Creates a foreign key name from a class name.
78
+ # +separate_class_name_and_id_with_underscore+ sets whether
79
+ # the method should put '_' between the name and 'id'.
80
+ #
81
+ # Examples:
82
+ # "Message".foreign_key # => "message_id"
83
+ # "Message".foreign_key(false) # => "messageid"
84
+ # "Admin::Post".foreign_key # => "post_id"
85
+ def foreign_key(class_name, separate_class_name_and_id_with_underscore = true)
86
+ underscore(demodulize(class_name)) + (separate_class_name_and_id_with_underscore ? "_id" : "id")
87
+ end
88
+
89
+ # Ruby 1.9 introduces an inherit argument for Module#const_get and
90
+ # #const_defined? and changes their default behavior.
91
+ if Module.method(:const_get).arity == 1
92
+ # Tries to find a constant with the name specified in the argument string:
93
+ #
94
+ # "Module".constantize # => Module
95
+ # "Test::Unit".constantize # => Test::Unit
96
+ #
97
+ # The name is assumed to be the one of a top-level constant, no matter whether
98
+ # it starts with "::" or not. No lexical context is taken into account:
99
+ #
100
+ # C = 'outside'
101
+ # module M
102
+ # C = 'inside'
103
+ # C # => 'inside'
104
+ # "C".constantize # => 'outside', same as ::C
105
+ # end
106
+ #
107
+ # NameError is raised when the name is not in CamelCase or the constant is
108
+ # unknown.
109
+ def constantize(camel_cased_word)
110
+ names = camel_cased_word.split('::')
111
+ names.shift if names.empty? || names.first.empty?
112
+
113
+ constant = Object
114
+ names.each do |name|
115
+ constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
116
+ end
117
+ constant
118
+ end
119
+ else
120
+ def constantize(camel_cased_word) #:nodoc:
121
+ names = camel_cased_word.split('::')
122
+ names.shift if names.empty? || names.first.empty?
123
+
124
+ constant = Object
125
+ names.each do |name|
126
+ constant = constant.const_defined?(name, false) ? constant.const_get(name) : constant.const_missing(name)
127
+ end
128
+ constant
129
+ end
130
+ end
131
+
132
+ # Turns a number into an ordinal string used to denote the position in an
133
+ # ordered sequence such as 1st, 2nd, 3rd, 4th.
134
+ #
135
+ # Examples:
136
+ # ordinalize(1) # => "1st"
137
+ # ordinalize(2) # => "2nd"
138
+ # ordinalize(1002) # => "1002nd"
139
+ # ordinalize(1003) # => "1003rd"
140
+ def ordinalize(number)
141
+ if (11..13).include?(number.to_i % 100)
142
+ "#{number}th"
143
+ else
144
+ case number.to_i % 10
145
+ when 1; "#{number}st"
146
+ when 2; "#{number}nd"
147
+ when 3; "#{number}rd"
148
+ else "#{number}th"
149
+ end
150
+ end
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,3 @@
1
+ # https://github.com/rails/rails/blob/e8727d37fc49d5bf9976c3cb5c46badb92cf4ced/activesupport/lib/active_support/core_ext/object.rb
2
+ MetricFu.lib_require { 'core_ext/object/blank' }
3
+ MetricFu.lib_require { 'core_ext/object/to_json' }
@@ -0,0 +1,106 @@
1
+ # https://github.com/rails/rails/blob/e8727d37fc49d5bf9976c3cb5c46badb92cf4ced/activesupport/lib/active_support/core_ext/object/blank.rb
2
+ # encoding: utf-8
3
+
4
+ class Object
5
+ # An object is blank if it's false, empty, or a whitespace string.
6
+ # For example, '', ' ', +nil+, [], and {} are all blank.
7
+ #
8
+ # This simplifies:
9
+ #
10
+ # if address.nil? || address.empty?
11
+ #
12
+ # ...to:
13
+ #
14
+ # if address.blank?
15
+ def blank?
16
+ respond_to?(:empty?) ? empty? : !self
17
+ end
18
+
19
+ # An object is present if it's not <tt>blank?</tt>.
20
+ def present?
21
+ !blank?
22
+ end
23
+
24
+ # Returns object if it's <tt>present?</tt> otherwise returns +nil+.
25
+ # <tt>object.presence</tt> is equivalent to <tt>object.present? ? object : nil</tt>.
26
+ #
27
+ # This is handy for any representation of objects where blank is the same
28
+ # as not present at all. For example, this simplifies a common check for
29
+ # HTTP POST/query parameters:
30
+ #
31
+ # state = params[:state] if params[:state].present?
32
+ # country = params[:country] if params[:country].present?
33
+ # region = state || country || 'US'
34
+ #
35
+ # ...becomes:
36
+ #
37
+ # region = params[:state].presence || params[:country].presence || 'US'
38
+ def presence
39
+ self if present?
40
+ end
41
+ end
42
+
43
+ class NilClass
44
+ # +nil+ is blank:
45
+ #
46
+ # nil.blank? # => true
47
+ def blank?
48
+ true
49
+ end
50
+ end
51
+
52
+ class FalseClass
53
+ # +false+ is blank:
54
+ #
55
+ # false.blank? # => true
56
+ def blank?
57
+ true
58
+ end
59
+ end
60
+
61
+ class TrueClass
62
+ # +true+ is not blank:
63
+ #
64
+ # true.blank? # => false
65
+ def blank?
66
+ false
67
+ end
68
+ end
69
+
70
+ class Array
71
+ # An array is blank if it's empty:
72
+ #
73
+ # [].blank? # => true
74
+ # [1,2,3].blank? # => false
75
+ alias_method :blank?, :empty?
76
+ end
77
+
78
+ class Hash
79
+ # A hash is blank if it's empty:
80
+ #
81
+ # {}.blank? # => true
82
+ # { key: 'value' }.blank? # => false
83
+ alias_method :blank?, :empty?
84
+ end
85
+
86
+ class String
87
+ # A string is blank if it's empty or contains whitespaces only:
88
+ #
89
+ # ''.blank? # => true
90
+ # ' '.blank? # => true
91
+ # ' '.blank? # => true
92
+ # ' something here '.blank? # => false
93
+ def blank?
94
+ self !~ /[^[:space:]]/
95
+ end
96
+ end
97
+
98
+ class Numeric #:nodoc:
99
+ # No number is blank:
100
+ #
101
+ # 1.blank? # => false
102
+ # 0.blank? # => false
103
+ def blank?
104
+ false
105
+ end
106
+ end
@@ -0,0 +1,12 @@
1
+ # https://github.com/rails/rails/blob/e8727d37fc49d5bf9976c3cb5c46badb92cf4ced/activesupport/lib/active_support/core_ext/object/to_json.rb
2
+ # Hack to load json gem first so we can overwrite its to_json.
3
+ begin
4
+ require 'json'
5
+ rescue LoadError
6
+ end
7
+
8
+ # The JSON gem adds a few modules to Ruby core classes containing :to_json definition, overwriting
9
+ # their default behavior. That said, we need to define the basic to_json method in all of them,
10
+ # otherwise they will always use to_json gem implementation, which is backwards incompatible in
11
+ # several cases (for instance, the JSON implementation for Hash does not work) with inheritance
12
+ # and consequently classes as ActiveSupport::OrderedHash cannot be serialized to json.
@@ -0,0 +1,2 @@
1
+ # https://github.com/rails/rails/blob/e8727d37fc49d5bf9976c3cb5c46badb92cf4ced/activesupport/lib/active_support/core_ext/string.rb
2
+ MetricFu.lib_require { 'core_ext/string/inflections' }
@@ -0,0 +1,195 @@
1
+ # https://github.com/rails/rails/blob/e8727d37fc49d5bf9976c3cb5c46badb92cf4ced/activesupport/lib/active_support/core_ext/string/inflections.rb
2
+ MetricFu.lib_require { 'core_ext/inflector/inflections' }
3
+
4
+ # String inflections define new methods on the String class to transform names for different purposes.
5
+ # For instance, you can figure out the name of a table from the name of a class.
6
+ #
7
+ # 'ScaleScore'.tableize # => "scale_scores"
8
+ #
9
+ class String
10
+ # Returns the plural form of the word in the string.
11
+ #
12
+ # If the optional parameter +count+ is specified,
13
+ # the singular form will be returned if <tt>count == 1</tt>.
14
+ # For any other value of +count+ the plural will be returned.
15
+ #
16
+ # If the optional parameter +locale+ is specified,
17
+ # the word will be pluralized as a word of that language.
18
+ # By default, this parameter is set to <tt>:en</tt>.
19
+ # You must define your own inflection rules for languages other than English.
20
+ #
21
+ # 'post'.pluralize # => "posts"
22
+ # 'octopus'.pluralize # => "octopi"
23
+ # 'sheep'.pluralize # => "sheep"
24
+ # 'words'.pluralize # => "words"
25
+ # 'the blue mailman'.pluralize # => "the blue mailmen"
26
+ # 'CamelOctopus'.pluralize # => "CamelOctopi"
27
+ # 'apple'.pluralize(1) # => "apple"
28
+ # 'apple'.pluralize(2) # => "apples"
29
+ # 'ley'.pluralize(:es) # => "leyes"
30
+ # 'ley'.pluralize(1, :es) # => "ley"
31
+ def pluralize(count = nil, locale = :en)
32
+ locale = count if count.is_a?(Symbol)
33
+ if count == 1
34
+ self
35
+ else
36
+ ActiveSupport::Inflector.pluralize(self, locale)
37
+ end
38
+ end
39
+
40
+ # The reverse of +pluralize+, returns the singular form of a word in a string.
41
+ #
42
+ # If the optional parameter +locale+ is specified,
43
+ # the word will be singularized as a word of that language.
44
+ # By default, this parameter is set to <tt>:en</tt>.
45
+ # You must define your own inflection rules for languages other than English.
46
+ #
47
+ # 'posts'.singularize # => "post"
48
+ # 'octopi'.singularize # => "octopus"
49
+ # 'sheep'.singularize # => "sheep"
50
+ # 'word'.singularize # => "word"
51
+ # 'the blue mailmen'.singularize # => "the blue mailman"
52
+ # 'CamelOctopi'.singularize # => "CamelOctopus"
53
+ # 'leyes'.singularize(:es) # => "ley"
54
+ def singularize(locale = :en)
55
+ ActiveSupport::Inflector.singularize(self, locale)
56
+ end
57
+
58
+ # +constantize+ tries to find a declared constant with the name specified
59
+ # in the string. It raises a NameError when the name is not in CamelCase
60
+ # or is not initialized. See ActiveSupport::Inflector.constantize
61
+ #
62
+ # 'Module'.constantize # => Module
63
+ # 'Class'.constantize # => Class
64
+ # 'blargle'.constantize # => NameError: wrong constant name blargle
65
+ def constantize
66
+ ActiveSupport::Inflector.constantize(self)
67
+ end
68
+
69
+ # +safe_constantize+ tries to find a declared constant with the name specified
70
+ # in the string. It returns nil when the name is not in CamelCase
71
+ # or is not initialized. See ActiveSupport::Inflector.safe_constantize
72
+ #
73
+ # 'Module'.safe_constantize # => Module
74
+ # 'Class'.safe_constantize # => Class
75
+ # 'blargle'.safe_constantize # => nil
76
+ def safe_constantize
77
+ ActiveSupport::Inflector.safe_constantize(self)
78
+ end
79
+
80
+ # By default, +camelize+ converts strings to UpperCamelCase. If the argument to camelize
81
+ # is set to <tt>:lower</tt> then camelize produces lowerCamelCase.
82
+ #
83
+ # +camelize+ will also convert '/' to '::' which is useful for converting paths to namespaces.
84
+ #
85
+ # 'active_record'.camelize # => "ActiveRecord"
86
+ # 'active_record'.camelize(:lower) # => "activeRecord"
87
+ # 'active_record/errors'.camelize # => "ActiveRecord::Errors"
88
+ # 'active_record/errors'.camelize(:lower) # => "activeRecord::Errors"
89
+ def camelize(first_letter = :upper)
90
+ case first_letter
91
+ when :upper
92
+ ActiveSupport::Inflector.camelize(self, true)
93
+ when :lower
94
+ ActiveSupport::Inflector.camelize(self, false)
95
+ end
96
+ end
97
+ alias_method :camelcase, :camelize
98
+
99
+ # Capitalizes all the words and replaces some characters in the string to create
100
+ # a nicer looking title. +titleize+ is meant for creating pretty output. It is not
101
+ # used in the Rails internals.
102
+ #
103
+ # +titleize+ is also aliased as +titlecase+.
104
+ #
105
+ # 'man from the boondocks'.titleize # => "Man From The Boondocks"
106
+ # 'x-men: the last stand'.titleize # => "X Men: The Last Stand"
107
+ def titleize
108
+ ActiveSupport::Inflector.titleize(self)
109
+ end
110
+ alias_method :titlecase, :titleize
111
+
112
+ # The reverse of +camelize+. Makes an underscored, lowercase form from the expression in the string.
113
+ #
114
+ # +underscore+ will also change '::' to '/' to convert namespaces to paths.
115
+ #
116
+ # 'ActiveModel'.underscore # => "active_model"
117
+ # 'ActiveModel::Errors'.underscore # => "active_model/errors"
118
+ def underscore
119
+ ActiveSupport::Inflector.underscore(self)
120
+ end
121
+
122
+ # Replaces underscores with dashes in the string.
123
+ #
124
+ # 'puni_puni'.dasherize # => "puni-puni"
125
+ def dasherize
126
+ ActiveSupport::Inflector.dasherize(self)
127
+ end
128
+
129
+ # Removes the module part from the constant expression in the string.
130
+ #
131
+ # 'ActiveRecord::CoreExtensions::String::Inflections'.demodulize # => "Inflections"
132
+ # 'Inflections'.demodulize # => "Inflections"
133
+ #
134
+ # See also +deconstantize+.
135
+ def demodulize
136
+ ActiveSupport::Inflector.demodulize(self)
137
+ end
138
+
139
+ # Removes the rightmost segment from the constant expression in the string.
140
+ #
141
+ # 'Net::HTTP'.deconstantize # => "Net"
142
+ # '::Net::HTTP'.deconstantize # => "::Net"
143
+ # 'String'.deconstantize # => ""
144
+ # '::String'.deconstantize # => ""
145
+ # ''.deconstantize # => ""
146
+ #
147
+ # See also +demodulize+.
148
+ def deconstantize
149
+ ActiveSupport::Inflector.deconstantize(self)
150
+ end
151
+
152
+ # Creates the name of a table like Rails does for models to table names. This method
153
+ # uses the +pluralize+ method on the last word in the string.
154
+ #
155
+ # 'RawScaledScorer'.tableize # => "raw_scaled_scorers"
156
+ # 'egg_and_ham'.tableize # => "egg_and_hams"
157
+ # 'fancyCategory'.tableize # => "fancy_categories"
158
+ def tableize
159
+ ActiveSupport::Inflector.tableize(self)
160
+ end
161
+
162
+ # Create a class name from a plural table name like Rails does for table names to models.
163
+ # Note that this returns a string and not a class. (To convert to an actual class
164
+ # follow +classify+ with +constantize+.)
165
+ #
166
+ # 'egg_and_hams'.classify # => "EggAndHam"
167
+ # 'posts'.classify # => "Post"
168
+ #
169
+ # Singular names are not handled correctly.
170
+ #
171
+ # 'business'.classify # => "Busines"
172
+ def classify
173
+ ActiveSupport::Inflector.classify(self)
174
+ end
175
+
176
+ # Capitalizes the first word, turns underscores into spaces, and strips '_id'.
177
+ # Like +titleize+, this is meant for creating pretty output.
178
+ #
179
+ # 'employee_salary'.humanize # => "Employee salary"
180
+ # 'author_id'.humanize # => "Author"
181
+ def humanize
182
+ ActiveSupport::Inflector.humanize(self)
183
+ end
184
+
185
+ # Creates a foreign key name from a class name.
186
+ # +separate_class_name_and_id_with_underscore+ sets whether
187
+ # the method should put '_' between the name and 'id'.
188
+ #
189
+ # 'Message'.foreign_key # => "message_id"
190
+ # 'Message'.foreign_key(false) # => "messageid"
191
+ # 'Admin::Post'.foreign_key # => "post_id"
192
+ def foreign_key(separate_class_name_and_id_with_underscore = true)
193
+ ActiveSupport::Inflector.foreign_key(self, separate_class_name_and_id_with_underscore)
194
+ end
195
+ end