accessor-utilities 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,21 @@ module AccessorUtilities::StringInstance
6
6
  #######################
7
7
 
8
8
  def is_variable_name?
9
- return self[ 0 ] == '@'
9
+
10
+ is_variable_name = false
11
+
12
+ last_index = length - 1
13
+
14
+ if self[ 0 ] == '@' and
15
+ self[ last_index ] != '?' and
16
+ self[ last_index ] != '='
17
+
18
+ is_variable_name = true
19
+
20
+ end
21
+
22
+ return is_variable_name
23
+
10
24
  end
11
25
 
12
26
  ###################
@@ -14,9 +28,17 @@ module AccessorUtilities::StringInstance
14
28
  ###################
15
29
 
16
30
  def variable_name
17
- slice_to_index = length - 1
18
- variable_name_string = ( self[ slice_to_index ] == '?' ? slice( 0, slice_to_index ) : self )
19
- return ( variable_name_string.is_variable_name? ? variable_name_string.to_sym : ( '@' + variable_name_string ).to_sym )
31
+
32
+ variable_name_string = self
33
+
34
+ unless variable_name_string.is_variable_name?
35
+
36
+ variable_name_string = '@' + accessor_name.to_s
37
+
38
+ end
39
+
40
+ return variable_name_string.to_sym
41
+
20
42
  end
21
43
 
22
44
  ###################
@@ -24,7 +46,31 @@ module AccessorUtilities::StringInstance
24
46
  ###################
25
47
 
26
48
  def accessor_name
27
- return ( is_variable_name? ? self.slice( 1, length ).to_sym : to_sym )
49
+
50
+ accessor_name_string = self
51
+
52
+ last_index = length - 1
53
+ last_character = self[ last_index ]
54
+
55
+ if last_character == '?' or
56
+ last_character == '='
57
+
58
+ accessor_name_string = slice( 0, last_index )
59
+
60
+ else
61
+
62
+ accessor_name_string = self
63
+
64
+ end
65
+
66
+ if accessor_name_string.is_variable_name?
67
+
68
+ accessor_name_string = slice( 1, length )
69
+
70
+ end
71
+
72
+ return accessor_name_string.to_sym
73
+
28
74
  end
29
75
 
30
76
  #########################
@@ -32,11 +78,51 @@ module AccessorUtilities::StringInstance
32
78
  #########################
33
79
 
34
80
  def write_accessor_name
35
- slice_to_index = length - 1
36
- variable_name_string = ( self[ slice_to_index ] == '?' ? slice( 0, slice_to_index ) : self )
37
- return ( variable_name_string[ length - 1 ] == '=' ? variable_name_string.to_sym : ( variable_name_string + '=' ).to_sym )
81
+
82
+ write_accessor_name_string = nil
83
+
84
+ last_index = length - 1
85
+
86
+ if self[ last_index ] == '=' and
87
+ self[ 0 ] != '@'
88
+
89
+ write_accessor_name_string = self
90
+
91
+ else
92
+
93
+ write_accessor_name_string = accessor_name.to_s + '='
94
+
95
+ end
96
+
97
+ return write_accessor_name_string.to_sym
98
+
38
99
  end
39
100
 
101
+ ##########################
102
+ # is_set_accessor_name #
103
+ ##########################
104
+
105
+ def is_set_accessor_name
106
+
107
+ is_set_accessor_name_string = nil
108
+
109
+ last_index = length - 1
110
+
111
+ if self[ last_index ] == '?' and
112
+ self[ 0 ] != '@'
113
+
114
+ is_set_accessor_name_string = self
115
+
116
+ else
117
+
118
+ is_set_accessor_name_string = accessor_name.to_s + '?'
119
+
120
+ end
121
+
122
+ return is_set_accessor_name_string.to_sym
123
+
124
+ end
125
+
40
126
  ##################
41
127
  # swizzle_name #
42
128
  ##################
@@ -6,7 +6,9 @@ module AccessorUtilities::SymbolInstance
6
6
  #######################
7
7
 
8
8
  def is_variable_name?
9
+
9
10
  return to_s.is_variable_name?
11
+
10
12
  end
11
13
 
12
14
  ###################
@@ -14,7 +16,9 @@ module AccessorUtilities::SymbolInstance
14
16
  ###################
15
17
 
16
18
  def variable_name
19
+
17
20
  return to_s.variable_name
21
+
18
22
  end
19
23
 
20
24
  ###################
@@ -22,7 +26,9 @@ module AccessorUtilities::SymbolInstance
22
26
  ###################
23
27
 
24
28
  def accessor_name
29
+
25
30
  return to_s.accessor_name
31
+
26
32
  end
27
33
 
28
34
  #########################
@@ -30,7 +36,19 @@ module AccessorUtilities::SymbolInstance
30
36
  #########################
31
37
 
32
38
  def write_accessor_name
39
+
33
40
  return to_s.write_accessor_name
41
+
42
+ end
43
+
44
+ ##########################
45
+ # is_set_accessor_name #
46
+ ##########################
47
+
48
+ def is_set_accessor_name
49
+
50
+ return to_s.is_set_accessor_name
51
+
34
52
  end
35
53
 
36
54
  ##################
@@ -38,7 +56,9 @@ module AccessorUtilities::SymbolInstance
38
56
  ##################
39
57
 
40
58
  def swizzle_name( swizzled_method_prefix = 'swizzled__', append_equals_to_method_name = false )
59
+
41
60
  return to_s.swizzle_name( swizzled_method_prefix, append_equals_to_method_name )
61
+
42
62
  end
43
63
 
44
64
  end
@@ -10,6 +10,8 @@ describe AccessorUtilities::StringInstance do
10
10
  it 'can report if a string is a variable name' do
11
11
  '@variable'.is_variable_name?.should == true
12
12
  'not_variable'.is_variable_name?.should == false
13
+ 'not_variable='.is_variable_name?.should == false
14
+ 'not_variable?'.is_variable_name?.should == false
13
15
  end
14
16
 
15
17
  ###################
@@ -19,6 +21,7 @@ describe AccessorUtilities::StringInstance do
19
21
  it 'can return variable name for variable or accessor name' do
20
22
  '@variable'.variable_name.should == :@variable
21
23
  'not_variable'.variable_name.should == :@not_variable
24
+ 'not_variable='.variable_name.should == :@not_variable
22
25
  'not_variable?'.variable_name.should == :@not_variable
23
26
  end
24
27
 
@@ -29,7 +32,8 @@ describe AccessorUtilities::StringInstance do
29
32
  it 'can return accessor name for variable or accessor name' do
30
33
  '@variable'.accessor_name.should == :variable
31
34
  'not_variable'.accessor_name.should == :not_variable
32
- 'not_variable?'.accessor_name.should == :not_variable?
35
+ 'not_variable='.accessor_name.should == :not_variable
36
+ 'not_variable?'.accessor_name.should == :not_variable
33
37
  end
34
38
 
35
39
  #########################
@@ -38,9 +42,20 @@ describe AccessorUtilities::StringInstance do
38
42
 
39
43
  it 'can return write accessor name for accessor name' do
40
44
  'accessor_name'.write_accessor_name.should == :accessor_name=
45
+ 'accessor_name='.write_accessor_name.should == :accessor_name=
41
46
  'accessor_name?'.write_accessor_name.should == :accessor_name=
42
47
  end
43
48
 
49
+ ##########################
50
+ # is_set_accessor_name #
51
+ ##########################
52
+
53
+ it 'can return is_set? accessor name for accessor name' do
54
+ 'accessor_name'.is_set_accessor_name.should == :accessor_name?
55
+ 'accessor_name?'.is_set_accessor_name.should == :accessor_name?
56
+ 'accessor_name='.is_set_accessor_name.should == :accessor_name?
57
+ end
58
+
44
59
  ##################
45
60
  # swizzle_name #
46
61
  ##################
@@ -10,6 +10,8 @@ describe AccessorUtilities::SymbolInstance do
10
10
  it 'can report if a string is a variable name' do
11
11
  :@variable.is_variable_name?.should == true
12
12
  :not_variable.is_variable_name?.should == false
13
+ :not_variable=.is_variable_name?.should == false
14
+ :not_variable?.is_variable_name?.should == false
13
15
  end
14
16
 
15
17
  ###################
@@ -19,6 +21,8 @@ describe AccessorUtilities::SymbolInstance do
19
21
  it 'can return variable name for variable or accessor name' do
20
22
  :@variable.variable_name.should == :@variable
21
23
  :not_variable.variable_name.should == :@not_variable
24
+ :not_variable=.variable_name.should == :@not_variable
25
+ :not_variable?.variable_name.should == :@not_variable
22
26
  end
23
27
 
24
28
  ###################
@@ -28,6 +32,8 @@ describe AccessorUtilities::SymbolInstance do
28
32
  it 'can return accessor name for variable or accessor name' do
29
33
  :@variable.accessor_name.should == :variable
30
34
  :not_variable.accessor_name.should == :not_variable
35
+ :not_variable=.accessor_name.should == :not_variable
36
+ :not_variable?.accessor_name.should == :not_variable
31
37
  end
32
38
 
33
39
  #########################
@@ -36,6 +42,18 @@ describe AccessorUtilities::SymbolInstance do
36
42
 
37
43
  it 'can return write accessor name for accessor name' do
38
44
  :accessor_name.write_accessor_name.should == :accessor_name=
45
+ :accessor_name=.write_accessor_name.should == :accessor_name=
46
+ :accessor_name?.write_accessor_name.should == :accessor_name=
47
+ end
48
+
49
+ ##########################
50
+ # is_set_accessor_name #
51
+ ##########################
52
+
53
+ it 'can return is_set? accessor name for accessor name' do
54
+ :accessor_name.is_set_accessor_name.should == :accessor_name?
55
+ :accessor_name?.is_set_accessor_name.should == :accessor_name?
56
+ :accessor_name=.is_set_accessor_name.should == :accessor_name?
39
57
  end
40
58
 
41
59
  ##################
metadata CHANGED
@@ -1,27 +1,24 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: accessor-utilities
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
4
5
  prerelease:
5
- version: 1.0.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Asher
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-09-05 00:00:00 Z
12
+ date: 2012-03-05 00:00:00.000000000 Z
14
13
  dependencies: []
15
-
16
- description: Extends String and Symbol instances with variable/accessor methods, provides swizzling helpers, provides accessor-related math for transforming :accessor, :reader, :writer.
14
+ description: Extends String and Symbol instances with variable/accessor methods, provides
15
+ swizzling helpers, provides accessor-related math for transforming :accessor, :reader,
16
+ :writer.
17
17
  email: asher@ridiculouspower.com
18
18
  executables: []
19
-
20
19
  extensions: []
21
-
22
20
  extra_rdoc_files: []
23
-
24
- files:
21
+ files:
25
22
  - lib/accessor-utilities/AccessorUtilities/AccessorMath.rb
26
23
  - lib/accessor-utilities/AccessorUtilities/ObjectInstance.rb
27
24
  - lib/accessor-utilities/AccessorUtilities/StringInstance.rb
@@ -39,30 +36,26 @@ files:
39
36
  - README.rdoc
40
37
  homepage: http://rubygems.org/gems/accessor-utilities
41
38
  licenses: []
42
-
43
39
  post_install_message:
44
40
  rdoc_options: []
45
-
46
- require_paths:
41
+ require_paths:
47
42
  - lib
48
- required_ruby_version: !ruby/object:Gem::Requirement
43
+ required_ruby_version: !ruby/object:Gem::Requirement
49
44
  none: false
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: "0"
54
- required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
50
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
60
55
  requirements: []
61
-
62
56
  rubyforge_project: accessor-utilities
63
57
  rubygems_version: 1.8.10
64
58
  signing_key:
65
59
  specification_version: 3
66
60
  summary: Utility methods for accessor-related meta-programming.
67
61
  test_files: []
68
-