Class: Rtasklib::TaskWarrior

Inherits:
Object
  • Object
show all
Includes:
Controller
Defined in:
lib/rtasklib.rb

Constant Summary collapse

DEFAULTS =
{
json_array:              'true',
verbose:                 'nothing',
confirmation:            'no',
dependency_confirmation: 'no',
exit_on_missing_db:      'yes', }
LOWEST_VERSION =
Gem::Version.new('2.4.0')

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Controller

#add!, #all, #arbitrary_attr, #check_uda, #create_uda, #filter, #get_rc, #get_uda_names, #get_udas, #get_version, #undo!, #update_config!

Constructor Details

#initialize(data = "#{Dir.home}/.task", opts = {}) ⇒ TaskWarrior

Returns a new instance of TaskWarrior.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/rtasklib.rb', line 27

def initialize data="#{Dir.home}/.task", opts = {}

  @data_location = data
  override_h     = DEFAULTS.merge({data_location: data}).merge(opts)
  @override      = Taskrc.new(override_h, :hash)
  @override_a    = override.model_to_rc
  @taskrc        = get_rc

  # Check TaskWarrior version, and throw warning if unavailable
  begin
    @version = check_version(get_version())
  rescue
    warn "Couldn't verify TaskWarrior's version"
  end
end

Instance Attribute Details

#data_locationObject (readonly)

Returns the value of attribute data_location.



13
14
15
# File 'lib/rtasklib.rb', line 13

def data_location
  @data_location
end

#overrideObject (readonly)

Returns the value of attribute override.



13
14
15
# File 'lib/rtasklib.rb', line 13

def override
  @override
end

#override_aObject (readonly)

Returns the value of attribute override_a.



13
14
15
# File 'lib/rtasklib.rb', line 13

def override_a
  @override_a
end

#override_strObject (readonly)

Returns the value of attribute override_str.



13
14
15
# File 'lib/rtasklib.rb', line 13

def override_str
  @override_str
end

#taskrcObject (readonly)

Returns the value of attribute taskrc.



13
14
15
# File 'lib/rtasklib.rb', line 13

def taskrc
  @taskrc
end

#versionObject (readonly)

Returns the value of attribute version.



13
14
15
# File 'lib/rtasklib.rb', line 13

def version
  @version
end

Instance Method Details

#check_version(version) ⇒ Object



43
44
45
46
47
48
# File 'lib/rtasklib.rb', line 43

def check_version version
  if version < LOWEST_VERSION
    warn "The current TaskWarrior version, #{version}, is untested"
  end
  version
end