coulda 0.4.1 → 0.4.2

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/HISTORY CHANGED
@@ -38,3 +38,7 @@ Cleanup
38
38
  -----
39
39
  - Modified to use 'pending' instead of 'jeremymcanally-pending' from github (after I removed the 'bones' gem
40
40
  dependency from 'pending')
41
+
42
+ 0.4.2
43
+ -----
44
+ - Moved 'vendored' files under coulda and added them to the gemspec (woops)
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{coulda}
8
- s.version = "0.4.1"
8
+ s.version = "0.4.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Evan David Light"]
@@ -30,6 +30,8 @@ Gem::Specification.new do |s|
30
30
  "lib/coulda/feature.rb",
31
31
  "lib/coulda/scenario.rb",
32
32
  "lib/coulda/tasks.rb",
33
+ "lib/coulda/vendor/constantize.rb",
34
+ "lib/coulda/vendor/underscore.rb",
33
35
  "test/feature_test.rb",
34
36
  "test/integration/using_coulda_test.rb",
35
37
  "test/regression/issue_1_test.rb",
@@ -9,6 +9,8 @@ require 'pending'
9
9
 
10
10
  require 'coulda/feature'
11
11
  require 'coulda/scenario'
12
+ require 'coulda/vendor/constantize'
13
+ require 'coulda/vendor/underscore'
12
14
 
13
15
  module Kernel
14
16
  def Feature(name, opts = {}, &block)
@@ -19,5 +21,3 @@ module Kernel
19
21
  end
20
22
  end
21
23
 
22
- require 'vendor/constantize'
23
- require 'vendor/underscore'
@@ -0,0 +1,45 @@
1
+ # Slightly tweeked version of #constantize from ActiveSupport 2.3.3
2
+ class String
3
+ # Ruby 1.9 introduces an inherit argument for Module#const_get and
4
+ # #const_defined? and changes their default behavior.
5
+ if Module.method(:const_get).arity == 1
6
+ # Tries to find a constant with the name specified in the argument string:
7
+ #
8
+ # "Module".constantize # => Module
9
+ # "Test::Unit".constantize # => Test::Unit
10
+ #
11
+ # The name is assumed to be the one of a top-level constant, no matter whether
12
+ # it starts with "::" or not. No lexical context is taken into account:
13
+ #
14
+ # C = 'outside'
15
+ # module M
16
+ # C = 'inside'
17
+ # C # => 'inside'
18
+ # "C".constantize # => 'outside', same as ::C
19
+ # end
20
+ #
21
+ # NameError is raised when the name is not in CamelCase or the constant is
22
+ # unknown.
23
+ def constantize
24
+ names = self.split('::')
25
+ names.shift if names.empty? || names.first.empty?
26
+
27
+ constant = Object
28
+ names.each do |name|
29
+ constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
30
+ end
31
+ constant
32
+ end
33
+ else
34
+ def constantize #:nodoc:
35
+ names = self.split('::')
36
+ names.shift if names.empty? || names.first.empty?
37
+
38
+ constant = Object
39
+ names.each do |name|
40
+ constant = constant.const_get(name, false) || constant.const_missing(name)
41
+ end
42
+ constant
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,9 @@
1
+ class String
2
+ def super_custom_underscore
3
+ self.gsub(/::/, '/').
4
+ gsub(/[^A-Za-z0-9]/,'_').
5
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
6
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
7
+ downcase
8
+ end
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coulda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan David Light
@@ -45,6 +45,8 @@ files:
45
45
  - lib/coulda/feature.rb
46
46
  - lib/coulda/scenario.rb
47
47
  - lib/coulda/tasks.rb
48
+ - lib/coulda/vendor/constantize.rb
49
+ - lib/coulda/vendor/underscore.rb
48
50
  - test/feature_test.rb
49
51
  - test/integration/using_coulda_test.rb
50
52
  - test/regression/issue_1_test.rb