Method_Name 0.1.0 → 0.1.1

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.
@@ -1,15 +1,16 @@
1
1
  require 'Method_Name/version'
2
2
 
3
- def Method_Name? str
4
-
5
- return false if str[' ']
6
- return true unless str[Method_Name::INVALID_REGEXP]
3
+ def Method_Name? raw_name
4
+ name = raw_name.to_s
5
+ return false if name[' ']
6
+ return false if name.to_s.strip.empty?
7
+ return true unless name[Method_Name::INVALID_REGEXP]
7
8
 
8
9
  begin
9
10
  eval %!
10
11
  class Method_Name
11
12
  module Sandbox
12
- def #{str}
13
+ def #{name}
13
14
  end
14
15
  end
15
16
  end
@@ -22,10 +23,13 @@ def Method_Name? str
22
23
 
23
24
  end # === def Method_Name
24
25
 
25
- def Method_Name str
26
+ def Method_Name name
26
27
 
27
- File.basename(str.strip.downcase)
28
+ new_name = File.basename(name.strip.downcase)
28
29
  .gsub( %r!#{Method_Name::INVALID_REGEXP}+!, '_' )
30
+
31
+ return nil unless Method_Name?(new_name)
32
+ new_name
29
33
 
30
34
  end # === def Method_Name
31
35
 
@@ -1,3 +1,3 @@
1
1
  class Method_Name
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -1,6 +1,10 @@
1
1
 
2
2
  describe "Method_Name?" do
3
3
 
4
+ it "accepts a symbol as a valid argument" do
5
+ Method_Name?(:<<).should == true
6
+ end
7
+
4
8
  it "returns true if string only has: a-z A-Z 0-9 \_" do
5
9
  Method_Name?('a_z_0_9').should == true
6
10
  end
@@ -20,6 +24,10 @@ describe "Method_Name?" do
20
24
  it "returns false for: $? " do
21
25
  Method_Name?("$?").should == false
22
26
  end
27
+
28
+ it "returns false for: ''" do
29
+ Method_Name?('').should == false
30
+ end
23
31
 
24
32
  end # === Method_Name?
25
33
 
@@ -36,6 +44,10 @@ describe "Method_Name" do
36
44
  it "replaces consecutive invalid characters with underscore: a--b--c" do
37
45
  Method_Name('a--b--c').should == 'a_b_c'
38
46
  end
47
+
48
+ it "returns nil if a valid method name can not be extracted" do
49
+ Method_Name('').should == nil
50
+ end
39
51
 
40
52
  end # === Method_Name
41
53
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Method_Name
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: