noteable 0.0.2 → 0.0.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 +4 -4
- data/bin/noteable +18 -1
- data/bin/whatsnoteable +6 -0
- data/lib/filepath.rb +19 -0
- data/lib/note.rb +3 -3
- data/lib/noteable.rb +34 -11
- data/lib/view.rb +41 -8
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fbdf3ea4b695379ccc54d452d7e0e3a49147329
|
4
|
+
data.tar.gz: 51ff77fcc8de6e6bf70465d0a5a79aad90315222
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dc02104a98ff7af0f8521a1c7bc4e38d2befa459cb5c9b9651d4d3e5dc687b5378ff29404b79f1d9c1a333a212ab6bc2ec2f1037aadec410b781817899e912f
|
7
|
+
data.tar.gz: bfd3fd8862254e464d98cea6b8ed06d62f2722b170431224bd94522043377982c8c29211c00874c17b45672809f9345f657e353cdb9d8f5c372f06d460158228
|
data/bin/noteable
CHANGED
@@ -4,4 +4,21 @@ require_relative '../lib/noteable'
|
|
4
4
|
|
5
5
|
$pattern = /(.*)(##note##)(.+)(##note##.*)/
|
6
6
|
|
7
|
-
|
7
|
+
# Possible routes
|
8
|
+
routes = {
|
9
|
+
find_all_and_print: [nil],
|
10
|
+
open: [/\d/],
|
11
|
+
help: [/-h/, /--help/],
|
12
|
+
version: [/-v/,/--version/],
|
13
|
+
tag: [/-t/ , /--tag/]
|
14
|
+
}
|
15
|
+
|
16
|
+
# Match route and call controller method
|
17
|
+
routes.each do |method, inputs|
|
18
|
+
if inputs.select { |input| ARGV[0] =~ input }.length > 0
|
19
|
+
NoteAble.send(method, ARGV.join)
|
20
|
+
elsif ARGV.length < 1
|
21
|
+
NoteAble.find_all_and_print
|
22
|
+
break
|
23
|
+
end
|
24
|
+
end
|
data/bin/whatsnoteable
ADDED
data/lib/filepath.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
class FilePath
|
2
|
+
@@count = 0
|
3
|
+
attr_reader :filepath, :id
|
4
|
+
def initialize filepath
|
5
|
+
@id = get_id
|
6
|
+
@filepath = filepath
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_id
|
10
|
+
@id = @@count
|
11
|
+
@@count += 1
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
str = ""
|
16
|
+
str << "#{@id}. "
|
17
|
+
str << "#{@filepath}".rjust(5) + ": "
|
18
|
+
end
|
19
|
+
end
|
data/lib/note.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Note
|
2
|
-
attr_reader :filepath, :note, :line
|
2
|
+
attr_reader :filepath, :note, :line, :id
|
3
3
|
|
4
4
|
def initialize args
|
5
5
|
@filepath = args[:filepath]
|
@@ -8,8 +8,8 @@ class Note
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def to_s
|
11
|
-
str =
|
12
|
-
str << "#{@line}".rjust(5) +
|
11
|
+
str = ""
|
12
|
+
str << "#{@line}".rjust(5) + ": "
|
13
13
|
str << "#{note}"
|
14
14
|
end
|
15
15
|
end
|
data/lib/noteable.rb
CHANGED
@@ -1,31 +1,54 @@
|
|
1
1
|
require_relative 'note'
|
2
|
+
require_relative 'filepath'
|
2
3
|
require_relative 'parser'
|
3
4
|
require_relative 'view'
|
4
5
|
require 'pathname'
|
5
6
|
|
6
7
|
module NoteAble
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
def self.find_all_and_print
|
9
|
+
View.render_page { render_notes group_by_file(parse_files) }
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.open id
|
13
|
+
exec "subl #{parse_files.find { |note| note.filepath.id == id.to_i }.filepath.filepath}"
|
14
|
+
end
|
10
15
|
|
11
|
-
|
16
|
+
private
|
12
17
|
|
13
18
|
def self.parse_files notes = []
|
14
19
|
Dir['**/*'].each do |file|
|
15
|
-
notes << (Parser.parse file).map! { |note|
|
20
|
+
notes << (Parser.parse file).map! { |note| build_note note } unless Pathname.new(file).directory?
|
16
21
|
end
|
22
|
+
filter_empty_notes notes
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.filter_empty_notes notes = []
|
26
|
+
notes.reject! { |file_notes| file_notes.length == 0 }.flatten
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.group_by_file notes
|
30
|
+
notes.group_by { |note| note.filepath }
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.build_note note
|
34
|
+
Note.new note: note[:note], line: note[:line], filepath: FilePath.new(note[:filepath])
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.version args
|
38
|
+
View.version
|
39
|
+
end
|
17
40
|
|
18
|
-
|
41
|
+
def self.help args
|
42
|
+
View.help
|
19
43
|
end
|
20
44
|
|
21
|
-
def self.
|
22
|
-
|
23
|
-
notes.flatten.group_by { |note| note.filepath }
|
45
|
+
def self.tag tag
|
46
|
+
$pattern = /(.*)(##"#{tag}"##)(.+)(##"#{tag}"##.*)/ if /^[a-zA-Z]+$/ =~ tag
|
24
47
|
end
|
25
48
|
|
26
|
-
def self.
|
49
|
+
def self.render_notes notes
|
27
50
|
notes.each do |filepath, notes|
|
28
|
-
View.render_file filepath
|
51
|
+
View.render_file filepath.to_s
|
29
52
|
notes.each { |note| View.render_note note.to_s }
|
30
53
|
end
|
31
54
|
end
|
data/lib/view.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
|
1
3
|
class View
|
2
4
|
@width = 70
|
3
5
|
|
4
6
|
def self.render_page
|
5
7
|
system 'clear'
|
8
|
+
header
|
9
|
+
puts
|
10
|
+
puts
|
11
|
+
puts "To open file in Sublime: '$ notable #'".center(@width).light_magenta
|
6
12
|
puts
|
7
|
-
puts '-' * @width
|
8
|
-
puts 'You have some NoteAble comments in your file...'.center(@width)
|
9
|
-
puts '-' * @width
|
10
|
-
|
11
13
|
yield
|
12
|
-
|
13
14
|
puts
|
14
|
-
puts
|
15
|
-
|
16
|
-
puts '-' * @width
|
15
|
+
puts
|
16
|
+
footer
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.render_file(file)
|
@@ -25,4 +25,37 @@ class View
|
|
25
25
|
str = ' ' * 5 + "#{note}".rjust(5)
|
26
26
|
puts str.length > @width ? str.slice(0, @width - 4) + '...' : str
|
27
27
|
end
|
28
|
+
|
29
|
+
def self.help
|
30
|
+
puts
|
31
|
+
puts ('-' * @width).yellow
|
32
|
+
puts 'The following commands work with NoteAble'.center(@width).green
|
33
|
+
puts ('-' * @width).yellow
|
34
|
+
puts <<-eos
|
35
|
+
-h, --help
|
36
|
+
-s, --settings Alter settings
|
37
|
+
-v, --version Display version
|
38
|
+
-t, --tag TAG Personalize tag message
|
39
|
+
eos
|
40
|
+
puts
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.version
|
44
|
+
puts 'Version: 0.0.3'
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.header
|
48
|
+
puts
|
49
|
+
puts ('-' * @width).yellow
|
50
|
+
puts 'You have some NoteAble comments in your file...'.center(@width).green
|
51
|
+
puts ('-' * @width).yellow
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.footer
|
55
|
+
puts ('-' * @width).yellow
|
56
|
+
puts 'Made with <3.. by Carolyn Phil James Aaron'.center(@width)
|
57
|
+
puts ('-' * @width).yellow
|
58
|
+
puts
|
59
|
+
end
|
60
|
+
|
28
61
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: noteable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carolyn,Phil,James,Aaron
|
@@ -18,6 +18,8 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- bin/noteable
|
21
|
+
- bin/whatsnoteable
|
22
|
+
- lib/filepath.rb
|
21
23
|
- lib/note.rb
|
22
24
|
- lib/noteable.rb
|
23
25
|
- lib/parser.rb
|