oktags 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a89cb6486aade586eadf73e6357523224302d7d4034a2dd3bef56a560d6e8f6c
4
- data.tar.gz: 0d103fef3b089a96eb954b0d3fce4709f93a2c11b2c0a938519a9886fa60593e
3
+ metadata.gz: 627114b53a234963a6e1547602f9bdabbd2e91814b6d7b07de8d2f07989170c4
4
+ data.tar.gz: 16fe1866c9793190c90af178b5125685b4afd4645cb2e43574c952466408bb5b
5
5
  SHA512:
6
- metadata.gz: f94eef23e1e45da986d19b664ec370869bdb9fe9230ddc6bd95cc46d7cd552d2c86a96781e23ef15591ca10453c56539b4a6af513dc35cb501972cd6703841f0
7
- data.tar.gz: 6bbfbe8fc72f800293af14782d373fa7eb882ee98c970b72c63816d6e31af2cc8e4d891d49812fac5c14182283cb1ba3cccbefe7e95afc7a5b6275882768764b
6
+ metadata.gz: d85747e3fd8ccad82fa328a853a3aea67e4ae6d2116474e34f61599fe535624f89ba8d540e296a847e652b5273bbcb60e95c340d236039ac4124a9d79b0bf983
7
+ data.tar.gz: 5d606c25adf29ace1025ce67a2287f4078775254c3dba57768dcdfc8e79a5390abdddd8976e3c4d6a37f45dd60e417271d9a3093a2db6d4dfbabe5812cc18530
data/Gemfile CHANGED
@@ -2,7 +2,9 @@ source 'https://rubygems.org' do
2
2
  # Specify your gem's dependencies in oktags.gemspec
3
3
  gemspec
4
4
 
5
- gem "rake", "~> 12.0"
6
-
7
- gem 'rspec'
5
+ group :development, :test do
6
+ gem 'rake', '~> 12.0'
7
+ gem 'rspec'
8
+ gem 'byebug'
9
+ end
8
10
  end
@@ -6,6 +6,7 @@ PATH
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ byebug (11.1.3)
9
10
  diff-lcs (1.4.4)
10
11
  rake (12.3.2)
11
12
  rspec (3.9.0)
@@ -26,6 +27,7 @@ PLATFORMS
26
27
  ruby
27
28
 
28
29
  DEPENDENCIES
30
+ byebug!
29
31
  oktags!
30
32
  rake (~> 12.0)!
31
33
  rspec!
data/README.org CHANGED
@@ -18,13 +18,15 @@
18
18
 
19
19
  #+begin_example
20
20
  Usage: oktags [options]
21
- -l, --list [PATH] List file tags (optionally for PATH)
22
21
  -a, --add-tags TAGS FILE Add comma-separated TAGS to FILE
22
+ -d TAG FILE, Delete TAG from FILE
23
+ --delete-tag-from-file
23
24
  -i FILE, Auto-complete tags and add them to FILE
24
25
  --add-tags-interactively
26
+ -l, --list [PATH] List file tags (optional PATH)
25
27
  -r, --rename-tag OLD_TAG NEW_TAG Rename OLD_TAG to NEW_TAG(S) recursively for all files
26
- -d TAG FILE, Delete TAG from FILE
27
- --delete-tag-from-file
28
+ -s TAGS [PATH], Search files which include (comma-separated) tags recursively (optional PATH)
29
+ --search-files-with-tags
28
30
  #+end_example
29
31
 
30
32
  * DESCRIPTION
@@ -37,34 +39,32 @@ it should work on Linux, macOS and Windows.
37
39
 
38
40
  * EXAMPLES
39
41
 
40
- Listing all tags in the current folder.
41
-
42
- #+begin_example
43
- $ touch foo
44
- $ touch bar.txt
45
- $ touch foobar--[tag1,tag2].pdf
46
- $ touch baz--[tag1].txt
47
- $ oktags -l
48
- tag1(2)
49
- tag2(1)
50
- #+end_example
51
-
52
- Listing all tags for a given path glob (assuming the same data set as above).
42
+ Add tags to a file. Tags are always unique.
53
43
 
54
44
  #+begin_example
55
- $ oktags -l '*txt'
56
- tag1(1)
45
+ $ touch foobar
46
+ $ oktags -a tag1 foobar
47
+ $ ls foobar*
48
+ foobar--[tag1]
49
+ $ oktags -a tag2 foobar--\[tag1\]
50
+ $ ls foobar*
51
+ foobar--[tag1,tag2]
52
+ $ oktags -a tag3,tag2 foobar--[tag1,tag2].pdf
53
+ $ ls foobar*
54
+ foobar--[tag1,tag2,tag3].pdf
57
55
  #+end_example
58
56
 
59
- Adding tags to a file. NB: Tags are always unique.
57
+ Delete a tag from a file.
60
58
 
61
59
  #+begin_example
62
- oktags -a tag3,tag2 foobar--[tag1,tag2].pdf
63
- $ ls foobar*
64
- foobar--[tag1,tag2,tag3].pdf
60
+ $ find . | grep business_card | head -n 1
61
+ ./archiv/Reto_Huber--[business_card,somedia,seo].pdf
62
+ $ oktags -d seo ./archiv/Reto_Huber--[business_card,somedia,seo].pdf
63
+ $ find . | grep business_card | head -n 1
64
+ ./archiv/Reto_Huber--[business_card,somedia].pdf
65
65
  #+end_example
66
66
 
67
- Interactively adding tags (with auto-completion through readline) to a file.
67
+ Interactively add tags (with auto-completion through readline) to a file.
68
68
 
69
69
  #+begin_example
70
70
  $ oktags -i foo
@@ -72,30 +72,50 @@ Interactively adding tags (with auto-completion through readline) to a file.
72
72
  tag1 tag2 tag3
73
73
  > tag2, new tag
74
74
  $ ls foo* | grep new
75
- foo--[new tag,tag2]
75
+ foo--[new_tag,tag2]
76
+ #+end_example
77
+
78
+ List all tags in the current folder.
79
+
80
+ #+begin_example
81
+ $ touch foo
82
+ $ touch bar.txt
83
+ $ touch foobar--[tag1,tag2].pdf
84
+ $ touch baz--[tag1].txt
85
+ $ oktags -l
86
+ tag1(2)
87
+ tag2(1)
88
+ #+end_example
89
+
90
+ List all tags for a given path glob (assuming the same data set as above).
91
+
92
+ #+begin_example
93
+ $ oktags -l '*txt'
94
+ tag1(1)
76
95
  #+end_example
77
96
 
78
- Renaming tags.
97
+ Rename tag.
79
98
 
80
99
  #+begin_example
81
100
  $ oktags -l
82
101
  200ok_expense(8)
83
102
  business_card(4)
84
- $ oktags -r 200ok_expense "200ok,expense"
103
+ $ oktags -r 200ok_expense 200ok,expense
85
104
  $ oktags -l
86
105
  expense(8)
87
106
  200ok(8)
88
107
  business_card(4)
89
108
  #+end_example
90
109
 
91
- Remove a tag from a file.
110
+ Search files with tags.
92
111
 
93
112
  #+begin_example
94
- $ find . | grep business_card | head -n 1
95
- ./archiv/Cyrill_Schwitter--[business_card,somedia,seo].pdf
96
- $ oktags -d seo ./archiv/Cyrill_Schwitter--[business_card,somedia,seo].pdf
97
- $ find . | grep business_card | head -n 1
98
- ./archiv/Cyrill_Schwitter--[business_card,somedia].pdf
113
+ $ oktags -s somedia,seo,business_card
114
+ archiv/Reto_Huber--[business_card,seo,somedia].pdf
115
+ archiv/Reto_Huber--[business_card,seo,somedia].txt
116
+ $ oktags -s business_card '**/*pdf'
117
+ archiv/Reto_Huber--[business_card,seo,somedia].pdf
118
+ archiv/Stefan_Schmidt--[business_card,lawoon].pdf
99
119
  #+end_example
100
120
 
101
121
  * INSTALLATION
@@ -122,20 +142,14 @@ the =.gem= file to [[https://rubygems.org][rubygems.org]].
122
142
 
123
143
  * TESTS
124
144
 
125
- Tests are implemented with [[https://rspec.info/][RSpec]] and can be run like this:
126
-
127
- #+begin_src shell
128
- ......
129
-
130
- Finished in 0.00408 seconds (files took 0.07109 seconds to load)
131
- 6 examples, 0 failures
132
- #+end_src
145
+ Tests are implemented with [[https://rspec.info/][RSpec]] and can be run with =bundle exec
146
+ rspec spec=.
133
147
 
134
148
  * NOTES
135
149
 
136
150
  Software systems come and go. It is easy to lose important data in
137
- (proprietary) legacy systems. Plain old files are boring and therefore
138
- are here to stay; at least they [[https://en.wikipedia.org/wiki/Computer_file#Storage][have been around since 1961]].
151
+ (proprietary) legacy systems. Plain old files are boring and are
152
+ therefore here to stay; at least they [[https://en.wikipedia.org/wiki/Computer_file#Storage][have been around since 1961]].
139
153
  Additional benefits of using plain old files are:
140
154
 
141
155
  - They are (mostly) platform independent.
@@ -146,14 +160,14 @@ Additional benefits of using plain old files are:
146
160
  - They can be transported independently from the software that captured/created them.
147
161
  - They are not proprietary.
148
162
 
149
- =oktags= is decidedly built to be just as boring as plain old
150
- files. It's written in a language that's been proven for shell scripts
151
- ([[https://www.ruby-lang.org/en/][Ruby]]) rather than using something more 'cool' like Clojure (with
152
- [[https://github.com/borkdude/babashka][babashka]] or [[https://github.com/anmonteiro/lumo][lumo]]). It also only uses Ruby primitives and has
153
- dependencies (apart from the test framework). =oktags= is
154
- therefore boring and here to stay. The idea is to tag your files once
155
- and for all, so you don't loose your important data in something that
156
- will become an unsupported legacy system at some point.
163
+ =oktags= is decidedly built to be just as boring as plain old files.
164
+ It's written in a language that's been proven for shell scripts ([[https://www.ruby-lang.org/en/][Ruby]])
165
+ rather than using something more 'cool'/'interesting'. It also only
166
+ uses Ruby built-ins and has no dependencies when run as a CLI or
167
+ library. =oktags= is therefore boring and here to stay. The idea is to
168
+ tag your files once and for all, so you will not loose your important
169
+ data in something that will become an unsupported legacy system at
170
+ some point.
157
171
 
158
172
  At [[https://200ok.ch/][200ok]], we develop various Free Software projects that work on plain
159
173
  old files:
data/bin/oktags CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'oktags'
3
+ require File.expand_path(File.join(%w[.. .. lib ok tags]), __FILE__)
4
4
  OK::Tags.main
@@ -0,0 +1,15 @@
1
+ class Hash
2
+ # like invert but not lossy. possibly a good blog post.
3
+ def safe_invert
4
+ inject({}) do |acc, (k, v)|
5
+ if v.is_a? Array
6
+ v.each do |vx|
7
+ acc[vx] = acc[vx].nil? ? k : [acc[vx], k].flatten
8
+ end
9
+ else
10
+ acc[v] = acc[v].nil? ? k : [acc[v], k].flatten
11
+ end
12
+ acc
13
+ end
14
+ end
15
+ end
@@ -5,25 +5,7 @@ require 'optparse'
5
5
  require 'set'
6
6
  require 'readline'
7
7
  require 'fileutils'
8
- require 'byebug'
9
-
10
- # TODO: Put this into it's own file
11
- class Hash
12
- # like invert but not lossy. possibly a good blog post.
13
- def safe_invert
14
- inject({}) do |acc, (k, v)|
15
- if v.is_a? Array
16
- v.each do |vx|
17
- acc[vx] = acc[vx].nil? ? k : [acc[vx], k].flatten
18
- end
19
- else
20
- acc[v] = acc[v].nil? ? k : [acc[v], k].flatten
21
- end
22
- acc
23
- end
24
- end
25
- end
26
-
8
+ require File.expand_path(File.join(%w[.. .. hash]), __FILE__)
27
9
 
28
10
  module OK
29
11
  module Tags
@@ -204,7 +186,7 @@ module OK
204
186
  opts.on(
205
187
  '-l',
206
188
  '--list [PATH]',
207
- 'List file tags (optional PATH)'
189
+ 'List file tags recursively (at optional PATH)'
208
190
  ) do |path|
209
191
  path ? list_pretty_tags(path) : list_pretty_tags
210
192
  exit
@@ -220,7 +202,7 @@ module OK
220
202
  opts.on(
221
203
  '-s',
222
204
  '--search-files-with-tags TAGS [PATH]',
223
- 'Search files which include (comma-separated) tags recursively (optional PATH)'
205
+ 'Search files which include (comma-separated) TAGS recursively (at optional PATH)'
224
206
  ) do |tags|
225
207
  if ARGV[0]
226
208
  list_files_with_tags(tags, ARGV[0])
@@ -234,4 +216,4 @@ module OK
234
216
  end
235
217
  end
236
218
 
237
- OK::Tags.main
219
+ OK::Tags.main if $0 == __FILE__
@@ -1,5 +1,5 @@
1
1
  module OK
2
2
  module Tags
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oktags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alain M. Lafon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-15 00:00:00.000000000 Z
11
+ date: 2020-10-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'oktags helps you organize your files by managing tags on them. It works
14
14
  by adding/removing at the end of the filename. Given a file ''cat.jpg'', when adding
@@ -33,6 +33,7 @@ files:
33
33
  - bin/console
34
34
  - bin/oktags
35
35
  - bin/setup
36
+ - lib/hash.rb
36
37
  - lib/ok/tags.rb
37
38
  - lib/ok/version.rb
38
39
  - lib/oktags.rb