fuzzy_notes 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1 +1,36 @@
1
1
  README
2
+
3
+ fuzzy_notes is a command line note manager with some cool features:
4
+
5
+ 1. Emacs/Vim/Any CLI text editor support
6
+ 2. Fuzzy path search and full text search across one or more note directories
7
+ 3. OpenSSL encryption
8
+ 4. Evernote integration (coming soon...)
9
+
10
+
11
+ CONFIG
12
+
13
+ A config file is not required if you're ok with fuzzy_note's defaults settings
14
+ outlined below:
15
+
16
+ :note_paths:
17
+ - ~/notes
18
+ :verbose: false
19
+ :full_text_search: false
20
+
21
+ fuzzy_notes looks for a ~/.fuzzy_notes config file or the -c option and
22
+ overwrites the defaults with the contents of the YAML file specified.
23
+
24
+
25
+ USAGE
26
+
27
+ fnote [options] [keyword1, keyword2...]
28
+ -c, --config [CONFIG] Specify config file
29
+ -p, --print Dump matching notes to stdout
30
+ -l, --list List statistics for matching notes
31
+ -i, --info Alias for 'list'
32
+ -s, --search Perform a full text search when matching notes
33
+ -v, --verbose Enable debug output
34
+ -e, --encrypt Encrypt matching notes
35
+ -d, --decrypt Decrypt matching notes
36
+ -h, --help Show usage
data/TODO CHANGED
@@ -1,2 +1,3 @@
1
- TODO:
2
- -Evernote support
1
+ TODO
2
+ -Evernote integration
3
+ -On the fly decryption/editing/re-encryption
data/bin/fnote CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # test without installing gem
4
- #$LOAD_PATH.unshift "#{File.dirname(File.expand_path(__FILE__))}/../lib/"
4
+ $LOAD_PATH.unshift "#{File.dirname(File.expand_path(__FILE__))}/../lib/"
5
5
 
6
6
  require 'optparse'
7
7
  require 'yaml'
@@ -5,7 +5,7 @@ class FuzzyNotes::Cipher
5
5
  private_class_method :new
6
6
 
7
7
  def self.apply_cipher(file_paths, decrypt = false)
8
- extension, action = decrypt ? ['.txt', 'dec'] : ['.enc', 'enc']
8
+ extension, action = decrypt ? ['.txt', :dec] : ['.enc', :enc]
9
9
  password = get_password
10
10
  cipher = Gibberish::AES.new(password)
11
11
 
@@ -16,12 +16,12 @@ class FuzzyNotes::Cipher
16
16
 
17
17
  begin
18
18
  ciphertext = cipher.send(action, File.read(path))
19
- log.debug "[debug] writing encrypted content to: #{pathname}/#{filename}#{extension}"
19
+ log.debug "writing #{decrypt ? 'un' : ''}encrypted content to: #{pathname}/#{filename}#{extension}"
20
20
  File.open("#{pathname}/#{filename}#{extension}", 'w') { |f| f << ciphertext }
21
- log.debug "[debug] deleting unencrypted file: #{path}"
21
+ log.debug "deleting #{decrypt ? '' : 'un'}encrypted file: #{path}"
22
22
  File.delete(path)
23
23
  rescue OpenSSL::Cipher::CipherError => e
24
- log.error "ERROR: #{e}"
24
+ log.error e
25
25
  end
26
26
  end
27
27
  end
@@ -30,7 +30,7 @@ class FuzzyNotes::Cipher
30
30
  def self.get_password
31
31
  printf 'Enter password (will not be shown):'
32
32
  `stty -echo`; password = STDIN.gets.strip;`stty echo`; puts
33
- log.debug "[debug] entered password: #{password.inspect}"
33
+ log.debug "entered password: #{password.inspect}"
34
34
  password
35
35
  end
36
36
 
@@ -8,7 +8,7 @@ class FuzzyNotes::FuzzyFinder
8
8
  def self.find(path, params = {})
9
9
  keywords, extensions, search = params.values_at(:keywords, :extensions, :full_text_search)
10
10
  match_proc = method(search ? :full_text_match? : :file_name_match?)
11
- log.debug "[debug] search path: #{path}"
11
+ log.debug "search path: #{path}"
12
12
 
13
13
  all_files, matching_files = [], []
14
14
  Find.find(*path) do |file_path|
@@ -3,14 +3,25 @@ require 'buffered_logger'
3
3
  class FuzzyNotes::Log
4
4
  private_class_method :new
5
5
  LOG_LEVEL = 1
6
+
6
7
 
7
8
  def self.init_log(log_level)
8
- @log = BufferedLogger.new(STDOUT, log_level)
9
+ @log = BufferedLogger.new(STDOUT, log_level || LOG_LEVEL, default_format)
9
10
  end
10
11
 
11
12
  def self.log
12
- @log ||= BufferedLogger.new(STDOUT, LOG_LEVEL)
13
+ @log ||= BufferedLogger.new(STDOUT, LOG_LEVEL, default_format)
13
14
  end
15
+
16
+ private
17
+
18
+ def self.default_format
19
+ { :debug => "$negative DEBUG: $white %s",
20
+ :info => "$green INFO: $white %s",
21
+ :warn => "$yellow WARNING: $white %s",
22
+ :error => "$red ERROR: $white %s" }
23
+ end
24
+
14
25
  end
15
26
 
16
27
 
@@ -16,10 +16,10 @@ attr_reader :matching_notes, :all_notes
16
16
  def initialize(params = {})
17
17
  parse_init_params(params)
18
18
  FuzzyNotes::Log.init_log(@log_level)
19
- log.debug "[debug] init attributes: \n#{attributes}"
19
+ log.debug "init attributes: \n#{attributes}"
20
20
 
21
21
  unless note_paths_valid?
22
- log.error "ERROR: no valid note paths found, exiting"
22
+ log.error "no valid note paths found, exiting"
23
23
  exit
24
24
  end
25
25
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuzzy_notes
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alex Skryl
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-24 00:00:00 -05:00
18
+ date: 2011-07-19 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -55,11 +55,11 @@ extensions: []
55
55
  extra_rdoc_files: []
56
56
 
57
57
  files:
58
- - lib/fuzzy_notes.rb
59
- - lib/fuzzy_notes/logger.rb
60
58
  - lib/fuzzy_notes/cipher.rb
61
- - lib/fuzzy_notes/notes.rb
62
59
  - lib/fuzzy_notes/fuzzy_finder.rb
60
+ - lib/fuzzy_notes/logger.rb
61
+ - lib/fuzzy_notes/notes.rb
62
+ - lib/fuzzy_notes.rb
63
63
  - bin/fnote
64
64
  - README
65
65
  - TODO