diff --git a/lib/calligraphy.rb b/lib/calligraphy.rb index dd9d2d4..4c35ad2 100644 --- a/lib/calligraphy.rb +++ b/lib/calligraphy.rb @@ -6,6 +6,7 @@ require 'calligraphy/xml/namespace' require 'calligraphy/xml/node' require 'calligraphy/xml/utils' +require 'calligraphy/utils' require 'calligraphy/resource' require 'calligraphy/web_dav_request' diff --git a/lib/calligraphy/utils.rb b/lib/calligraphy/utils.rb new file mode 100644 index 0000000..8776de5 --- /dev/null +++ b/lib/calligraphy/utils.rb @@ -0,0 +1,22 @@ +module Calligraphy + module Utils + TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'] + FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE'] + + def is_true?(val) + TRUE_VALUES.include? val + end + + def is_false?(val) + FALSE_VALUES.include? val + end + + def join_paths(*paths) + paths.join '/' + end + + def split_and_pop(path:, separator: '/') + path.split(separator)[0..-2] + end + end +end