Module: RoleBuilderUtils
- Defined in:
- lib/belphanior/servant/role_builder.rb
Class Method Summary collapse
- .arguments_and_path_to_sinatra_path(arguments, path) ⇒ Object
- .identifier_to_url_component(identifier) ⇒ Object
- .is_valid_identifier?(identifier) ⇒ Boolean
- .normalize_identifier(identifier) ⇒ Object
-
.usage_string_to_sinatra_path(usage) ⇒ Object
converts Belphanior-style “$(arg)” arguments to Sinatra-style “:arg” specifiers.
Class Method Details
.arguments_and_path_to_sinatra_path(arguments, path) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/belphanior/servant/role_builder.rb', line 24 def self.arguments_and_path_to_sinatra_path(arguments, path) arguments.each { |arg| path = path.sub("$("+arg+")", ":"+identifier_to_url_component(arg)) } path end |
.identifier_to_url_component(identifier) ⇒ Object
36 37 38 |
# File 'lib/belphanior/servant/role_builder.rb', line 36 def self.identifier_to_url_component(identifier) identifier.gsub(/ /,"_").downcase end |
.is_valid_identifier?(identifier) ⇒ Boolean
30 31 32 |
# File 'lib/belphanior/servant/role_builder.rb', line 30 def self.is_valid_identifier?(identifier) identifier =~ /^[a-zA-Z][a-zA-Z0-9 ]*$/ end |
.normalize_identifier(identifier) ⇒ Object
33 34 35 |
# File 'lib/belphanior/servant/role_builder.rb', line 33 def self.normalize_identifier(identifier) identifier.downcase end |
.usage_string_to_sinatra_path(usage) ⇒ Object
converts Belphanior-style “$(arg)” arguments to Sinatra-style “:arg” specifiers
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/belphanior/servant/role_builder.rb', line 10 def self.usage_string_to_sinatra_path(usage) output = "" usage.split("$").each { |substring| if substring[0,1]=="(" substring[0]=":" remainder_array = substring.split(")") output += (substring.split(")").join) else output += substring end } output end |