memo 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 (6) hide show
  1. data/README.markdown +7 -0
  2. data/bin/memo +8 -25
  3. data/lib/memo.rb +1 -0
  4. data/lib/memo/base.rb +33 -0
  5. metadata +7 -5
  6. data/README +0 -1
@@ -0,0 +1,7 @@
1
+ # Memo
2
+
3
+ Memo is a way to store and review notes or other snippets of information in a simple, useful way.
4
+
5
+ ## INSTALLATION
6
+
7
+ $ gem install memo
data/bin/memo CHANGED
@@ -1,31 +1,14 @@
1
- #!/usr/bin/ruby
1
+ #!/usr/bin/env ruby
2
2
 
3
- MEMO_FILE = File.join(ENV['HOME'], '.memo/memos')
3
+ require File.dirname(__FILE__) + '/../lib/memo'
4
4
 
5
- unless File.exists?(MEMO_FILE)
6
- unless File.exists? File.join(ENV['HOME'], '.memo')
7
- Dir.mkdir(File.join(ENV['HOME'], '.memo'))
8
- File.new(MEMO_FILE, 'w+')
9
- end
10
- end
11
-
12
- def push(arg)
13
- File.open(MEMO_FILE,'a') do |f|
14
- f.puts arg
15
- end
16
- end
17
-
18
- def pop
19
- File.open(MEMO_FILE,'r') do |f|
20
- f.readlines.reverse.each do |line|
21
- print line
22
- STDIN.readline
23
- end
24
- end
25
- end
5
+ memo = Memo::Base.new
26
6
 
27
7
  if (arg = ARGV.shift)
28
- push arg
8
+ memo.push arg
29
9
  else
30
- pop
10
+ while m = memo.pop
11
+ puts m
12
+ STDIN.readline
13
+ end
31
14
  end
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + '/memo/base'
@@ -0,0 +1,33 @@
1
+ module Memo
2
+ class Base
3
+ def initialize
4
+ home = ENV['HOME']
5
+ memo_dir = File.join(home, '.memo')
6
+ @memo_file = File.join(home, '.memo/memos')
7
+ @memo_stack = File.open(@memo_file, 'r').readlines
8
+
9
+ create_memo_file!
10
+ end
11
+
12
+ def push(arg)
13
+ File.open(@memo_file,'a') do |f|
14
+ f.puts arg
15
+ end
16
+ end
17
+
18
+ def pop
19
+ @memo_stack.pop
20
+ end
21
+
22
+ private
23
+
24
+ def create_memo_file!
25
+ unless File.exists?(@memo_file)
26
+ unless File.exists?(memo_dir)
27
+ Dir.mkdir memo_dir
28
+ File.new(@memo_file, 'w+')
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Manning
@@ -29,9 +29,11 @@ extra_rdoc_files: []
29
29
 
30
30
  files:
31
31
  - bin/memo
32
- - README
32
+ - lib/memo.rb
33
+ - lib/memo/base.rb
34
+ - README.markdown
33
35
  has_rdoc: true
34
- homepage: ""
36
+ homepage: https://github.com/mattmanning/memo
35
37
  licenses: []
36
38
 
37
39
  post_install_message:
data/README DELETED
@@ -1 +0,0 @@
1
- Readme file