urls 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gemspec +29 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +66 -0
- data/Rakefile +36 -0
- data/bin/urls +4 -0
- data/lib/urls.rb +56 -0
- data/lib/urls/runner.rb +108 -0
- data/lib/urls/url.rb +28 -0
- data/lib/urls/version.rb +3 -0
- data/spec/helper.rb +42 -0
- data/spec/runner_spec.rb +192 -0
- metadata +239 -0
data/.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'rubygems' unless defined? :Gem
|
3
|
+
require File.dirname(__FILE__) + "/lib/urls/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "urls"
|
7
|
+
s.version = Urls::VERSION
|
8
|
+
s.authors = ["Gabriel Horner"]
|
9
|
+
s.email = "gabriel.horner@gmail.com"
|
10
|
+
s.homepage = "http://github.com/cldwalker/urls"
|
11
|
+
s.summary = "urls - bookmarking from the commandline with tags"
|
12
|
+
s.description = "urls is a commandline bookmarking app that aims to make bookmarking fast, easy and customizable. urls also lets you organize bookmarks by tags. Works only on ruby 1.9."
|
13
|
+
s.required_rubygems_version = ">= 1.3.6"
|
14
|
+
s.executables = %w(urls)
|
15
|
+
s.add_dependency 'boson', '~> 1.2'
|
16
|
+
s.add_dependency 'hirb'
|
17
|
+
s.add_dependency 'dm-core'
|
18
|
+
s.add_dependency 'dm-yaml-adapter'
|
19
|
+
s.add_dependency 'dm-migrations'
|
20
|
+
s.add_dependency 'dm-timestamps'
|
21
|
+
s.add_dependency 'dm-validations'
|
22
|
+
s.add_dependency 'tag', '~> 0.4'
|
23
|
+
s.add_development_dependency 'minitest', '~> 2.11.0'
|
24
|
+
s.add_development_dependency 'bahia', '~> 0.7'
|
25
|
+
s.add_development_dependency 'rake', '~> 0.9.2'
|
26
|
+
s.files = Dir.glob(%w[{lib,spec}/**/*.rb bin/* [A-Z]*.{txt,rdoc,md} ext/**/*.{rb,c} **/deps.rip]) + Dir.glob(%w{Rakefile .gemspec .travis.yml})
|
27
|
+
s.extra_rdoc_files = ["README.md", "LICENSE.txt"]
|
28
|
+
s.license = 'MIT'
|
29
|
+
end
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT LICENSE
|
2
|
+
|
3
|
+
Copyright (c) 2012 Gabriel Horner
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
## Description
|
2
|
+
urls is a commandline bookmarking app that aims to make bookmarking fast, easy, and customizable.
|
3
|
+
urls also lets you organize bookmarks by tags. Works only on ruby 1.9.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
```sh
|
8
|
+
# Comes with following commands
|
9
|
+
$ urls
|
10
|
+
Usage: urls [OPTIONS] COMMAND [ARGS]
|
11
|
+
|
12
|
+
Available commands:
|
13
|
+
add adds url with optional description and tags
|
14
|
+
edit edits urls in a file
|
15
|
+
help Displays help for a command
|
16
|
+
list list all urls or by a tag
|
17
|
+
rm removes url
|
18
|
+
tags List tags
|
19
|
+
|
20
|
+
Options:
|
21
|
+
-h, --help Displays this help message
|
22
|
+
|
23
|
+
# Optional description comes after url
|
24
|
+
$ urls add http://news.ycombinator.com time sink --tags funny
|
25
|
+
urls: Added http://news.ycombinator.com
|
26
|
+
|
27
|
+
$ urls list
|
28
|
+
+-----------------------------+-----------+-------+
|
29
|
+
| name | desc | tags |
|
30
|
+
+-----------------------------+-----------+-------+
|
31
|
+
| http://news.ycombinator.com | time sink | funny |
|
32
|
+
+-----------------------------+-----------+-------+
|
33
|
+
1 row in set
|
34
|
+
|
35
|
+
$ urls tags
|
36
|
+
funny
|
37
|
+
```
|
38
|
+
|
39
|
+
## Configuration
|
40
|
+
|
41
|
+
Custom config and additional commands can be defined in ~/.urlsrc:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
# Change database adapter to postgres
|
45
|
+
Urls.db = 'postgres://me:@localhost/my_db'
|
46
|
+
|
47
|
+
# Add `urls my_command` with a force option
|
48
|
+
class Urls::Runner
|
49
|
+
option force: :boolean
|
50
|
+
def my_command(options={})
|
51
|
+
end
|
52
|
+
end
|
53
|
+
```
|
54
|
+
|
55
|
+
For full list of supported database adapters, [see here](https://github.com/datamapper/dm-core/wiki/Adapters).
|
56
|
+
To learn more about defining custom commands, [read about boson](https://github.com/cldwalker/boson#readme).
|
57
|
+
|
58
|
+
## Motivation
|
59
|
+
[tagtree](https://github.com/cldwalker/tag-tree) and its shortcomings. While it had wicked querying
|
60
|
+
capibilites, it was pretty unusable from the commandline. urls aims to change that and make this
|
61
|
+
very usable, from the commandline and browser.
|
62
|
+
|
63
|
+
## TODO
|
64
|
+
* Create additional plugin to give your urls a web interface
|
65
|
+
* Create additional plugin that let's you add bookmarks from your browser
|
66
|
+
* Allow tag storage be indepent of `tag`
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
def gemspec
|
5
|
+
@gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
|
6
|
+
end
|
7
|
+
|
8
|
+
desc "Build the gem"
|
9
|
+
task :gem=>:gemspec do
|
10
|
+
sh "gem build .gemspec"
|
11
|
+
FileUtils.mkdir_p 'pkg'
|
12
|
+
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Install the gem locally"
|
16
|
+
task :install => :gem do
|
17
|
+
sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Generate the gemspec"
|
21
|
+
task :generate do
|
22
|
+
puts gemspec.to_ruby
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Validate the gemspec"
|
26
|
+
task :gemspec do
|
27
|
+
gemspec.validate
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'Run tests'
|
31
|
+
task :test do |t|
|
32
|
+
ENV['RUBYLIB'] = ['lib', '.', ENV['RUBYLIB']].compact.join(':')
|
33
|
+
sh 'testrb spec/*_spec.rb'
|
34
|
+
end
|
35
|
+
|
36
|
+
task :default => :test
|
data/bin/urls
ADDED
data/lib/urls.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'urls/url'
|
2
|
+
require 'urls/version'
|
3
|
+
|
4
|
+
module Urls
|
5
|
+
def self.home
|
6
|
+
@home ||= (ENV['URLS_HOME'] || File.join(Dir.home, '.urls')).tap do |dir|
|
7
|
+
FileUtils.mkdir_p(dir)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# database for datamapper. Can be a uri string or a hash of options
|
13
|
+
attr_accessor :db
|
14
|
+
# command to open urls in browser
|
15
|
+
attr_accessor :browser
|
16
|
+
end
|
17
|
+
|
18
|
+
self.browser = 'open'
|
19
|
+
|
20
|
+
def self.setup
|
21
|
+
self.db ||= { adapter: 'yaml', path: home }
|
22
|
+
DataMapper.setup(:default, db)
|
23
|
+
DataMapper.finalize
|
24
|
+
DataMapper.auto_upgrade!
|
25
|
+
ENV['TAG_MODEL'] = 'urls'
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.add_tag(url, tags)
|
29
|
+
tag('add', url, '--tags', *tags)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.tag(*cmds)
|
33
|
+
options = cmds[-1].is_a?(Hash) ? cmds.pop : {}
|
34
|
+
ENV['BOSONRC'] = '' # don't want urlsrc to pass as tagrc
|
35
|
+
if options[:capture]
|
36
|
+
`tag #{cmds.join(' ')}`
|
37
|
+
else
|
38
|
+
system('tag', *cmds)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.tagged_items
|
43
|
+
tag('items', capture: true).split("\n").inject({}) do |h,line|
|
44
|
+
url, tags = line.split("\t")
|
45
|
+
h.update url => tags
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
module API
|
50
|
+
# copy url(s) to clipboard, default uses osx
|
51
|
+
def copy(urls)
|
52
|
+
system(%[echo "#{urls.join("\n")}" | pbcopy])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
extend API
|
56
|
+
end
|
data/lib/urls/runner.rb
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'urls'
|
2
|
+
require 'boson/runner'
|
3
|
+
require 'hirb'
|
4
|
+
ENV['BOSONRC'] = ENV['URLS_RC'] || '~/.urlsrc'
|
5
|
+
|
6
|
+
module Urls
|
7
|
+
class Runner < Boson::Runner
|
8
|
+
# hook into init since it's after loading rc but before command execution
|
9
|
+
def self.init(*)
|
10
|
+
Urls.setup
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
option :tags, type: :array, desc: 'tags for url'
|
15
|
+
desc "adds url with optional description and tags"
|
16
|
+
def add(url, *desc)
|
17
|
+
options = desc[-1].is_a?(Hash) ? desc.pop : {}
|
18
|
+
abort "urls: #{url} already exists" if Url.first(name: Url.urlify(url))
|
19
|
+
|
20
|
+
if (obj = Url.create(name: url, desc: desc.join(' '))).saved?
|
21
|
+
if options[:tags]
|
22
|
+
Urls.add_tag(url, options[:tags])
|
23
|
+
end
|
24
|
+
say "Added #{url}"
|
25
|
+
else
|
26
|
+
abort "urls: Failed to save url - #{obj.errors.full_messages.join(', ')}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'removes url'
|
31
|
+
def rm(url)
|
32
|
+
if u = Url.first(name: Url.urlify(url))
|
33
|
+
u.destroy
|
34
|
+
say "Deleted #{url}"
|
35
|
+
else
|
36
|
+
abort "urls: #{url} not found"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
desc 'edits urls in a file'
|
41
|
+
def edit
|
42
|
+
unless DataMapper::Repository.adapters[:default].options['adapter'] == 'yaml'
|
43
|
+
abort 'urls: edit only works with yaml db'
|
44
|
+
end
|
45
|
+
file = Urls.home + '/urls.yml'
|
46
|
+
system(ENV['EDITOR'] || 'vim', file)
|
47
|
+
end
|
48
|
+
|
49
|
+
option :tab, type: :boolean, desc: 'print tab-delimited table', alias: 'T'
|
50
|
+
option :fields, type: :array, default: [:name, :desc], values: [:name, :desc],
|
51
|
+
desc: 'Fields to display'
|
52
|
+
option :simple, type: :boolean, desc: 'only lists urls'
|
53
|
+
option :open, type: :boolean, desc: 'open in browser'
|
54
|
+
option :copy, type: :boolean, desc: 'copy to clipboard'
|
55
|
+
option :tag, type: :boolean, desc: 'query by tag', alias: 't'
|
56
|
+
desc "list all urls or by a tag"
|
57
|
+
def list(query=nil, options={})
|
58
|
+
if options.delete(:simple)
|
59
|
+
options.update headers: false, fields: [:name], tab: true
|
60
|
+
end
|
61
|
+
|
62
|
+
urls = if options[:tag]
|
63
|
+
names = Urls.tag('list', query, capture: true).split("\n")
|
64
|
+
Url.all name: names
|
65
|
+
elsif query
|
66
|
+
Url.all(desc: /#{query}/) | Url.all(name: /#{query}/)
|
67
|
+
else
|
68
|
+
Url.all
|
69
|
+
end
|
70
|
+
|
71
|
+
Hirb.enable
|
72
|
+
if options[:open]
|
73
|
+
choices = menu urls.map(&:name)
|
74
|
+
cmds = Urls.browser.split(/\s+/)
|
75
|
+
choices.each {|u| system(*cmds, u) }
|
76
|
+
elsif options[:copy]
|
77
|
+
choices = menu urls.map(&:name)
|
78
|
+
Urls.copy choices
|
79
|
+
else
|
80
|
+
urls = urls.map {|e| e.attributes }
|
81
|
+
if !(url_tags = Urls.tagged_items).empty?
|
82
|
+
urls.each {|e| e[:tags] = url_tags[e[:name]] || '' }
|
83
|
+
options[:fields] << :tags
|
84
|
+
end
|
85
|
+
puts table(urls, options)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
desc 'List tags'
|
90
|
+
def tags
|
91
|
+
Urls.tag('tags')
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
def menu(arr)
|
97
|
+
Hirb::Menu.render(arr)
|
98
|
+
end
|
99
|
+
|
100
|
+
def table(rows, options={})
|
101
|
+
Hirb::Helpers::AutoTable.render(rows, options)
|
102
|
+
end
|
103
|
+
|
104
|
+
def say(*args)
|
105
|
+
puts *args.map {|e| "urls: #{e}" }
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
data/lib/urls/url.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'dm-core'
|
2
|
+
require 'dm-yaml-adapter'
|
3
|
+
require 'dm-migrations'
|
4
|
+
require 'dm-timestamps'
|
5
|
+
require 'dm-validations'
|
6
|
+
|
7
|
+
# set default string length
|
8
|
+
DataMapper::Property::String.length(255)
|
9
|
+
|
10
|
+
class Url
|
11
|
+
include DataMapper::Resource
|
12
|
+
|
13
|
+
property :id, Serial
|
14
|
+
property :name, String, required: true
|
15
|
+
property :desc, String
|
16
|
+
property :created_at, DateTime
|
17
|
+
property :updated_at, DateTime
|
18
|
+
|
19
|
+
validates_uniqueness_of :name
|
20
|
+
|
21
|
+
def self.urlify(url)
|
22
|
+
url.include?('://') ? url : "http://#{url}"
|
23
|
+
end
|
24
|
+
|
25
|
+
before :save do
|
26
|
+
self.name = self.class.urlify(name)
|
27
|
+
end
|
28
|
+
end
|
data/lib/urls/version.rb
ADDED
data/spec/helper.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
gem 'minitest' unless ENV['NO_RUBYGEMS']
|
2
|
+
require 'minitest/spec'
|
3
|
+
require 'minitest/autorun' unless $0.end_with?('/m')
|
4
|
+
require 'urls'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'bahia'
|
7
|
+
|
8
|
+
ENV['URLS_HOME'] = File.dirname(__FILE__) + '/.urls'
|
9
|
+
ENV['URLS_RC'] = File.dirname(__FILE__) + '/.urlsrc'
|
10
|
+
ENV['TAG_HOME'] = File.dirname(__FILE__) + '/.tag'
|
11
|
+
|
12
|
+
module TestHelpers
|
13
|
+
# rc file for executables
|
14
|
+
def with_rc(body)
|
15
|
+
old = ENV['URLS_RC']
|
16
|
+
ENV['URLS_RC'] = File.dirname(__FILE__) + '/.urlsrc.temp'
|
17
|
+
File.open(ENV['URLS_RC'], 'w') {|f| f.write body }
|
18
|
+
|
19
|
+
yield
|
20
|
+
|
21
|
+
FileUtils.rm_f ENV['URLS_RC']
|
22
|
+
ENV['URLS_RC'] = old
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class MiniTest::Unit::TestCase
|
27
|
+
include Bahia
|
28
|
+
include TestHelpers
|
29
|
+
end
|
30
|
+
|
31
|
+
module StringExt
|
32
|
+
def unindent
|
33
|
+
chomp.gsub(/^\s*/, '')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
String.send :include, StringExt
|
37
|
+
|
38
|
+
MiniTest::Unit.after_tests do
|
39
|
+
FileUtils.rm_rf(ENV['URLS_HOME'])
|
40
|
+
FileUtils.rm_rf(ENV['TAG_HOME'])
|
41
|
+
FileUtils.rm_f(ENV['URLS_RC'])
|
42
|
+
end
|
data/spec/runner_spec.rb
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
|
3
|
+
describe 'Urls::Runner' do
|
4
|
+
def stdout
|
5
|
+
super.chomp
|
6
|
+
end
|
7
|
+
|
8
|
+
def stderr
|
9
|
+
super.chomp
|
10
|
+
end
|
11
|
+
|
12
|
+
def list_urls(arg=nil)
|
13
|
+
urls "list #{arg} --simple"
|
14
|
+
end
|
15
|
+
|
16
|
+
before do
|
17
|
+
FileUtils.rm_rf(ENV['URLS_HOME'])
|
18
|
+
FileUtils.rm_rf(ENV['TAG_HOME'])
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'default help' do
|
22
|
+
it 'prints help with no arguments' do
|
23
|
+
urls
|
24
|
+
stdout.must_match /^Usage: urls/
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'prints help with --help' do
|
28
|
+
urls '--help'
|
29
|
+
stdout.must_match /^Usage: urls/
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'commands' do
|
34
|
+
describe 'add' do
|
35
|
+
it 'adds a url' do
|
36
|
+
urls 'add http://wtf.com'
|
37
|
+
stdout.must_equal "urls: Added http://wtf.com"
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'adds a url with a tag' do
|
41
|
+
urls 'add http://dodo.com -t bird'
|
42
|
+
list_urls('bird -t')
|
43
|
+
stdout.must_equal "http://dodo.com\tbird"
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'prints error for redundant submission' do
|
47
|
+
urls 'add http://wtf.com'
|
48
|
+
urls 'add http://wtf.com'
|
49
|
+
stderr.must_equal "urls: http://wtf.com already exists"
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'prints error for redundant submission without http' do
|
53
|
+
urls 'add http://wtf.com'
|
54
|
+
urls 'add wtf.com'
|
55
|
+
stderr.must_equal "urls: wtf.com already exists"
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'prints error when validation fails' do
|
59
|
+
urls 'add ""'
|
60
|
+
stderr.must_equal "urls: Failed to save url - Name must not be blank"
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'automatically prepends http:// if not given' do
|
64
|
+
urls 'add google.com'
|
65
|
+
list_urls
|
66
|
+
stdout.must_equal "http://google.com"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'deletes a url' do
|
71
|
+
urls 'add http://wtf.com'
|
72
|
+
urls 'rm http://wtf.com'
|
73
|
+
|
74
|
+
stdout.must_equal "urls: Deleted http://wtf.com"
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'deletes a url without specifying http' do
|
78
|
+
urls 'add http://wtf.com'
|
79
|
+
urls 'rm wtf.com'
|
80
|
+
|
81
|
+
stdout.must_equal "urls: Deleted wtf.com"
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'prints an error when deleting a nonexistant url' do
|
85
|
+
urls 'rm blah'
|
86
|
+
stderr.must_equal "urls: blah not found"
|
87
|
+
end
|
88
|
+
|
89
|
+
describe 'list' do
|
90
|
+
it 'lists a url with no args' do
|
91
|
+
urls 'add http://wtf.com some desc'
|
92
|
+
urls 'list'
|
93
|
+
stdout.must_equal <<-STR.unindent
|
94
|
+
+----------------+-----------+
|
95
|
+
| name | desc |
|
96
|
+
+----------------+-----------+
|
97
|
+
| http://wtf.com | some desc |
|
98
|
+
+----------------+-----------+
|
99
|
+
1 row in set
|
100
|
+
STR
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'lists a url by name' do
|
104
|
+
urls 'add http://wtf.com some desc'
|
105
|
+
urls 'list wtf'
|
106
|
+
stdout.must_equal <<-STR.unindent
|
107
|
+
+----------------+-----------+
|
108
|
+
| name | desc |
|
109
|
+
+----------------+-----------+
|
110
|
+
| http://wtf.com | some desc |
|
111
|
+
+----------------+-----------+
|
112
|
+
1 row in set
|
113
|
+
STR
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'lists a url by desc' do
|
117
|
+
urls 'add http://wtf.com some desc'
|
118
|
+
urls 'list some'
|
119
|
+
stdout.must_equal <<-STR.unindent
|
120
|
+
+----------------+-----------+
|
121
|
+
| name | desc |
|
122
|
+
+----------------+-----------+
|
123
|
+
| http://wtf.com | some desc |
|
124
|
+
+----------------+-----------+
|
125
|
+
1 row in set
|
126
|
+
STR
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'lists a url by a tag' do
|
130
|
+
urls 'add http://dodo.com -t bird'
|
131
|
+
urls 'list bird -t'
|
132
|
+
stdout.must_equal <<-STR.unindent
|
133
|
+
+-----------------+------+------+
|
134
|
+
| name | desc | tags |
|
135
|
+
+-----------------+------+------+
|
136
|
+
| http://dodo.com | | bird |
|
137
|
+
+-----------------+------+------+
|
138
|
+
1 row in set
|
139
|
+
STR
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'lists a url and opens it' do
|
143
|
+
skip 'how?'
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'lists a url and copies it' do
|
147
|
+
skip 'how?'
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'edits a url' do
|
152
|
+
ENV['EDITOR'] = 'echo'
|
153
|
+
urls 'edit'
|
154
|
+
stdout.must_equal Urls.home + '/urls.yml'
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'edits a url' do
|
158
|
+
ENV['EDITOR'] = 'echo'
|
159
|
+
urls 'edit'
|
160
|
+
stdout.must_equal Urls.home + '/urls.yml'
|
161
|
+
end
|
162
|
+
|
163
|
+
it "doesn't edit a url if a non-yaml db" do
|
164
|
+
with_rc "Urls.db = {adapter: 'in_memory'}" do
|
165
|
+
urls 'edit'
|
166
|
+
stderr.must_equal 'urls: edit only works with yaml db'
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
it "lists tags" do
|
171
|
+
urls 'add http://dodo.com -t bird'
|
172
|
+
urls 'tags'
|
173
|
+
stdout.must_equal 'bird'
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe "$URLS_RC" do
|
178
|
+
it 'loads when defined' do
|
179
|
+
with_rc "puts 'RC in the house'" do
|
180
|
+
urls
|
181
|
+
stdout.must_match /RC in the house/
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'can define a custom db' do
|
186
|
+
with_rc "Urls.db = {adapter: 'sqlite'}" do
|
187
|
+
urls
|
188
|
+
stderr.must_match /`require':.*dm-sqlite-adapter/
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
metadata
ADDED
@@ -0,0 +1,239 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: urls
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Gabriel Horner
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-08 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: boson
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.2'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.2'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: hirb
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: dm-core
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: dm-yaml-adapter
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: dm-migrations
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: dm-timestamps
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: dm-validations
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: tag
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ~>
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0.4'
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ~>
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0.4'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: minitest
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ~>
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: 2.11.0
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ~>
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: 2.11.0
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: bahia
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ~>
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0.7'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ~>
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0.7'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: rake
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ~>
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: 0.9.2
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ~>
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: 0.9.2
|
190
|
+
description: urls is a commandline bookmarking app that aims to make bookmarking fast,
|
191
|
+
easy and customizable. urls also lets you organize bookmarks by tags. Works only
|
192
|
+
on ruby 1.9.
|
193
|
+
email: gabriel.horner@gmail.com
|
194
|
+
executables:
|
195
|
+
- urls
|
196
|
+
extensions: []
|
197
|
+
extra_rdoc_files:
|
198
|
+
- README.md
|
199
|
+
- LICENSE.txt
|
200
|
+
files:
|
201
|
+
- lib/urls/runner.rb
|
202
|
+
- lib/urls/url.rb
|
203
|
+
- lib/urls/version.rb
|
204
|
+
- lib/urls.rb
|
205
|
+
- spec/helper.rb
|
206
|
+
- spec/runner_spec.rb
|
207
|
+
- bin/urls
|
208
|
+
- LICENSE.txt
|
209
|
+
- CHANGELOG.md
|
210
|
+
- README.md
|
211
|
+
- Rakefile
|
212
|
+
- .gemspec
|
213
|
+
- .travis.yml
|
214
|
+
homepage: http://github.com/cldwalker/urls
|
215
|
+
licenses:
|
216
|
+
- MIT
|
217
|
+
post_install_message:
|
218
|
+
rdoc_options: []
|
219
|
+
require_paths:
|
220
|
+
- lib
|
221
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
222
|
+
none: false
|
223
|
+
requirements:
|
224
|
+
- - ! '>='
|
225
|
+
- !ruby/object:Gem::Version
|
226
|
+
version: '0'
|
227
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
|
+
none: false
|
229
|
+
requirements:
|
230
|
+
- - ! '>='
|
231
|
+
- !ruby/object:Gem::Version
|
232
|
+
version: 1.3.6
|
233
|
+
requirements: []
|
234
|
+
rubyforge_project:
|
235
|
+
rubygems_version: 1.8.19
|
236
|
+
signing_key:
|
237
|
+
specification_version: 3
|
238
|
+
summary: urls - bookmarking from the commandline with tags
|
239
|
+
test_files: []
|