Module: Things2THL::Constants

Defined in:
lib/Things2THL.rb

Constant Summary collapse

STRUCTURES =

Ways in which the items can be structured on the THL side. Elements are: <Things item> => [<THL item>, mapping, postblock], where mapping is a map containing <Things prop> => <THL prop>. <Things prop> is a symbol representing the name of a Node property. <THL prop> can be any of the following

:symbol   => value of <Things prop> is assigned to this prop
[:symbol, {hash}] => value of <Things prop> is looked up in {hash}
                     and the corresponding value is assigned to :symbol
{value1 => :symbol1, value2 => :symbol2} => if value of <Things prop>
            is value1, then :symbol1 prop in THL is set to true, etc.

postblock, if given, should be a code block that will receive

the original node, the produced new properties hash and the
Things2THL object as parameters, and do any necessary
postprocessing on the new properties
If postblock inserts in the properties hash an item with the key
:__newnodes__, it should be an array with items of the form
   { :new => :what,
     :with_properties => { properties }
   }
Those items will be added to the new THL node immediately
after its creation.
{
  :projects_as_lists => { 
    :area => [:folder,
              {
                :name => :name,
              }],
    :project => [:list,
                 {
                   :name => :name,
                   :creation_date => :created_date,
                 },
                 Proc.new {|node,prop,obj|
                   obj.add_list_notes(node,prop)
                   obj.add_project_duedate(node,prop)
                 }
                ],
    :selected_to_do => [:task,
                        {
                          :name => :title,
                          :creation_date => :created_date,
                          :due_date => :due_date,
                          :completion_date => :completed_date,
                          :cancellation_date => :canceled_date,
                          :activation_date => :start_date,
                          :status => {
                            :completed => :completed,
                            :canceled  => :canceled,
                          },
                        },
                        Proc.new {|node,prop,obj|
                          obj.add_notes(node,prop)
                          obj.fix_completed_canceled(node, prop)
                          obj.archive_completed(prop)
                          obj.process_tags(node, prop, true, true)
                          obj.check_today(node, prop)
                        }
                       ]
  },
  :projects_as_tasks => {
    :area => [:list,
              {
                :name => :name,
              }],
    :project => [:task,
                 {
                   :name => :title,
                   :creation_date => :created_date,
                   :due_date => :due_date,
                   :completion_date => :completed_date,
                   :cancellation_date => :canceled_date,
                   :activation_date => :start_date,
                   :status => {
                     :completed => :completed,
                     :canceled  => :canceled,
                   },
                 },
                 Proc.new {|node,prop,obj|
                   obj.add_notes(node,prop)
                   obj.fix_completed_canceled(node, prop)
                   obj.archive_completed(prop)
                   obj.process_tags(node, prop, false, true)
                 }
                ],
    :selected_to_do => [:task,
                        {
                          :name => :title,
                          :creation_date => :created_date,
                          :due_date => :due_date,
                          :completion_date => :completed_date,
                          :cancellation_date => :canceled_date,
                          :activation_date => :start_date,
                          :status => {
                            :completed => :completed,
                            :canceled  => :canceled,
                          },
                        },
                        Proc.new {|node,prop,obj|
                          obj.add_notes(node,prop)
                          obj.fix_completed_canceled(node, prop)
                          obj.archive_completed(prop)
                          obj.process_tags(node, prop, false, true)
                          obj.check_today(node, prop)
                        }
                       ]
  },
  :projects_areas_as_lists => {
    :area => [:list,
              {
                :name => :name,
              }],
    :project => [:list,
                 {
                   :name => :name,
                   :creation_date => :created_date,
                 },
                 Proc.new {|node,prop,obj|
                   obj.add_list_notes(node,prop)
                   obj.add_project_duedate(node,prop)
                 }
                ],
    :selected_to_do => [:task,
                        {
                          :name => :title,
                          :creation_date => :created_date,
                          :due_date => :due_date,
                          :completion_date => :completed_date,
                          :cancellation_date => :canceled_date,
                          :activation_date => :start_date,
                          :status => {
                            :completed => :completed,
                            :canceled  => :canceled,
                          },
                        },
                        Proc.new {|node,prop,obj|
                          obj.add_notes(node,prop)
                          obj.fix_completed_canceled(node, prop)
                          obj.archive_completed(prop)
                          obj.process_tags(node, prop, true, true)
                          obj.check_today(node, prop)
                        }
                       ]
  }
}
TITLEPROP =

For some reason some entities in THL use “title”, others use “name”

{
  :folder => :name,
  :list => :name,
  :task => :title
}
TIMEUNITS =

Time units for time-estimate tags

{
  "sec" => 1,
  "min" => 60,
  "hr"  => 60*60,
  "hour" => 60*60,
}