module Urls
Constants
- VERSION
Attributes
browser[RW]
command to open urls in browser
db[RW]
database for datamapper. Can be a uri string or a hash of options
Public Class Methods
add_tag(url, tags)
click to toggle source
# File lib/urls.rb, line 28 def self.add_tag(url, tags) tag('add', url, '--tags', *tags) end
home()
click to toggle source
# File lib/urls.rb, line 5 def self.home @home ||= (ENV['URLS_HOME'] || File.join(Dir.home, '.urls')).tap do |dir| FileUtils.mkdir_p(dir) end end
setup()
click to toggle source
# File lib/urls.rb, line 20 def self.setup self.db ||= { adapter: 'yaml', path: home } DataMapper.setup(:default, db) DataMapper.finalize DataMapper.auto_upgrade! ENV['TAG_MODEL'] = 'urls' end
tag(*cmds)
click to toggle source
# File lib/urls.rb, line 32 def self.tag(*cmds) options = cmds[-1].is_a?(Hash) ? cmds.pop : {} ENV['BOSONRC'] = '' # don't want urlsrc to pass as tagrc if options[:capture] `tag #{cmds.join(' ')}` else system('tag', *cmds) end end
tagged_items()
click to toggle source
# File lib/urls.rb, line 42 def self.tagged_items tag('items', capture: true).split("\n").inject({}) do |h,line| url, tags = line.split("\t") h.update url => tags end end