Class: Rtasklib::TaskWarrior
- Inherits:
-
Object
- Object
- Rtasklib::TaskWarrior
- Includes:
- Controller
- Defined in:
- lib/rtasklib.rb
Overview
To interact with the TaskWarrior database simply instantiate this with a path to the .task folder where data is stored. If left out it will look for a database in the default location ‘~/.task`
Optionally pass in a hash of taskrc options to override what is in your .taskrc on every command. By default rtasklib provides a set of sensible defaults:
These of course can be overridden with opts param as well
In general rtasklib is only feature complete on TaskWarrior installs 2.4 and greater and it will warn you if yours is lower or can’t be determined, but will still allow you to interact with it. Proceed at your own risk.
Constant Summary collapse
- DEFAULTS =
Sane defaults to override a base .taskrc
{ # Wrap export objects in an array? Disabling this will break Rtasklib # functionality json_array: 'true', # Stop writing user friendly methods. Disabling this will break Rtasklib # functionality verbose: 'nothing', # Call the gc on every execution. This will change id numbers whenever the # task list changes. By default this is off, but may have some # performance implications. gc: 'off', # Will ask for confirmation before we do anything TaskWarrior decides is # dangerous. We handle most of these cases in Rtasklib. confirmation: 'no', dependency_confirmation: 'no', # If it can't find a TaskWarrior db just exit. exit_on_missing_db: 'yes', }
- LOWEST_VERSION =
Lowest supported TaskWarrior version
Gem::Version.new('2.4.0')
Instance Attribute Summary collapse
-
#data_location ⇒ String
readonly
The file path that you passed in at initialization.
-
#override ⇒ Rtasklib::Taskrc
readonly
The options to override the default .taskrc.
-
#override_a ⇒ Array
readonly
Override in array form, useful for passing to shell.
-
#override_str ⇒ String
readonly
Override in string form, useful for passing to shell.
-
#taskrc ⇒ Rtasklib::Taskrc
readonly
Your current TaskWarrior configuration.
-
#udas ⇒ Hash{Symbol=>Hash}
readonly
Currently configured User Defined Attributes.
-
#version ⇒ Gem::Version
readonly
The version of the current TaskWarrior install.
Instance Method Summary collapse
-
#check_version(version = nil) ⇒ Gem::Version
Check the state of the TaskWarrior install.
-
#initialize(data = "#{Dir.home}/.task", opts = {}) ⇒ TaskWarrior
constructor
A new instance of TaskWarrior.
Methods included from Controller
#add!, #all, #count, #create_uda!, #delete!, #done!, #get_rc, #get_uda_names, #get_udas, #get_version, #modify!, #some, #start!, #stop!, #sync!, #uda_exists?, #undo!, #update_config!
Constructor Details
#initialize(data = "#{Dir.home}/.task", opts = {}) ⇒ TaskWarrior
Returns a new instance of TaskWarrior.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/rtasklib.rb', line 98 def initialize data="#{Dir.home}/.task", opts = {} # Check TaskWarrior version, and throw warning if unavailable begin @version = check_version rescue warn "Couldn't verify TaskWarrior's version" end @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 @udas = get_udas add_udas_to_model!(udas) unless udas.nil? end |
Instance Attribute Details
#data_location ⇒ String (readonly)
Returns The file path that you passed in at initialization.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/rtasklib.rb', line 67 class TaskWarrior attr_reader :version, :data_location, :taskrc, :udas, :override, :override_a, :override_str include Controller # Sane defaults to override a base .taskrc DEFAULTS = { # Wrap export objects in an array? Disabling this will break Rtasklib # functionality json_array: 'true', # Stop writing user friendly methods. Disabling this will break Rtasklib # functionality verbose: 'nothing', # Call the gc on every execution. This will change id numbers whenever the # task list changes. By default this is off, but may have some # performance implications. gc: 'off', # Will ask for confirmation before we do anything TaskWarrior decides is # dangerous. We handle most of these cases in Rtasklib. confirmation: 'no', dependency_confirmation: 'no', # If it can't find a TaskWarrior db just exit. exit_on_missing_db: 'yes', } # Lowest supported TaskWarrior version LOWEST_VERSION = Gem::Version.new('2.4.0') # @param data [String, Pathname] path to the .task database # @param opts [Hash] overrides to the .taskrc to run on each command # @api public def initialize data="#{Dir.home}/.task", opts = {} # Check TaskWarrior version, and throw warning if unavailable begin @version = check_version rescue warn "Couldn't verify TaskWarrior's version" end @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 @udas = get_udas add_udas_to_model!(udas) unless udas.nil? end # Check the state of the TaskWarrior install. Either pass a Gem::Version # representation passed to the version param or call with no args for # it to make a call to the shell to figure that out itself. # # @param version [Gem::Version, nil] version to check # @return [Gem::Version] # @api public def check_version version=nil version = get_version if version.nil? if version < LOWEST_VERSION warn "The current TaskWarrior version, #{version}, is untested" end version end end |
#override ⇒ Rtasklib::Taskrc (readonly)
Returns The options to override the default .taskrc.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/rtasklib.rb', line 67 class TaskWarrior attr_reader :version, :data_location, :taskrc, :udas, :override, :override_a, :override_str include Controller # Sane defaults to override a base .taskrc DEFAULTS = { # Wrap export objects in an array? Disabling this will break Rtasklib # functionality json_array: 'true', # Stop writing user friendly methods. Disabling this will break Rtasklib # functionality verbose: 'nothing', # Call the gc on every execution. This will change id numbers whenever the # task list changes. By default this is off, but may have some # performance implications. gc: 'off', # Will ask for confirmation before we do anything TaskWarrior decides is # dangerous. We handle most of these cases in Rtasklib. confirmation: 'no', dependency_confirmation: 'no', # If it can't find a TaskWarrior db just exit. exit_on_missing_db: 'yes', } # Lowest supported TaskWarrior version LOWEST_VERSION = Gem::Version.new('2.4.0') # @param data [String, Pathname] path to the .task database # @param opts [Hash] overrides to the .taskrc to run on each command # @api public def initialize data="#{Dir.home}/.task", opts = {} # Check TaskWarrior version, and throw warning if unavailable begin @version = check_version rescue warn "Couldn't verify TaskWarrior's version" end @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 @udas = get_udas add_udas_to_model!(udas) unless udas.nil? end # Check the state of the TaskWarrior install. Either pass a Gem::Version # representation passed to the version param or call with no args for # it to make a call to the shell to figure that out itself. # # @param version [Gem::Version, nil] version to check # @return [Gem::Version] # @api public def check_version version=nil version = get_version if version.nil? if version < LOWEST_VERSION warn "The current TaskWarrior version, #{version}, is untested" end version end end |
#override_a ⇒ Array (readonly)
Returns override in array form, useful for passing to shell.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/rtasklib.rb', line 67 class TaskWarrior attr_reader :version, :data_location, :taskrc, :udas, :override, :override_a, :override_str include Controller # Sane defaults to override a base .taskrc DEFAULTS = { # Wrap export objects in an array? Disabling this will break Rtasklib # functionality json_array: 'true', # Stop writing user friendly methods. Disabling this will break Rtasklib # functionality verbose: 'nothing', # Call the gc on every execution. This will change id numbers whenever the # task list changes. By default this is off, but may have some # performance implications. gc: 'off', # Will ask for confirmation before we do anything TaskWarrior decides is # dangerous. We handle most of these cases in Rtasklib. confirmation: 'no', dependency_confirmation: 'no', # If it can't find a TaskWarrior db just exit. exit_on_missing_db: 'yes', } # Lowest supported TaskWarrior version LOWEST_VERSION = Gem::Version.new('2.4.0') # @param data [String, Pathname] path to the .task database # @param opts [Hash] overrides to the .taskrc to run on each command # @api public def initialize data="#{Dir.home}/.task", opts = {} # Check TaskWarrior version, and throw warning if unavailable begin @version = check_version rescue warn "Couldn't verify TaskWarrior's version" end @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 @udas = get_udas add_udas_to_model!(udas) unless udas.nil? end # Check the state of the TaskWarrior install. Either pass a Gem::Version # representation passed to the version param or call with no args for # it to make a call to the shell to figure that out itself. # # @param version [Gem::Version, nil] version to check # @return [Gem::Version] # @api public def check_version version=nil version = get_version if version.nil? if version < LOWEST_VERSION warn "The current TaskWarrior version, #{version}, is untested" end version end end |
#override_str ⇒ String (readonly)
Returns override in string form, useful for passing to shell.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/rtasklib.rb', line 67 class TaskWarrior attr_reader :version, :data_location, :taskrc, :udas, :override, :override_a, :override_str include Controller # Sane defaults to override a base .taskrc DEFAULTS = { # Wrap export objects in an array? Disabling this will break Rtasklib # functionality json_array: 'true', # Stop writing user friendly methods. Disabling this will break Rtasklib # functionality verbose: 'nothing', # Call the gc on every execution. This will change id numbers whenever the # task list changes. By default this is off, but may have some # performance implications. gc: 'off', # Will ask for confirmation before we do anything TaskWarrior decides is # dangerous. We handle most of these cases in Rtasklib. confirmation: 'no', dependency_confirmation: 'no', # If it can't find a TaskWarrior db just exit. exit_on_missing_db: 'yes', } # Lowest supported TaskWarrior version LOWEST_VERSION = Gem::Version.new('2.4.0') # @param data [String, Pathname] path to the .task database # @param opts [Hash] overrides to the .taskrc to run on each command # @api public def initialize data="#{Dir.home}/.task", opts = {} # Check TaskWarrior version, and throw warning if unavailable begin @version = check_version rescue warn "Couldn't verify TaskWarrior's version" end @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 @udas = get_udas add_udas_to_model!(udas) unless udas.nil? end # Check the state of the TaskWarrior install. Either pass a Gem::Version # representation passed to the version param or call with no args for # it to make a call to the shell to figure that out itself. # # @param version [Gem::Version, nil] version to check # @return [Gem::Version] # @api public def check_version version=nil version = get_version if version.nil? if version < LOWEST_VERSION warn "The current TaskWarrior version, #{version}, is untested" end version end end |
#taskrc ⇒ Rtasklib::Taskrc (readonly)
Returns Your current TaskWarrior configuration.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/rtasklib.rb', line 67 class TaskWarrior attr_reader :version, :data_location, :taskrc, :udas, :override, :override_a, :override_str include Controller # Sane defaults to override a base .taskrc DEFAULTS = { # Wrap export objects in an array? Disabling this will break Rtasklib # functionality json_array: 'true', # Stop writing user friendly methods. Disabling this will break Rtasklib # functionality verbose: 'nothing', # Call the gc on every execution. This will change id numbers whenever the # task list changes. By default this is off, but may have some # performance implications. gc: 'off', # Will ask for confirmation before we do anything TaskWarrior decides is # dangerous. We handle most of these cases in Rtasklib. confirmation: 'no', dependency_confirmation: 'no', # If it can't find a TaskWarrior db just exit. exit_on_missing_db: 'yes', } # Lowest supported TaskWarrior version LOWEST_VERSION = Gem::Version.new('2.4.0') # @param data [String, Pathname] path to the .task database # @param opts [Hash] overrides to the .taskrc to run on each command # @api public def initialize data="#{Dir.home}/.task", opts = {} # Check TaskWarrior version, and throw warning if unavailable begin @version = check_version rescue warn "Couldn't verify TaskWarrior's version" end @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 @udas = get_udas add_udas_to_model!(udas) unless udas.nil? end # Check the state of the TaskWarrior install. Either pass a Gem::Version # representation passed to the version param or call with no args for # it to make a call to the shell to figure that out itself. # # @param version [Gem::Version, nil] version to check # @return [Gem::Version] # @api public def check_version version=nil version = get_version if version.nil? if version < LOWEST_VERSION warn "The current TaskWarrior version, #{version}, is untested" end version end end |
#udas ⇒ Hash{Symbol=>Hash} (readonly)
Returns Currently configured User Defined Attributes.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/rtasklib.rb', line 67 class TaskWarrior attr_reader :version, :data_location, :taskrc, :udas, :override, :override_a, :override_str include Controller # Sane defaults to override a base .taskrc DEFAULTS = { # Wrap export objects in an array? Disabling this will break Rtasklib # functionality json_array: 'true', # Stop writing user friendly methods. Disabling this will break Rtasklib # functionality verbose: 'nothing', # Call the gc on every execution. This will change id numbers whenever the # task list changes. By default this is off, but may have some # performance implications. gc: 'off', # Will ask for confirmation before we do anything TaskWarrior decides is # dangerous. We handle most of these cases in Rtasklib. confirmation: 'no', dependency_confirmation: 'no', # If it can't find a TaskWarrior db just exit. exit_on_missing_db: 'yes', } # Lowest supported TaskWarrior version LOWEST_VERSION = Gem::Version.new('2.4.0') # @param data [String, Pathname] path to the .task database # @param opts [Hash] overrides to the .taskrc to run on each command # @api public def initialize data="#{Dir.home}/.task", opts = {} # Check TaskWarrior version, and throw warning if unavailable begin @version = check_version rescue warn "Couldn't verify TaskWarrior's version" end @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 @udas = get_udas add_udas_to_model!(udas) unless udas.nil? end # Check the state of the TaskWarrior install. Either pass a Gem::Version # representation passed to the version param or call with no args for # it to make a call to the shell to figure that out itself. # # @param version [Gem::Version, nil] version to check # @return [Gem::Version] # @api public def check_version version=nil version = get_version if version.nil? if version < LOWEST_VERSION warn "The current TaskWarrior version, #{version}, is untested" end version end end |
#version ⇒ Gem::Version (readonly)
Returns The version of the current TaskWarrior install.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/rtasklib.rb', line 67 class TaskWarrior attr_reader :version, :data_location, :taskrc, :udas, :override, :override_a, :override_str include Controller # Sane defaults to override a base .taskrc DEFAULTS = { # Wrap export objects in an array? Disabling this will break Rtasklib # functionality json_array: 'true', # Stop writing user friendly methods. Disabling this will break Rtasklib # functionality verbose: 'nothing', # Call the gc on every execution. This will change id numbers whenever the # task list changes. By default this is off, but may have some # performance implications. gc: 'off', # Will ask for confirmation before we do anything TaskWarrior decides is # dangerous. We handle most of these cases in Rtasklib. confirmation: 'no', dependency_confirmation: 'no', # If it can't find a TaskWarrior db just exit. exit_on_missing_db: 'yes', } # Lowest supported TaskWarrior version LOWEST_VERSION = Gem::Version.new('2.4.0') # @param data [String, Pathname] path to the .task database # @param opts [Hash] overrides to the .taskrc to run on each command # @api public def initialize data="#{Dir.home}/.task", opts = {} # Check TaskWarrior version, and throw warning if unavailable begin @version = check_version rescue warn "Couldn't verify TaskWarrior's version" end @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 @udas = get_udas add_udas_to_model!(udas) unless udas.nil? end # Check the state of the TaskWarrior install. Either pass a Gem::Version # representation passed to the version param or call with no args for # it to make a call to the shell to figure that out itself. # # @param version [Gem::Version, nil] version to check # @return [Gem::Version] # @api public def check_version version=nil version = get_version if version.nil? if version < LOWEST_VERSION warn "The current TaskWarrior version, #{version}, is untested" end version end end |
Instance Method Details
#check_version(version = nil) ⇒ Gem::Version
Check the state of the TaskWarrior install. Either pass a Gem::Version representation passed to the version param or call with no args for it to make a call to the shell to figure that out itself.
122 123 124 125 126 127 128 |
# File 'lib/rtasklib.rb', line 122 def check_version version=nil version = get_version if version.nil? if version < LOWEST_VERSION warn "The current TaskWarrior version, #{version}, is untested" end version end |