Module: Concordion::SnakeCaseUtility

Included in:
StringUtility
Defined in:
lib/concordion/string_utility.rb

Instance Method Summary collapse

Instance Method Details

#snake_case(str) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/concordion/string_utility.rb', line 4

def snake_case(str)
  file_parts = str.split "::"
  
  s = file_parts.pop      
  s = s.gsub( /([A-Z])/, '_\1')
  
  if s.index("_") == 0
    s = s.slice(1, s.length)
  end
  
  file_parts << s
  file_parts.join('/').downcase
end

#snake_cased_goldmaster_name(str) ⇒ Object



25
26
27
# File 'lib/concordion/string_utility.rb', line 25

def snake_cased_goldmaster_name(str)
  snake_cased_test_name(str).gsub(".html", "_goldmaster.html")
end

#snake_cased_test_name(str) ⇒ Object



18
19
20
21
22
23
# File 'lib/concordion/string_utility.rb', line 18

def snake_cased_test_name(str)
  s = snake_case(str)
  s = s.gsub(/_test$/, '')

  "#{s}.html"
end