dotnotes 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +28 -0
- data/Rakefile +2 -0
- data/bin/note +18 -0
- data/dotnotes.gemspec +23 -0
- data/lib/dotnotes.rb +102 -0
- data/lib/dotnotes/version.rb +3 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3fc67f4261b461d0848d5ab43edfed6789d2fde3
|
4
|
+
data.tar.gz: cc1dd156a7c4cd5a9a23624bff96be73ddaeb167
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f12d6f86ddb54ea41430d8424311d0b3e71b2ac2db92593f4357892597abc59a87407d06912be492a714905f3c41eab4167f7372caeec9745d14300d97b03076
|
7
|
+
data.tar.gz: b961658fdb44bbb69f4161db3b22ca97f7d93258b27b5b07d119a8c064a83f98242473010606f7d2561b049de1ea5d40e7aef53e9536e7bf77f1edb0b295ca4b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Radu-Bogdan Croitoru
|
2
|
+
|
3
|
+
MIT License
|
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,28 @@
|
|
1
|
+
# .notes
|
2
|
+
|
3
|
+
A CRUD note library. It will make a directory `.notes` in your HOME.
|
4
|
+
You can create, read, update and destroy notes using your terminal.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Install it yourself as:
|
9
|
+
|
10
|
+
$ gem install dotnotes
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
note new {filename} # Create a new note with filename
|
15
|
+
note show {filename} # Display a note
|
16
|
+
note edit {filename} # Edit a note
|
17
|
+
note delete {filename} # Delete a note
|
18
|
+
note list # List all notes
|
19
|
+
note find {keyword} # Check which files contain the keyword
|
20
|
+
note help # Display this help
|
21
|
+
|
22
|
+
## Contributing
|
23
|
+
|
24
|
+
1. Fork it ( https://github.com/radubogdan/dotnotes/fork )
|
25
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
26
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
27
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
28
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/note
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'dotnotes'
|
4
|
+
|
5
|
+
note = Dotnotes::Application.new
|
6
|
+
|
7
|
+
command = ARGV.shift
|
8
|
+
filename = ARGV.shift
|
9
|
+
|
10
|
+
begin
|
11
|
+
note.send(command, *filename)
|
12
|
+
rescue NoMethodError, TypeError, ArgumentError
|
13
|
+
note.help
|
14
|
+
rescue NoteAlreadyExist
|
15
|
+
puts "The note already exist"
|
16
|
+
rescue NoteNotExist
|
17
|
+
puts "The note doesn't exist"
|
18
|
+
end
|
data/dotnotes.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'dotnotes/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "dotnotes"
|
8
|
+
spec.version = Dotnotes::VERSION
|
9
|
+
spec.authors = ["Radu-Bogdan Croitoru"]
|
10
|
+
spec.email = ["croitoruradubogdan@gmail.com"]
|
11
|
+
spec.summary = %q{Create notes from your terminal.}
|
12
|
+
spec.description = %q{Simple CLI Application to create and edit notes directly from terminal.}
|
13
|
+
spec.homepage = "https://github.com/radubogdan/dotnotes"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
data/lib/dotnotes.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
require "dotnotes/version"
|
2
|
+
|
3
|
+
# Don't overwrite default Exceptions but use them
|
4
|
+
class NoteAlreadyExist < StandardError; end
|
5
|
+
class NoteNotExist < StandardError; end
|
6
|
+
|
7
|
+
module Dotnotes
|
8
|
+
class Application
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@notes_path = ENV['HOME'] + '/.notes'
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialized? p={}
|
15
|
+
path = @notes_path + "/" + p[:file].to_s
|
16
|
+
File.exists?(path)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Create a new note in notes path
|
20
|
+
# filename is the name of the note
|
21
|
+
#
|
22
|
+
# @example
|
23
|
+
# begin
|
24
|
+
# note.new(name)
|
25
|
+
# rescue NoteAlreadyExist
|
26
|
+
# puts "the note already exist
|
27
|
+
# rescue UninitializedNotesPath
|
28
|
+
# puts "note.init must be run first"
|
29
|
+
# end
|
30
|
+
def new filename
|
31
|
+
Dir.mkdir @notes_path unless initialized?
|
32
|
+
|
33
|
+
if initialized?(file: filename)
|
34
|
+
raise NoteAlreadyExist
|
35
|
+
else
|
36
|
+
file = File.open(@notes_path + "/#{filename}", "w")
|
37
|
+
system("vi #{file.path}")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Display contents of an existing note
|
42
|
+
# filename is the name of the note
|
43
|
+
#
|
44
|
+
# @example
|
45
|
+
# note.show(name)
|
46
|
+
def show filename
|
47
|
+
file_path = @notes_path + "/" + filename
|
48
|
+
system("cat #{file_path}") if initialized?(file: filename)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Edit a note
|
52
|
+
# filename is the name of the note
|
53
|
+
#
|
54
|
+
# @example
|
55
|
+
# note.show(name)
|
56
|
+
def edit filename
|
57
|
+
file_path = @notes_path + "/" + filename
|
58
|
+
if initialized?(file: filename)
|
59
|
+
system("vi #{file_path}")
|
60
|
+
else
|
61
|
+
raise NoteNotExist
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Show all notes
|
66
|
+
def list
|
67
|
+
system("stat #{@notes_path}/* -c \"%y %s %n\"") unless Dir[@notes_path + "/*"].empty?
|
68
|
+
end
|
69
|
+
|
70
|
+
# Delete a note
|
71
|
+
# filename is the name of the note
|
72
|
+
#
|
73
|
+
# @example
|
74
|
+
# note.delete(name)
|
75
|
+
def delete filename
|
76
|
+
file_path = @notes_path + "/" + filename
|
77
|
+
if initialized?(file: filename)
|
78
|
+
system("rm #{file_path}")
|
79
|
+
else
|
80
|
+
raise NoteNotExist
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# Find a keyword in a note
|
85
|
+
def find keyword
|
86
|
+
system("find #{@notes_path} -type f -print0 | xargs -0 grep -li #{keyword}")
|
87
|
+
end
|
88
|
+
|
89
|
+
def help
|
90
|
+
puts ""
|
91
|
+
puts "Commands:"
|
92
|
+
puts " note new {filename} # Create a new note with filename"
|
93
|
+
puts " note show {filename} # Display a note"
|
94
|
+
puts " note edit {filename} # Edit a note"
|
95
|
+
puts " note delete {filename} # Delete a note"
|
96
|
+
puts " note list # List all notes"
|
97
|
+
puts " note find {keyword} # Check which files contain the keyword"
|
98
|
+
puts " note help # Display this help"
|
99
|
+
puts ""
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dotnotes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Radu-Bogdan Croitoru
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Simple CLI Application to create and edit notes directly from terminal.
|
42
|
+
email:
|
43
|
+
- croitoruradubogdan@gmail.com
|
44
|
+
executables:
|
45
|
+
- note
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/note
|
55
|
+
- dotnotes.gemspec
|
56
|
+
- lib/dotnotes.rb
|
57
|
+
- lib/dotnotes/version.rb
|
58
|
+
homepage: https://github.com/radubogdan/dotnotes
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.0.14
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Create notes from your terminal.
|
82
|
+
test_files: []
|