nowa-chit 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +11 -4
- data/lib/chit.rb +36 -21
- metadata +2 -1
data/README.txt
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
= Chit
|
2
2
|
|
3
|
+
http://github.com/nowa/chit
|
3
4
|
http://github.com/robin/chit
|
4
5
|
|
5
6
|
== DESCRIPTION:
|
@@ -31,11 +32,11 @@ $ chit [cheatsheet]
|
|
31
32
|
|
32
33
|
If it does not exist, a new one will be created and waiting for editing. Leave it blank and quit the editor if you don't want to add a new one.
|
33
34
|
|
34
|
-
To edit a cheat sheet, use the --edit switch.
|
35
|
+
To edit a cheat sheet, use the --edit/-e switch.
|
35
36
|
|
36
37
|
$ cheat [cheatsheet] --edit
|
37
38
|
|
38
|
-
To add a cheat sheet, use the --add switch.
|
39
|
+
To add a cheat sheet, use the --add/-a switch.
|
39
40
|
|
40
41
|
$ cheat [cheatsheet] --add
|
41
42
|
|
@@ -47,7 +48,7 @@ To get your private cheat sheet:
|
|
47
48
|
|
48
49
|
$ chit @[cheatsheet]
|
49
50
|
|
50
|
-
The prefix '@' works the same for both --edit and --add.
|
51
|
+
The prefix '@' works the same for both --edit/-e and --add/-a.
|
51
52
|
|
52
53
|
The cheat sheet can be in a path. For example:
|
53
54
|
|
@@ -63,6 +64,10 @@ To show all the private cheat sheets:
|
|
63
64
|
|
64
65
|
$ chit @[all|sheets]
|
65
66
|
|
67
|
+
To search cheat sheets begin with 'name', use the --search/-s switch
|
68
|
+
|
69
|
+
$ chit name --search
|
70
|
+
|
66
71
|
== INSTALL:
|
67
72
|
|
68
73
|
sudo gem install robin-chit -s http://gems.github.com
|
@@ -112,8 +117,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
112
117
|
|
113
118
|
== BY:
|
114
119
|
|
115
|
-
Robin Lu
|
120
|
+
Robin Lu, nowa
|
116
121
|
|
117
122
|
http://www.robinlu.com
|
123
|
+
http://www.nowazhu.com
|
118
124
|
|
119
125
|
iamawalrus[at]gmail[dot]com
|
126
|
+
nowazhu[at]gmail[dot]com
|
data/lib/chit.rb
CHANGED
@@ -3,7 +3,7 @@ $:.unshift File.dirname(__FILE__)
|
|
3
3
|
|
4
4
|
module Chit
|
5
5
|
extend self
|
6
|
-
VERSION = '0.0.
|
6
|
+
VERSION = '0.0.5'
|
7
7
|
|
8
8
|
defaults = {
|
9
9
|
'root' => "#{ENV['HOME']}/.chit"
|
@@ -55,15 +55,21 @@ module Chit
|
|
55
55
|
|
56
56
|
@fullpath = File.join(working_dir, "#{@sheet}.yml")
|
57
57
|
|
58
|
-
add(sheet_file) and return if args.delete('--add')
|
59
|
-
edit(sheet_file) and return if args.delete('--edit')
|
58
|
+
add(sheet_file) and return if (args.delete('--add')||args.delete('-a'))
|
59
|
+
edit(sheet_file) and return if (args.delete('--edit')||args.delete('-e'))
|
60
|
+
search and return if (args.delete('--search')||args.delete('-s'))
|
60
61
|
true
|
61
62
|
end
|
62
63
|
|
63
64
|
def list_all
|
64
|
-
|
65
|
-
|
65
|
+
puts all_sheets.sort.join("\n")
|
66
|
+
end
|
67
|
+
|
68
|
+
def search
|
69
|
+
reg = Regexp.compile("^#{@sheet}")
|
70
|
+
files = all_sheets.select {|sheet| sheet =~ reg }
|
66
71
|
puts files.sort.join("\n")
|
72
|
+
true
|
67
73
|
end
|
68
74
|
|
69
75
|
def sheet_file
|
@@ -192,23 +198,32 @@ module Chit
|
|
192
198
|
@git.add
|
193
199
|
@git.commit_all("-")
|
194
200
|
end
|
201
|
+
true
|
195
202
|
end
|
196
203
|
|
197
|
-
|
198
|
-
|
199
|
-
|
204
|
+
private
|
205
|
+
|
206
|
+
def editor
|
207
|
+
ENV['VISUAL'] || ENV['EDITOR'] || "vim"
|
208
|
+
end
|
209
|
+
|
210
|
+
def write_to_tempfile(title, body = nil)
|
211
|
+
title = title.gsub(/\/|::/, '-')
|
212
|
+
# god dammit i hate tempfile, this is so messy but i think it's
|
213
|
+
# the only way.
|
214
|
+
tempfile = Tempfile.new(title + '.cheat')
|
215
|
+
tempfile.write(body) if body
|
216
|
+
tempfile.close
|
217
|
+
system "#{editor} #{tempfile.path}"
|
218
|
+
tempfile.open
|
219
|
+
body = tempfile.read
|
220
|
+
tempfile.close
|
221
|
+
body
|
222
|
+
end
|
223
|
+
|
224
|
+
def all_sheets
|
225
|
+
@git.ls_files.to_a.map {|f|
|
226
|
+
f[0][0..((f[0].rindex('.')||0) - 1)]}
|
227
|
+
end
|
200
228
|
|
201
|
-
def write_to_tempfile(title, body = nil)
|
202
|
-
title = title.gsub(/\/|::/, '-')
|
203
|
-
# god dammit i hate tempfile, this is so messy but i think it's
|
204
|
-
# the only way.
|
205
|
-
tempfile = Tempfile.new(title + '.cheat')
|
206
|
-
tempfile.write(body) if body
|
207
|
-
tempfile.close
|
208
|
-
system "#{editor} #{tempfile.path}"
|
209
|
-
tempfile.open
|
210
|
-
body = tempfile.read
|
211
|
-
tempfile.close
|
212
|
-
body
|
213
|
-
end
|
214
229
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nowa-chit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robin Lu
|
@@ -34,6 +34,7 @@ dependencies:
|
|
34
34
|
description: Chit is A command line tool for cheat sheet utility based on git.
|
35
35
|
email:
|
36
36
|
- iamawalrus@gmail.com
|
37
|
+
- nowazhu@gmail.com
|
37
38
|
executables:
|
38
39
|
- chit
|
39
40
|
extensions: []
|