robin-chit 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.txt +39 -13
  2. data/lib/chit.rb +22 -6
  3. metadata +1 -1
data/README.txt CHANGED
@@ -4,29 +4,39 @@ http://github.com/robin/chit
4
4
 
5
5
  == DESCRIPTION:
6
6
 
7
- Chit is A command line tool for cheat sheet utility based on git.
7
+ Chit is a command line cheat sheet utility based on git.
8
8
 
9
9
  == FEATURES:
10
10
 
11
- Chit was inspired by 'cheat' (http://cheat.errtheblog.com/) by Chris Wanstrath. You can use chit to access and manage your cheat sheets easily.
11
+ Chit was inspired by 'cheat' (http://cheat.errtheblog.com/) by Chris Wanstrath. You can use chit to access and manage cheat sheets easily.
12
12
 
13
- There are several differences between 'cheat' and 'chit'. By using chit, besides the wonderful features of 'cheat', you get:
13
+ There are several differences between cheat and chit’. By using chit, besides the wonderful features of cheat’, you get:
14
14
 
15
- 1. Git powered cheat sheet repository. You can specify where you get the sheets and where to share them.
16
- 2. Your own private cheat sheet. Everybody has some project related or smoe cheat sheets which are not mean to public. You can also put them into chit
15
+ 1. Git powered cheat sheet repository. You can specify where you get the sheets and where to share them.
16
+ 2. Your own private cheat sheets. Everybody has some project related or smoe cheat sheets which are not mean to public. You can also put them into chit
17
17
  3. Directory support. You can group cheat sheets by directory now.
18
- 4. one less letter to type.
18
+ 4. One less letter to type.
19
19
 
20
20
  == SYNOPSIS:
21
21
 
22
- To get your cheat sheet:
22
+ To initialize chit repositories
23
+
24
+ $ chit --init
25
+
26
+ This will be run automatically when you run chit for the first time.
27
+
28
+ To get a cheat sheet:
29
+
23
30
  $ chit [cheatsheet]
24
- If it does not exist, a new one will be created and waiting for your editing. Leave it blank and quit the editor if you don't want to add a new one.
31
+
32
+ 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.
25
33
 
26
34
  To edit a cheat sheet, use the --edit switch.
35
+
27
36
  $ cheat [cheatsheet] --edit
28
37
 
29
38
  To add a cheat sheet, use the --add switch.
39
+
30
40
  $ cheat [cheatsheet] --add
31
41
 
32
42
  During editing a cheat sheet, empty the content will get the cheat sheet removed.
@@ -34,17 +44,30 @@ During editing a cheat sheet, empty the content will get the cheat sheet removed
34
44
  A prefix '@' indicates the cheat sheet is in private mode. A private cheat sheet is kept in another repository.
35
45
 
36
46
  To get your private cheat sheet:
47
+
37
48
  $ chit @[cheatsheet]
38
49
 
39
50
  The prefix '@' works the same for both --edit and --add.
40
51
 
41
52
  The cheat sheet can be in a path. For example:
53
+
42
54
  $ chit mysql/select
43
- will get your the cheat sheet 'select' under mysql.
55
+
56
+ will get the cheat sheet 'select' under mysql.
57
+
58
+ To show all the cheat sheets:
59
+
60
+ $ chit [all|show]
61
+
62
+ To show all the private cheat sheets:
63
+
64
+ $ chit @[all|show]
44
65
 
45
66
  == INSTALL:
46
67
 
47
- sudo gem install chit
68
+ sudo gem install robin-chit -s http://gems.github.com
69
+
70
+ chit --init
48
71
 
49
72
  == CONFIGURATION:
50
73
 
@@ -52,9 +75,9 @@ Before run 'chit', you may want to config ~/.chitrc which is a YAML file.
52
75
 
53
76
  * root: local path to store the cheat sheet. By default, it is ~/.chit
54
77
  * main:
55
- ** clone-from: where to get the public cheat sheets. You can use git://github.com/robin/chitsheet.git, which is a snap shoot of http://cheat.errtheblog.com/.
78
+ * clone-from: where to get the public cheat sheets. You can use git://github.com/robin/chitsheet.git, which is a snap shoot of http://cheat.errtheblog.com/.
56
79
  * private:
57
- ** clone-from: where to get the private cheat sheets. If not specified, a new git repository will be init for private cheat sheets.
80
+ * clone-from: where to get the private cheat sheets. If not specified, a new git repository will be init for private cheat sheets.
58
81
 
59
82
  == REQUIREMENTS:
60
83
 
@@ -65,7 +88,7 @@ Before run 'chit', you may want to config ~/.chitrc which is a YAML file.
65
88
 
66
89
  This software is shared by MIT License
67
90
 
68
- Copyright (c) 2008 FIX
91
+ Copyright (c) 2008 Robin Lu
69
92
 
70
93
  Permission is hereby granted, free of charge, to any person obtaining
71
94
  a copy of this software and associated documentation files (the
@@ -87,6 +110,9 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
87
110
  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
88
111
 
89
112
  == BY:
113
+
90
114
  Robin Lu
115
+
91
116
  http://www.robinlu.com
117
+
92
118
  iamawalrus[at]gmail[dot]com
@@ -3,18 +3,29 @@ $:.unshift File.dirname(__FILE__)
3
3
 
4
4
  module Chit
5
5
  extend self
6
- VERSION = '0.0.1'
6
+ VERSION = '0.0.2'
7
7
 
8
8
  defaults = {
9
9
  'root' => "#{ENV['HOME']}/.chit"
10
10
  }
11
11
 
12
- CONFIG = defaults.merge(YAML.load_file("#{ENV['HOME']}/.chitrc"))
12
+ CHITRC = "#{ENV['HOME']}/.chitrc"
13
+
14
+ FileUtils.cp(File.join(File.dirname(__FILE__), "../resources/chitrc"), CHITRC) unless File.exist?(CHITRC)
15
+
16
+ CONFIG = defaults.merge(YAML.load_file(CHITRC))
13
17
 
14
18
  def run(args)
19
+ unless File.exist?(main_path) && File.exist?(private_path)
20
+ return unless init_chit
21
+ end
15
22
  args = args.dup
16
23
 
17
24
  return unless parse_args(args)
25
+
26
+ if %w[sheets all].include? @sheet
27
+ return list_all()
28
+ end
18
29
 
19
30
  unless File.exist?(sheet_file)
20
31
  update
@@ -34,15 +45,23 @@ module Chit
34
45
  @sheet = args.shift || 'chit'
35
46
  is_private = (@sheet =~ /^@(.*)/)
36
47
  @sheet = is_private ? $1 : @sheet
48
+
37
49
  working_dir = is_private ? private_path : main_path
38
- @fullpath = File.join(working_dir, "#{@sheet}.yml")
39
50
  @git = Git.open(working_dir)
51
+
52
+ @fullpath = File.join(working_dir, "#{@sheet}.yml")
40
53
 
41
54
  add(sheet_file) and return if args.delete('--add')
42
55
  edit(sheet_file) and return if args.delete('--edit')
43
56
  true
44
57
  end
45
58
 
59
+ def list_all
60
+ files = @git.ls_files.to_a.map {|f|
61
+ f[0][0..((f[0].rindex('.')||0) - 1)]}
62
+ puts files.sort.join("\n")
63
+ end
64
+
46
65
  def sheet_file
47
66
  @fullpath
48
67
  end
@@ -80,9 +99,6 @@ module Chit
80
99
  end
81
100
 
82
101
  def update
83
- unless File.exist?(main_path)
84
- return unless init_chit
85
- end
86
102
  if CONFIG['main']['clone-from']
87
103
  g = Git.open(main_path)
88
104
  g.pull
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: robin-chit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin Lu