cnote 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54afc4391700ef178bc0ed861e49cdbcfe30cc73
4
- data.tar.gz: a5aab3d03e17f4ae079f137e024ba6c6bf733373
3
+ metadata.gz: 0f576ae8756a70983786ca2c5fd60e057103e520
4
+ data.tar.gz: 4f8d882001c3402892ee357a925e04b491bd2a52
5
5
  SHA512:
6
- metadata.gz: c881765e7c0c228e0e01f9c12c56ba06f9341eb0c9e184fff491d6422f61485e23a0b289f34c2f92e10a22e22ae6fae3d8959733b33a26a29f4abd3116b8854b
7
- data.tar.gz: 624d176e63393ffa9e5f91124418ecf4780306e7227c14e84d9af043d923ccbda5ae85f5af3d5684244c06acd869efbffd0ee7681991b5738324f1e143b1bb82
6
+ metadata.gz: d50be2e44a608d3f58cbba5d861e16f34086319abbea7e541cf0e08864af389f83fdb8f88e7dd87db1551f228132f3073d9304017220c27998a66b55c9d39dfe
7
+ data.tar.gz: 862a4fe135058318ca4c4014b5bbd9eb8ac4fd03ef11787f8d83f66508d832eef57c1249045fefd01b1fba17c348b2c773d46c6f21e5ce9103aee18ba422a542
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # CNote
2
2
  > CLI notes app for Linux (and probably macOS) ((and maybe Windows Subsystem for Linux)) written in Ruby
3
3
 
4
- CNote is my personal system for managing notes. I wanted something snappy and lightweight that would let me search, tag and edit a folder full of markdown files using just my keyboard and some `vim`mish single-letter commands.
4
+ CNote is my personal system for managing notes. I wanted something snappy and lightweight that would let me search, tag and edit a folder full of markdown files using just my keyboard and some `vim`-ish single-letter commands.
5
5
 
6
6
  ## Installation
7
7
 
@@ -11,7 +11,7 @@ First of all, make sure you have a recent version of Ruby installed (including R
11
11
 
12
12
  ## Usage
13
13
 
14
- CNote will be installed as a command on your machine. To get started, run `cnote`. The first time you run `cnote`, you'll be walked through the basic setup process which will produce a `.cnote.yaml` file within your `$HOME` directory. To skip this, just create the file yourself. Valid options for this file are covered [here](#).
14
+ CNote will be installed as a command on your machine. To get started, run `cnote`. The first time you run `cnote`, you'll be walked through the basic setup process which will produce a `.cnote.yaml` file within your `$HOME` directory. To skip this, just create the file yourself. Valid options for this file are covered [here](#configuration).
15
15
 
16
16
  ```
17
17
  $ cnote
data/cnote.gemspec CHANGED
@@ -25,6 +25,5 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
26
  spec.add_development_dependency "rspec", "~> 3.0"
27
27
 
28
- spec.add_runtime_dependency "awesome_print", "~> 1.8"
29
28
  spec.add_runtime_dependency "colorize", "~> 0.8.1"
30
29
  end
data/lib/cnote/note.rb CHANGED
@@ -19,7 +19,9 @@ class Note
19
19
  @filename = File.basename(path)
20
20
  @path = path
21
21
 
22
- refresh
22
+ File.open(@path, "r") do |file|
23
+ refresh(file.read)
24
+ end
23
25
 
24
26
  @modified = File.mtime(@path) if !@modified
25
27
  @created = @modified if !@created
@@ -27,19 +29,20 @@ class Note
27
29
  @title = "Untitled" if !@title
28
30
  end
29
31
 
30
- def refresh
31
- File.open(@path, "r") do |file|
32
- file.each_line do |line|
33
- line = line.strip
34
- if @meta_regex =~ line
35
- parse_meta($~[1])
36
- elsif !@title
37
- if line != ""
38
- @title = line.gsub(/#|[^a-z0-9\s\.\-]/i, "").strip
39
- end
40
- else
41
- @content << line + "\n"
32
+ def refresh(contents)
33
+ @title = nil
34
+ @content = ''
35
+
36
+ contents.each_line do |line|
37
+ line = line.strip
38
+ if @meta_regex =~ line
39
+ parse_meta($~[1])
40
+ elsif !@title
41
+ if line != ""
42
+ @title = line.gsub(/#|[^a-z0-9\s\.\-]/i, "").strip
42
43
  end
44
+ else
45
+ @content << line + "\n"
43
46
  end
44
47
  end
45
48
  end
@@ -102,7 +105,7 @@ class Note
102
105
  # Leave two empty lines before metadata.
103
106
  contents = contents.lines.slice(0, contents.lines.length - trailing_empty).join("")
104
107
 
105
- contents += "\n\n"
108
+ contents += "\n"
106
109
  contents += "<!--- created: #{@created} -->\n"
107
110
  contents += "<!--- modified: #{@modified} -->\n"
108
111
  contents += "<!--- tags: #{@tags.join(", ")} -->\n"
@@ -110,6 +113,8 @@ class Note
110
113
  File.open(@path, "w") do |file|
111
114
  file.write(contents)
112
115
  end
116
+
117
+ refresh(contents)
113
118
  end
114
119
  end
115
120
  end
data/lib/cnote/notes.rb CHANGED
@@ -1,4 +1,3 @@
1
- require "ap"
2
1
  require "colorize"
3
2
  require "fileutils"
4
3
  require "time"
@@ -7,11 +6,7 @@ require "cnote/note"
7
6
  class Notes
8
7
  def initialize(config)
9
8
  @config = config
10
- @notes = Dir[File.join(@config.note_path, "**", "*")].select do |file|
11
- File.extname(file) == ".md"
12
- end.map do |file|
13
- Note.new(file)
14
- end
9
+ @notes = Dir[File.join(@config.note_path, "**/*.md")].map { |f| Note.new(f) }
15
10
  @filtered = @notes
16
11
  end
17
12
 
@@ -162,8 +157,8 @@ class Notes
162
157
  num = params.first.to_i
163
158
  note = @filtered[num - 1]
164
159
 
165
- if note
166
- if confirm("You're #{"sure".italic} you want to delete note #{num.to_s.bold.white} with title #{note.title.bold.white}?")
160
+ if note and File.exists? note.path
161
+ if confirm("You're #{'sure'.italic} you want to delete note #{num.to_s.bold.white} with title #{note.title.bold.white}?")
167
162
  FileUtils.rm(note.path)
168
163
  @notes.delete(note)
169
164
  @filtered.delete(note)
@@ -179,12 +174,15 @@ class Notes
179
174
  def peek(params)
180
175
  note = @filtered[params.first.to_i - 1]
181
176
  if note
177
+ lines = note.content.lines
182
178
  puts
183
179
  puts "-" * 40
184
180
  puts note.title.bold.white
185
- puts note.content.split("\n").slice(0, 10)
186
- puts
187
- puts "... (cont'd) ...".italic.gray
181
+ puts lines.slice(0, 15)
182
+ if lines.length > 15
183
+ puts
184
+ puts "(#{lines.length - 15} more line#{'s' if lines.length != 16}...)".italic
185
+ end
188
186
  puts "-" * 40
189
187
  puts
190
188
  else
@@ -281,7 +279,7 @@ class Notes
281
279
  tags = note.tags.map { |tag| tag.yellow }
282
280
  puts " tags: " + "[#{tags.join('] [')}]"
283
281
  else
284
- puts " <no tags>".gray
282
+ puts " <no tags>"
285
283
  end
286
284
  puts " modified: " + note.modified.strftime("%a, %b %e %Y, %l:%M%P").italic
287
285
  puts " created: " + note.created.strftime("%a, %b %e %Y, %l:%M%P").italic
data/lib/cnote/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cnote
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/cnote.rb CHANGED
@@ -3,10 +3,6 @@ require "cnote/config"
3
3
  require "cnote/notes"
4
4
  require "cnote/version"
5
5
 
6
- # module Cnote
7
- # Your code goes here...
8
- # end
9
-
10
6
  config = Config.new("~/.cnote.yaml")
11
7
 
12
8
  # Start REPL
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cnote
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
  - Tony McCoy
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
- - !ruby/object:Gem::Dependency
56
- name: awesome_print
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.8'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.8'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: colorize
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -102,8 +88,6 @@ files:
102
88
  - classes/notes.rb
103
89
  - cnote.gemspec
104
90
  - exe/cnote
105
- - gems.locked
106
- - gems.rb
107
91
  - lib/cnote.rb
108
92
  - lib/cnote/config.rb
109
93
  - lib/cnote/note.rb
data/gems.locked DELETED
@@ -1,14 +0,0 @@
1
- GEM
2
- specs:
3
- awesome_print (1.8.0)
4
- colorize (0.8.1)
5
-
6
- PLATFORMS
7
- ruby
8
-
9
- DEPENDENCIES
10
- awesome_print (~> 1.8)
11
- colorize (~> 0.8.1)
12
-
13
- BUNDLED WITH
14
- 1.15.4
data/gems.rb DELETED
@@ -1,6 +0,0 @@
1
-
2
- # Added at 2017-09-09 01:27:23 -0700 by tony:
3
- gem "awesome_print", "~> 1.8"
4
-
5
- # Added at 2017-09-09 03:13:22 -0700 by tony:
6
- gem "colorize", "~> 0.8.1"