Top Level Namespace

Defined Under Namespace

Modules: TextUtils Classes: Array, BlockReader, CodeReader, File, FixtureReader, HashReader, LineReader, NameParser, NameTokenizer, StringLineReader, Time, TreeReader, ValuesReader

Instance Method Summary collapse

Instance Method Details

#find_data_path_from_gemfile_gitref(name) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/textutils/utils.rb', line 20

def find_data_path_from_gemfile_gitref( name )
  puts "[textutils] find_data_path( name='#{name}' )..."
  puts "load path:"
  pp $LOAD_PATH

  # escape chars for regex e.g. . becomes \.
  name_esc = name.gsub( '.', '\.' )


  # note:
  #  - hexdigest must be 12 chars e.g. b7d1c9619a54 or similar
  
  # e.g. match /\/(beer\.db-[a-z0-9]+)|(beer\.db)\//

  name_regex = /\/((#{name_esc}-[a-z0-9]{12})|(#{name_esc}))\/lib$/
  candidates = []
  $LOAD_PATH.each do |path|
    if path =~ name_regex
      # cutoff trailing /lib
      candidates << path[0..-5]
    end
  end

  puts 'found candidates:'
  pp candidates

  ## use first candidate
  candidates[0]
end

#title_esc_regex(title_unescaped) ⇒ Object



14
15
16
17
# File 'lib/textutils/utils.rb', line 14

def title_esc_regex( title_unescaped )
  puts "*** warn: depreceated fn call: use TextUtils.title_esc_regex() or include TextUtils::TitleHelpers"
  TextUtils.title_esc_regex( title_unescaped )
end