common_name 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  coverage
4
4
  rdoc
5
5
  pkg
6
+ Gemfile.lock
@@ -1,13 +1,8 @@
1
1
  require 'active_support'
2
2
  require 'active_support/version'
3
- %w{
4
- active_support/inflector
5
- }.each do |active_support_3_requirement|
6
- require active_support_3_requirement
7
- end if ::ActiveSupport::VERSION::MAJOR == 3
8
-
9
- if defined?(::Rails)
10
- require 'common_name/railtie'
3
+ if ::ActiveSupport::VERSION::MAJOR >= 3
4
+ require 'active_support/core_ext/string'
5
+ require 'active_support/inflector'
11
6
  end
12
7
 
13
8
  # This library comes out of my frustration with seeing lines like
@@ -32,7 +27,9 @@ module CommonName
32
27
 
33
28
  # delegate instance methods to class methods
34
29
  METHODS.each do |m|
35
- eval %{ def common_#{m}; self.class.common_#{m}; end }
30
+ define_method "common_#{m}" do
31
+ self.class.send("common_#{m}")
32
+ end
36
33
  end
37
34
 
38
35
  module ClassMethods
@@ -92,3 +89,20 @@ module CommonName
92
89
  def common_plural_camel; _COMMON_PLURAL_CAMEL ||= common_plural.camelcase; end
93
90
  end
94
91
  end
92
+
93
+ if defined?(::ActiveRecord)
94
+ ::ActiveRecord::Base.class_eval do
95
+ def self._common_name
96
+ name.underscore
97
+ end
98
+ include ::CommonName
99
+ end
100
+ end
101
+ if defined?(::ActionController)
102
+ ::ActionController::Base.class_eval do
103
+ def self._common_name
104
+ controller_name.singularize
105
+ end
106
+ include ::CommonName
107
+ end
108
+ end
@@ -1,3 +1,3 @@
1
1
  module CommonName
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'
3
3
  end
@@ -11,7 +11,7 @@ end
11
11
  # a class where you always want to chop off the _component part and singularize
12
12
  class Component
13
13
  def self._common_name
14
- name.underscore.gsub('_component', '').singularize
14
+ name.underscore.sub(/_component$/, '').singularize
15
15
  end
16
16
  include CommonName
17
17
  end
metadata CHANGED
@@ -1,78 +1,58 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: common_name
3
- version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 1
9
- - 6
10
- version: 0.1.6
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.7
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Seamus Abshere
14
9
  - Derek Kastner
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2011-03-02 00:00:00 -06:00
20
- default_executable:
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
13
+ date: 2012-03-12 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
23
16
  name: bundler
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2154157800 !ruby/object:Gem::Requirement
26
18
  none: false
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 3
31
- segments:
32
- - 0
33
- version: "0"
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
34
23
  type: :development
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: shoulda
38
24
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *2154157800
26
+ - !ruby/object:Gem::Dependency
27
+ name: shoulda
28
+ requirement: &2154157280 !ruby/object:Gem::Requirement
40
29
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
48
34
  type: :development
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: activesupport
52
35
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *2154157280
37
+ - !ruby/object:Gem::Dependency
38
+ name: activesupport
39
+ requirement: &2154156640 !ruby/object:Gem::Requirement
54
40
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 11
59
- segments:
60
- - 2
61
- - 3
62
- - 4
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
63
44
  version: 2.3.4
64
45
  type: :runtime
65
- version_requirements: *id003
66
- description: Provides methods like User.common_name (#=> "user") and User.common_plural_symbol (#=> :users) so that you don't have to chain humanize/downcase/etc. etc.'
67
- email:
46
+ prerelease: false
47
+ version_requirements: *2154156640
48
+ description: Provides methods like User.common_name (#=> "user") and User.common_plural_symbol
49
+ (#=> :users) so that you don't have to chain humanize/downcase/etc. etc.'
50
+ email:
68
51
  - seamus@abshere.net
69
52
  executables: []
70
-
71
53
  extensions: []
72
-
73
54
  extra_rdoc_files: []
74
-
75
- files:
55
+ files:
76
56
  - .document
77
57
  - .gitignore
78
58
  - Gemfile
@@ -81,44 +61,35 @@ files:
81
61
  - Rakefile
82
62
  - common_name.gemspec
83
63
  - lib/common_name.rb
84
- - lib/common_name/railtie.rb
85
64
  - lib/common_name/version.rb
86
65
  - test/common_name_test.rb
87
66
  - test/test_helper.rb
88
- has_rdoc: true
89
67
  homepage: http://github.com/seamusabshere/common_name
90
68
  licenses: []
91
-
92
69
  post_install_message:
93
70
  rdoc_options: []
94
-
95
- require_paths:
71
+ require_paths:
96
72
  - lib
97
- required_ruby_version: !ruby/object:Gem::Requirement
73
+ required_ruby_version: !ruby/object:Gem::Requirement
98
74
  none: false
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- hash: 3
103
- segments:
104
- - 0
105
- version: "0"
106
- required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
80
  none: false
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- hash: 3
112
- segments:
113
- - 0
114
- version: "0"
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
115
85
  requirements: []
116
-
117
86
  rubyforge_project: commonname
118
- rubygems_version: 1.3.7
87
+ rubygems_version: 1.8.15
119
88
  signing_key:
120
89
  specification_version: 3
121
- summary: Provides methods like User.common_name (#=> "user") and User.common_plural_symbol (#=> :users)
122
- test_files:
90
+ summary: Provides methods like User.common_name (#=> "user") and User.common_plural_symbol
91
+ (#=> :users)
92
+ test_files:
123
93
  - test/common_name_test.rb
124
94
  - test/test_helper.rb
95
+ has_rdoc:
@@ -1,21 +0,0 @@
1
- module CommonName
2
- class Railtie < ::Rails::Railtie
3
- initializer 'ActiveRecord' do
4
- ::ActiveRecord::Base.class_eval do
5
- def self._common_name
6
- name.underscore
7
- end
8
- include ::CommonName
9
- end
10
- end
11
-
12
- initializer 'ActionController' do
13
- ::ActionController::Base.class_eval do
14
- def self._common_name
15
- controller_name.singularize
16
- end
17
- include ::CommonName
18
- end
19
- end
20
- end
21
- end