peter-notes 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24dcc4e40cda3fd1cc04a6a571f7b545a190e36f
4
- data.tar.gz: 54e4dc169ec29966017bd43774180c47ee99e26c
3
+ metadata.gz: f1a21b583cef933540e0039eb042232c65f5dab7
4
+ data.tar.gz: 6fd4913e95b32a3096584cab526bdeae7578831c
5
5
  SHA512:
6
- metadata.gz: 0417a4fbc402adefacced99f1360b078b7dc69db2dad9ac3dfabff85b13cc8fff2a20b5cf6e14623503ab684efff724557bda5764ff049906d3d8df6e04be19b
7
- data.tar.gz: 9a902e2d34c5aaeb462f921b8ff0bedbd0b4bf0f0af075232903221bf64dd52dbd793ceaff7488100dc85c750318fa784562b9d5d307073fe2566287bbbd7cc2
6
+ metadata.gz: b6d7da6e4bff5e00f305bd55b21589519ecc843c37c5639c5a2f2bbec28f2e3e7ce5e3cc1ddee3c1c49740f88a51f206de37a173726b1588b3188ebee9715d23
7
+ data.tar.gz: dbc24e02be65b36e18873daf20b6e4d96f21f12b4c84badbc2530b34153d4b1479a304a137ac50694e7b2725d61f38762363d6c8b7496b4780a0145f5eff49a5
data/README.md CHANGED
@@ -1,22 +1,12 @@
1
- <div>
2
- <a href="https://travis-ci.org/fonsecapeter/peter-notes">
3
- <img src="https://travis-ci.org/fonsecapeter/peter-notes.svg?branch=master"></img>
4
- </a>
5
- </div>
1
+ # Peter Notes <a href="https://travis-ci.org/fonsecapeter/peter-notes"><img src="https://travis-ci.org/fonsecapeter/peter-notes.svg?branch=master"></img></a>
6
2
 
7
- # Peter Notes
3
+ Manage your notes from the console. ([ruby gem](https://rubygems.org/gems/peter-notes/))
8
4
 
9
- Manage your notes from the console.
5
+ If you're like me, you spend most of your computing time in a terminal. You have a text-editor that's heavily customized to your liking, and you wish you could read and write everything with it. Naturally, when it comes time to ditch the paper note-pad, you refuse to to use the more popular gui-driven apps.
10
6
 
11
- If you're like me, you spend most of your computing time in a terminal. You have a text-editor that's heavily customized to your liking, and you wish you could read and write everything with it. Naturally, you feel the same about your notes and, when it comes time to ditch the note-pad, you refuse to to use the more popular gui-driven apps.
7
+ But when you start looking for a console-based notes framework you're blinded by crazy features and unwilling to learn a new tool. You've also already started keeping your notes in some text files and don't want to have to start over.
12
8
 
13
- But when you start looking for a console-based notes framework you're blinded by crazy features and unwilling to learn a new tool. You've also already started keeping some text files in a directory and just cd into them all the time. Eventually you write an alias and call it a day.
14
-
15
- That's what I did. I also turned my alias into a bash function and wrote a couple more after I got tired of grepping on my own. At a certain point I got tired of writing bash and migrated to a ruby project. It was probably way more work than learning a new tool but I think it's pretty cool so whatever.
16
-
17
- Anyway, I made this this lightweight tool to do what I wanted it to do, which isn't a lot. It's essentially `cd`, `grep`, `tree`, and `find` wrapped into some nicer syntax with a preferences file to hold the info that you don't want to keep typing. That means it'll stay out of the way and let you choose where you keep your notes, how you organize them, how you track them (if you do), and what editor you use to write them. You can even just point it at your notes and stop cding and grepping into them manually.
18
-
19
- I made it for myself, and mostly packaged it into a ruby gem so I could keep it on all my computers/virtual machines, but if anyone else out there ever uses this, hopefully you like it. Much like Mr. Matsumoto, I think programming should be simple and linguistic, and I feel the same about the console.
9
+ Anyway, I went through the same thing and made this this lightweight tool (originally from some aliases in my bashrc) to do what I wanted it to do, which isn't a lot. But, like ruby, it has a nice interface, and it'll stay out of the way. That means you can choose where you keep your notes, how you organize them, how you track them (if you do), and what editor you use to write them. So if you already have your own notes, you can just point `peter-notes` at them (see preferences below) and start using worlds simplest (and coolest) notes-manager.
20
10
 
21
11
  ## Installation
22
12
 
@@ -30,7 +20,7 @@ But you can do more!
30
20
 
31
21
  Lets assume you have the following notes:
32
22
 
33
- /Users/peter/Notes/
23
+ ~/Notes
34
24
  |-- projects
35
25
  | |-- python
36
26
  | | +-- jarbs.txt
@@ -39,24 +29,24 @@ Lets assume you have the following notes:
39
29
  +-- other
40
30
  +-- motorcycle.txt
41
31
 
42
- Most of the time you just want to open them. To do that, just type `notes`. You can specify your text editor and where your notes are in `~/peter-notes.yaml` (see the preferences section below).
32
+ Most of the time you just want to open them. To do that, type `notes`. You can specify your text editor and where your notes are in `~/peter-notes.yaml` (see the preferences section below). This will basically `cd` into your notes and open them all with `YOUR-EDITOR ./`. Some editors don't super work when you open a directory, but I use vim with [NerdTree](https://github.com/scrooloose/nerdtree) and I'm sure other editors have similar plugins.
43
33
 
44
34
  If you want to open a specific note, you can pass in a `file-glob` to specify which notes you want to open. If you think a file glob is what happens when you spill coffee on your computer, just check this out [this](http://tldp.org/LDP/abs/html/globbingref.html) or google it (hint, you use it in bash a lot, like, when you `ls *.rb`).
45
35
 
46
- If you just want to open `other/motorcycle.txt` you can run `notes "other/motorcycle.txt"`. But that's kind of lame, so you could also fo `notes "motorcycle.txt"`, or even `notes "moto*"`. If you're feeling extra crazy, you could even get away with `m*` in this case, basically if you pass a glob in, `peter-notes` will just take the first match in `--find` (see below) and open that.
36
+ Now, lets say you want to open `other/motorcycle.txt`. You could run `notes "other/motorcycle.txt"`. But that's kind of lame, so you could also do `notes "motorcycle.txt"`, or even `notes "moto*"`. If you're feeling extra crazy, you could get away with `m*` here. Basically if you pass a glob in, `peter-notes` will just take the first match from `--find` (see below) and open that.
47
37
 
48
38
  If you wanted to open all notes under `projects/` you could also use this same idea and run `notes "projects"`.
49
39
 
50
40
  That's like what 90% of what you'll ever need and no crazy macros or flags to memorize. Not bad right? Well not all flags are bad, in fact, you also get some super-helpful optional ones for the other 10%:
51
41
 
52
42
  - `-s`, `--search REGEX`:
53
- Search within notes for text matching the specified `REGEX`. If you haven't guessed, this is the [grep](http://linuxcommand.org/man_pages/grep1.html) part. Specifically, it's running `grep -r YOUR-NOTES-DIR -e REGEX`.
43
+ Search within notes for text matching the specified `REGEX`. This isn't magic, it's just [grep](http://linuxcommand.org/man_pages/grep1.html). Specifically, it's running `grep -r YOUR-NOTES-DIR -e REGEX`.
54
44
 
55
45
  - `-f`, `--find FILE-GLOB`:
56
46
  Seach for notes that match the specified file-glob. This one's running [find](http://linuxcommand.org/man_pages/find1.html) -- `find YOUR-NOTES-DIR -name FILE-GLOB`. It's a little more than that though, this will be fuzzy in that you can add some path info to your glob. For example, if you ran `notes --find "projects/*.txt"`, you'd get back both `projects/python/jarbs.txt` and `projects/ruby/peter_notes.txt`. So it's better than just find. A little.
57
47
 
58
48
  - `-l`, `--list [PATH]`:
59
- List all notes or, if a `PATH` is specified, list notes within the specified path. Bet you thought this was running `ls -r`, well it's actually running [tree](http://linuxcommand.org/man_pages/tree1.html) because it's much cooler -- `tree YOUR-NOTES-DIR/PATH`.
49
+ List all notes or, if a `PATH` is specified, list notes within the specified path. Bet you thought this was running `ls -R`, well it's actually running [tree](http://linuxcommand.org/man_pages/tree1.html) because it's much cooler -- `tree YOUR-NOTES-DIR/PATH`.
60
50
 
61
51
  Oh yeah, make sure your terminal has `grep`, `find`, and `tree`. It should, but depends on how crazy your 'gear' is. Also, this is a cli tool, don't try to import it into some ruby source code.
62
52
 
@@ -68,7 +58,7 @@ Preferences are saved in `~/.peter-notes.yml`. There are just 2 options that you
68
58
  The editor of your choice. This value will get passed to bash so make sure you use the exact name your terminal will understand.
69
59
 
70
60
  **Possible Values**: `[vim, subl, atom, emacs, nano]`
71
- (more?) I haven't tested others and dont know which work well when opening a directory. For vim I use the NerdTree plugin.
61
+ (more?) I haven't tested others but I know they're out there.
72
62
 
73
63
  **Default Value**: `vim`
74
64
 
@@ -90,10 +80,12 @@ notes_dir: /home/peter/Notes
90
80
 
91
81
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/test` to run the tests. You can also run `bin/console` for an interactive [pry](http://pryrepl.org/) prompt.
92
82
 
93
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
94
-
95
83
  If you're changing the man page, generate roff and html files with `bin/ronn`.
96
84
 
85
+ To install this gem onto your local machine, run `bundle exec rake install`.
86
+
87
+ To release a new version, first update the version number in `lib/peter_notes/version.rb`, then build the gem with `bundle exec rake build`. Now you can and push the `.gem` file to [rubygems.org](https://rubygems.org) with `gem push pkg/peter-notes-VERSION.gem`.
88
+
97
89
  ## Contributing
98
90
 
99
91
  Bug reports and pull requests are welcome on GitHub at https://github.com/fonsecapeter/peter-notes. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -104,4 +96,4 @@ The gem is available as open source under the terms of the [MIT License](http://
104
96
 
105
97
  ## Code of Conduct
106
98
 
107
- Everyone interacting in the peter-notes projects codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fonsecapeter/peter-notes/blob/master/CODE_OF_CONDUCT.md).
99
+ Everyone interacting in the peter-notes project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fonsecapeter/peter-notes/blob/master/CODE_OF_CONDUCT.md).
data/bin/notes CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ $LOAD_PATH << 'lib'
2
3
 
3
4
  require_relative '../lib/peter_notes/peter_notes.rb'
4
5
  run
data/bin/test CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env bash
2
- rake spec
2
+ bundle exec rake spec
@@ -1,4 +1,5 @@
1
1
  require 'optparse'
2
+ require 'models/preferences'
2
3
 
3
4
  class ConsoleApp
4
5
  def run
@@ -12,7 +13,7 @@ class ConsoleApp
12
13
  self.search(regex)
13
14
  exit(0)
14
15
  end
15
- opts.on('-f', '--find FILE-GLOB', 'Find notes that match FILE-GLOB') do |glob|
16
+ opts.on('-f', '--find FILE-GLOB', 'Find notes that fuzzily match FILE-GLOB') do |glob|
16
17
  puts(self.find(glob))
17
18
  exit(0)
18
19
  end
@@ -24,6 +25,16 @@ class ConsoleApp
24
25
  puts(opts)
25
26
  exit(0)
26
27
  end
28
+ opts.on('-v', '--version', 'Show version') do
29
+ puts(self.version)
30
+ exit(0)
31
+ end
32
+ opts.separator('')
33
+ opts.separator("Preferences are loaded from #{Preferences.prefs_file} and should look like:")
34
+ opts.separator(Preferences.defaults_yaml)
35
+
36
+ opts.separator('')
37
+ opts.separator("Documentation at https://github.com/fonsecapeter/peter-notes or man peter-notes")
27
38
  end.parse!
28
39
  self.on_run(arg)
29
40
  end
data/lib/models/notes.rb CHANGED
@@ -1,5 +1,6 @@
1
- require_relative 'console_app'
2
- require_relative 'preferences'
1
+ require 'models/console_app'
2
+ require 'models/preferences'
3
+ require 'peter_notes/version'
3
4
 
4
5
  class Notes < ConsoleApp
5
6
  attr_reader :editor, :notes_dir
@@ -14,12 +15,11 @@ class Notes < ConsoleApp
14
15
  end
15
16
 
16
17
  def find(glob)
17
- parsed = glob.split('/')
18
- glob_terminus = parsed.pop
19
- glob_path = parsed.join('/')
18
+ glob_path, glob_terminus = File.split(glob)
19
+ glob_path.gsub!(File::SEPARATOR, '.*')
20
20
  cmd = "find \"#{@notes_dir}\" -name \"#{glob_terminus}\""
21
- if glob_path != ''
22
- cmd += " | grep \"#{glob_path}\""
21
+ if glob_path != '.' # FILE::split breaks out . for bare file names
22
+ cmd += " | grep -e \"#{glob_path}\""
23
23
  end
24
24
  found = `#{cmd}`
25
25
  return found.split
@@ -36,13 +36,18 @@ class Notes < ConsoleApp
36
36
  end
37
37
 
38
38
  def list(path)
39
- system("tree #{@notes_dir}/#{path}")
39
+ notes_path = File.join(@notes_dir, path)
40
+ system("tree #{notes_path}")
40
41
  end
41
42
 
42
43
  def on_run(glob)
43
44
  open_notes(glob)
44
45
  end
45
46
 
47
+ def version
48
+ return PeterNotes::VERSION
49
+ end
50
+
46
51
  private
47
52
 
48
53
  def enter_dir
@@ -18,6 +18,10 @@ class Preferences
18
18
  @@prefs_file
19
19
  end
20
20
 
21
+ def self.defaults_yaml
22
+ @@defaults.to_yaml
23
+ end
24
+
21
25
  def initialize(prefs=nil)
22
26
  @preferences = prefs || load_preferences
23
27
  @preferences[:notes_dir] = File.expand_path(@preferences[:notes_dir])
@@ -26,7 +30,7 @@ class Preferences
26
30
  end
27
31
 
28
32
  def self.write_yaml_defaults
29
- File.write(@@prefs_file, @@defaults.to_yaml)
33
+ File.write(@@prefs_file, self.defaults_yaml)
30
34
  end
31
35
 
32
36
  private
@@ -1,6 +1,6 @@
1
- require_relative "version"
2
- require_relative '../models/preferences'
3
- require_relative '../models/notes'
1
+ require "peter_notes/version"
2
+ require 'models/preferences'
3
+ require 'models/notes'
4
4
 
5
5
  def run
6
6
  preferences = Preferences.new
@@ -1,3 +1,3 @@
1
1
  module PeterNotes
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
data/peter-notes.gemspec CHANGED
@@ -1,30 +1,39 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
2
+ lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "peter_notes/version"
4
+ require 'peter_notes/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "peter-notes"
7
+ spec.name = 'peter-notes'
8
8
  spec.version = PeterNotes::VERSION
9
- spec.authors = ["Peter Fonseca"]
10
- spec.email = ["peter.nfonseca@gmail.com"]
9
+ spec.authors = ['Peter Fonseca']
10
+ spec.email = ['peter.nfonseca@gmail.com']
11
11
 
12
12
  spec.summary = %q{Lightweight notes manager}
13
- spec.description = %q{Manage notes with this minimal gem. You can choose your editor and organize your notes however you choose. If you want to track your notes, this gem will stay out of the way. It's a cli tool, don't try to import it in a ruby file.}
14
- spec.homepage = "https://github.com/fonsecapeter/peter-notes"
15
- spec.license = "MIT"
13
+ spec.description = %q{Manage notes from the console with this minimal gem.
14
+
15
+ If you're like me, you spend most of your computing time in a terminal. You have a text-editor that's heavily customized to your liking, and you wish you could read and write everything with it. Naturally, when it comes time to ditch the paper note-pad, you refuse to to use the more popular gui-driven apps.
16
+
17
+ But when you start looking for a console-based notes framework you're blinded by crazy features and unwilling to learn a new tool. You've also already started keeping your notes in some text files and don't want to have to start over.
18
+
19
+ Anyway, I went through the same thing and made this this lightweight tool (originally from some aliases in my bashrc) to do what I wanted it to do, which isn't a lot. But, like ruby, it has a nice interface, and it'll stay out of the way. That means you can choose where you keep your notes, how you organize them, how you track them (if you do), and what editor you use to write them. So if you already have your own notes, you can just point `peter-notes` at them (see preferences below) and start using worlds simplest (and coolest) notes-manager.
20
+
21
+ This is a cli tool, don't try to import it into some ruby source code.}
22
+ spec.homepage = 'https://github.com/fonsecapeter/peter-notes'
23
+ spec.license = 'MIT'
16
24
 
17
25
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
26
  f.match(%r{^(test|spec|features)/})
19
27
  end
20
- spec.bindir = "bin"
21
- spec.executables = ["notes"]
22
- spec.require_paths = ["lib"]
23
-
24
- spec.add_development_dependency "bundler", "~> 1.15"
25
- spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "rspec", "~> 3.0"
27
- spec.add_development_dependency "ronn", "~> 0.7.3"
28
- spec.add_development_dependency "pry", "~> 0.10.4"
29
- spec.add_development_dependency "simplecov-console", "~> 0.4.2"
28
+ spec.bindir = 'bin'
29
+ spec.executables = ['notes']
30
+ spec.require_paths = ['lib']
31
+
32
+ spec.add_runtime_dependency 'manpages', '~> 0.6.1'
33
+ spec.add_development_dependency 'bundler', '~> 1.15'
34
+ spec.add_development_dependency 'pry', '~> 0.10.4'
35
+ spec.add_development_dependency 'rake', '~> 10.0'
36
+ spec.add_development_dependency 'ronn', '~> 0.7.3'
37
+ spec.add_development_dependency 'rspec', '~> 3.0'
38
+ spec.add_development_dependency 'simplecov-console', '~> 0.4.2'
30
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peter-notes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Fonseca
@@ -10,6 +10,20 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2017-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: manpages
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.6.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.6.1
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -25,33 +39,33 @@ dependencies:
25
39
  - !ruby/object:Gem::Version
26
40
  version: '1.15'
27
41
  - !ruby/object:Gem::Dependency
28
- name: rake
42
+ name: pry
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '10.0'
47
+ version: 0.10.4
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '10.0'
54
+ version: 0.10.4
41
55
  - !ruby/object:Gem::Dependency
42
- name: rspec
56
+ name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '3.0'
61
+ version: '10.0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '3.0'
68
+ version: '10.0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: ronn
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -67,19 +81,19 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: 0.7.3
69
83
  - !ruby/object:Gem::Dependency
70
- name: pry
84
+ name: rspec
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: 0.10.4
89
+ version: '3.0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: 0.10.4
96
+ version: '3.0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: simplecov-console
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -94,9 +108,16 @@ dependencies:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
110
  version: 0.4.2
97
- description: Manage notes with this minimal gem. You can choose your editor and organize
98
- your notes however you choose. If you want to track your notes, this gem will stay
99
- out of the way. It's a cli tool, don't try to import it in a ruby file.
111
+ description: |-
112
+ Manage notes from the console with this minimal gem.
113
+
114
+ If you're like me, you spend most of your computing time in a terminal. You have a text-editor that's heavily customized to your liking, and you wish you could read and write everything with it. Naturally, when it comes time to ditch the paper note-pad, you refuse to to use the more popular gui-driven apps.
115
+
116
+ But when you start looking for a console-based notes framework you're blinded by crazy features and unwilling to learn a new tool. You've also already started keeping your notes in some text files and don't want to have to start over.
117
+
118
+ Anyway, I went through the same thing and made this this lightweight tool (originally from some aliases in my bashrc) to do what I wanted it to do, which isn't a lot. But, like ruby, it has a nice interface, and it'll stay out of the way. That means you can choose where you keep your notes, how you organize them, how you track them (if you do), and what editor you use to write them. So if you already have your own notes, you can just point `peter-notes` at them (see preferences below) and start using worlds simplest (and coolest) notes-manager.
119
+
120
+ This is a cli tool, don't try to import it into some ruby source code.
100
121
  email:
101
122
  - peter.nfonseca@gmail.com
102
123
  executables: