Skip to content

Commit

Permalink
Fix version chomping
Browse files Browse the repository at this point in the history
  • Loading branch information
dropofwill committed Apr 16, 2015
1 parent 51e19a4 commit ee34835
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions lib/rtasklib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
require_relative "rtasklib/taskrc"

require "open3"
require "pathname"

module Rtasklib

class TaskWarrior
attr_reader :taskrc, :version, :rc_location,
:data_location, :override, :create_new
attr_reader :taskrc, :version, :rc_location, :data_location,
:override, :create_new, :config

DEFAULT_CONFIG = {
json: {
Expand All @@ -24,12 +25,13 @@ class TaskWarrior
},
}

def initialize rc="#{Dir.home}/.taskrc", override=DEFAULT_CONFIG,
create_new=false
@rc_location = rc
@data_location = rc.chomp('rc')
def initialize rc="#{Dir.home}/.taskrc", data="#{Dir.home}/.task/",
override=DEFAULT_CONFIG, create_new=false
@rc_location = Pathname.new(rc)
@data_location = Pathname.new(data)
@override = DEFAULT_CONFIG.merge(override)
@create_new = create_new
@config = Rtasklib::Taskrc.new(rc)

# Check TW version, and throw warning
# begin
Expand All @@ -44,7 +46,7 @@ def check_version
raw_ver, retval = Rtasklib::Execute.task(@create_new,
"rc.data.location=#{@data_location}",
"_version")
gem_ver = Gem::Version.new(raw_ver[0].chomp) if retval == 0
gem_ver = Gem::Version.new(raw_ver.chomp) if retval == 0

if gem_ver < Gem::Version.new('2.4.0')
warn "#{gem_ver} is untested"
Expand Down
2 changes: 1 addition & 1 deletion lib/rtasklib/taskrc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TaskrcModel
class Taskrc
attr_reader :config

def initialize rc="#{Dir.home}/.taskrc"
def initialize rc
taskrc = []

File.open(rc).each do |line|
Expand Down

0 comments on commit ee34835

Please sign in to comment.