Class: Ptimelog::Script

Inherits:
Object
  • Object
show all
Includes:
DeprecationWarning
Defined in:
lib/ptimelog/script.rb

Overview

Wrapper around all external scripts that might be called to get more information about the time-entries

Instance Method Summary collapse

Methods included from DeprecationWarning

#deprecate, included

Constructor Details

#initialize(config_dir) ⇒ Script

Returns a new instance of Script.



7
8
9
# File 'lib/ptimelog/script.rb', line 7

def initialize(config_dir)
  @config_dir = config_dir
end

Instance Method Details

#billableObject



16
17
18
# File 'lib/ptimelog/script.rb', line 16

def billable
  @config_dir.join('billable').expand_path
end

#deprecate_header(script_fn) ⇒ Object



38
39
40
# File 'lib/ptimelog/script.rb', line 38

def deprecate_header(script_fn)
  "DEPRECATION NOTICE: #{script_fn} is deprecated"
end

#deprecate_message(_) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/ptimelog/script.rb', line 29

def deprecate_message(_)
  <<~MESSAGE
    Please move the parser- and billable-scripts to an inferer-script.
    Support for the previous scripts in parsers/* and billable will
    be dropped in 0.7.

  MESSAGE
end

#inferer(name) ⇒ Object



20
21
22
23
24
25
# File 'lib/ptimelog/script.rb', line 20

def inferer(name)
  return NullPathname.new if name.to_s.empty?
  raise if name =~ %r{[\\/]} # prevent relavtive paths, stupidly, FIXME: really check FS

  @config_dir.join('inferers').join(name).expand_path
end

#parser(parser_name) ⇒ Object



11
12
13
14
# File 'lib/ptimelog/script.rb', line 11

def parser(parser_name)
  @config_dir.join("parsers/#{parser_name}") # FIXME: security-hole, prevent relative paths!
             .expand_path
end