noteable 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/noteable +7 -0
- data/lib/note.rb +15 -0
- data/lib/noteable.rb +32 -0
- data/lib/parser.rb +22 -0
- data/lib/view.rb +28 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c8cf71ad4289e2427528c62f709b001e0ef7800d
|
4
|
+
data.tar.gz: 27b014519ef7a6d0d3d639e940cfe1a0fc4b0083
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a43997ade3fce43456abccdf4d5901e5e4f5c84ea0582501e7034317f6d74645627697ba395d951edc2b768093724775a70996feffaead6498899b898cd6d16a
|
7
|
+
data.tar.gz: ba008cec301eb009ff2117945039ecdf70e153d95c7d361e2b4da3e9a3f9589d17b5f4375afb72c16de901b1e168c44d25fab93a5d48b58e013ee4630b172145
|
data/bin/noteable
ADDED
data/lib/note.rb
ADDED
data/lib/noteable.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative 'note'
|
2
|
+
require_relative 'parser'
|
3
|
+
require_relative 'view'
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
module NoteAble
|
7
|
+
def self.find_all_and_print
|
8
|
+
View.render_page { return_notes parse_files }
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def self.parse_files notes = []
|
14
|
+
Dir['**/*'].each do |file|
|
15
|
+
notes << (Parser.parse file).map! { |note| Note.new(note) } unless Pathname.new(file).directory?
|
16
|
+
end
|
17
|
+
|
18
|
+
filter_notes notes
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.filter_notes notes = []
|
22
|
+
notes.reject! { |file_notes| file_notes.length == 0 }
|
23
|
+
notes.flatten.group_by { |note| note.filepath }
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.return_notes notes
|
27
|
+
notes.each do |filepath, notes|
|
28
|
+
View.render_file filepath
|
29
|
+
notes.each { |note| View.render_note note.to_s }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/parser.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Parser
|
2
|
+
def self.parse file_path
|
3
|
+
@file_path = file_path
|
4
|
+
@matches = []
|
5
|
+
parse_matches
|
6
|
+
filter_matches
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def self.parse_matches
|
12
|
+
File.open(@file_path, 'r:ASCII-8BIT').each_with_index do |content, index|
|
13
|
+
@matches << { filepath: @file_path,
|
14
|
+
note: content,
|
15
|
+
line: index } if content =~ $pattern
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.filter_matches
|
20
|
+
@matches.each { |match| match[:note].gsub!($pattern, '\3').strip! }
|
21
|
+
end
|
22
|
+
end
|
data/lib/view.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
class View
|
2
|
+
@width = 70
|
3
|
+
|
4
|
+
def self.render_page
|
5
|
+
system 'clear'
|
6
|
+
puts
|
7
|
+
puts '-' * @width
|
8
|
+
puts 'You have some NoteAble comments in your file...'.center(@width)
|
9
|
+
puts '-' * @width
|
10
|
+
|
11
|
+
yield
|
12
|
+
|
13
|
+
puts
|
14
|
+
puts '-' * @width
|
15
|
+
puts 'Made with <3.. by Carolyn Phil James Aaron'.center(@width)
|
16
|
+
puts '-' * @width
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.render_file(file)
|
20
|
+
puts
|
21
|
+
puts ' ' * 3 + "#{file}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.render_note(note)
|
25
|
+
str = ' ' * 5 + "#{note}".rjust(5)
|
26
|
+
puts str.length > @width ? str.slice(0, @width - 4) + '...' : str
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: noteable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Carolyn,Phil,James,Aaron
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A simple gem for making and finding notes in your code
|
14
|
+
email: pdwittig@gmail.com
|
15
|
+
executables:
|
16
|
+
- noteable
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/noteable
|
21
|
+
- lib/note.rb
|
22
|
+
- lib/noteable.rb
|
23
|
+
- lib/parser.rb
|
24
|
+
- lib/view.rb
|
25
|
+
homepage: https://github.com/awertman/NoteAble
|
26
|
+
licenses:
|
27
|
+
- MIT
|
28
|
+
metadata: {}
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements: []
|
44
|
+
rubyforge_project:
|
45
|
+
rubygems_version: 2.2.2
|
46
|
+
signing_key:
|
47
|
+
specification_version: 4
|
48
|
+
summary: A simple gem for making and finding notes in your code
|
49
|
+
test_files: []
|