tag 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 +19 -0
- data/CHANGELOG.rdoc +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +36 -0
- data/bin/tag +4 -0
- data/deps.rip +1 -0
- data/lib/tag.rb +88 -0
- metadata +74 -0
data/.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'rubygems' unless Object.const_defined?(:Gem)
|
3
|
+
require File.dirname(__FILE__) + "/lib/tag"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "tag"
|
7
|
+
s.version = Tag::VERSION
|
8
|
+
s.authors = ["Gabriel Horner"]
|
9
|
+
s.email = "gabriel.horner@gmail.com"
|
10
|
+
s.homepage = "http://github.com/cldwalker/tag"
|
11
|
+
s.summary = "tag anything from the commandline"
|
12
|
+
s.description = "This project lets you tag anything from the commandline. The `tag` executable provides a consistent way to add, remove and modify tags for tagged items. The goal is to make tagging dead simple and usable by other commandline apps. In making tags a first class nix citizen, perhaps they will see the light of day."
|
13
|
+
s.required_rubygems_version = ">= 1.3.6"
|
14
|
+
s.executables = %w(tag)
|
15
|
+
s.add_dependency 'thor', '~> 0.14.6'
|
16
|
+
s.files = Dir.glob(%w[{lib,spec}/**/*.rb bin/* [A-Z]*.{txt,rdoc,md} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
|
17
|
+
s.extra_rdoc_files = ["README.md", "LICENSE.txt"]
|
18
|
+
s.license = 'MIT'
|
19
|
+
end
|
data/CHANGELOG.rdoc
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT LICENSE
|
2
|
+
|
3
|
+
Copyright (c) 2011 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,37 @@
|
|
1
|
+
Description
|
2
|
+
===========
|
3
|
+
This project lets you tag anything from the commandline. The `tag` executable
|
4
|
+
provides a consistent way to add, remove and modify tags for tagged
|
5
|
+
items. The goal is to make tagging dead simple and usable by other commandline apps.
|
6
|
+
In making tags a first class nix citizen, perhaps they will see the light of day.
|
7
|
+
|
8
|
+
Examples
|
9
|
+
========
|
10
|
+
|
11
|
+
$ tag add horse animal
|
12
|
+
$ tag add cat animal
|
13
|
+
$ tag list animal
|
14
|
+
horse
|
15
|
+
cat
|
16
|
+
|
17
|
+
# TODO
|
18
|
+
|
19
|
+
Motivation
|
20
|
+
==========
|
21
|
+
As I wanted to tag [my vim knowledge](http://github.com/cldwalker/vimdb) on the
|
22
|
+
commandline, I found its tagging features to greatly exceed that project's
|
23
|
+
scope.
|
24
|
+
|
25
|
+
Contributing
|
26
|
+
============
|
27
|
+
[See here](http://tagaholic.me/contributing.html)
|
28
|
+
|
29
|
+
Todo
|
30
|
+
====
|
31
|
+
|
32
|
+
* Tests!
|
33
|
+
* Several more tag actions
|
34
|
+
* Description and time fields
|
35
|
+
* Make storage agnostic
|
36
|
+
* Switch from thor to boson
|
37
|
+
* Explain how to integrate with other commandline apps
|
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']
|
33
|
+
sh 'testrb spec/*_spec.rb'
|
34
|
+
end
|
35
|
+
|
36
|
+
task :default => :test
|
data/bin/tag
ADDED
data/deps.rip
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
thor ~>0.14.6
|
data/lib/tag.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'thor'
|
3
|
+
|
4
|
+
module Tag
|
5
|
+
VERSION = '0.1.0'
|
6
|
+
|
7
|
+
class Store
|
8
|
+
class << self; attr_accessor :file; end
|
9
|
+
self.file = Dir.home + '/.tagrc'
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@file = self.class.file
|
13
|
+
@hash = File.exists?(@file) ? YAML.load_file(@file) : {}
|
14
|
+
end
|
15
|
+
|
16
|
+
def save
|
17
|
+
File.open(@file, 'w') {|f| f.write(@hash.to_yaml) }
|
18
|
+
end
|
19
|
+
|
20
|
+
def tag(item, tag)
|
21
|
+
@hash[tag] ||= []
|
22
|
+
@hash[tag] << item
|
23
|
+
save
|
24
|
+
end
|
25
|
+
|
26
|
+
def remove_tag(item, tag)
|
27
|
+
@hash[tag] ||= []
|
28
|
+
@hash[tag].delete item
|
29
|
+
save
|
30
|
+
end
|
31
|
+
|
32
|
+
def list(tag)
|
33
|
+
@hash[tag] ||= []
|
34
|
+
@hash[tag]
|
35
|
+
end
|
36
|
+
|
37
|
+
def list_tags
|
38
|
+
@hash.keys.sort
|
39
|
+
end
|
40
|
+
|
41
|
+
def tree
|
42
|
+
list_tags.map {|tag|
|
43
|
+
["#{tag}", list(tag).map {|t| " #{t}" }]
|
44
|
+
}.flatten
|
45
|
+
end
|
46
|
+
|
47
|
+
def delete_tags(*tags)
|
48
|
+
tags.each {|tag| @hash.delete(tag) }
|
49
|
+
save
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.store
|
54
|
+
@store ||= Store.new
|
55
|
+
end
|
56
|
+
|
57
|
+
class Runner < Thor
|
58
|
+
desc "add ITEM TAG", 'tag an item'
|
59
|
+
def add(item, tag)
|
60
|
+
Tag.store.tag(item, tag)
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "rm ITEM TAG", 'remove tag from item'
|
64
|
+
def rm(item, tag)
|
65
|
+
Tag.store.remove_tag(item, tag)
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "list TAG", 'list items by tag'
|
69
|
+
def list(tag)
|
70
|
+
puts Tag.store.list(tag)
|
71
|
+
end
|
72
|
+
|
73
|
+
method_option :rm, :type => :boolean, :desc => 'remove tags'
|
74
|
+
desc "tags", 'list or remove tags'
|
75
|
+
def tags(*args)
|
76
|
+
if options[:rm]
|
77
|
+
Tag.store.delete_tags(*args)
|
78
|
+
else
|
79
|
+
puts Tag.store.list_tags
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
desc "tree", 'print tags with their items underneath them'
|
84
|
+
def tree
|
85
|
+
puts Tag.store.tree
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tag
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Gabriel Horner
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-11-12 00:00:00 -05:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: thor
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ~>
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.14.6
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
description: This project lets you tag anything from the commandline. The `tag` executable provides a consistent way to add, remove and modify tags for tagged items. The goal is to make tagging dead simple and usable by other commandline apps. In making tags a first class nix citizen, perhaps they will see the light of day.
|
28
|
+
email: gabriel.horner@gmail.com
|
29
|
+
executables:
|
30
|
+
- tag
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files:
|
34
|
+
- README.md
|
35
|
+
- LICENSE.txt
|
36
|
+
files:
|
37
|
+
- lib/tag.rb
|
38
|
+
- bin/tag
|
39
|
+
- LICENSE.txt
|
40
|
+
- CHANGELOG.rdoc
|
41
|
+
- README.md
|
42
|
+
- deps.rip
|
43
|
+
- Rakefile
|
44
|
+
- .gemspec
|
45
|
+
has_rdoc: true
|
46
|
+
homepage: http://github.com/cldwalker/tag
|
47
|
+
licenses:
|
48
|
+
- MIT
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.3.6
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.6.2
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: tag anything from the commandline
|
73
|
+
test_files: []
|
74
|
+
|