note_formatter 0.0.1
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 +7 -0
- data/LICENSE +22 -0
- data/README.md +4 -0
- data/bin/note_formatter +24 -0
- data/configs.yml +15 -0
- data/lib/helpers/configuration.rb +24 -0
- data/lib/note_formatter/formatter.rb +36 -0
- data/lib/note_formatter/note.rb +10 -0
- data/lib/note_formatter.rb +31 -0
- metadata +53 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d900288e88d28beb7d46862da86514c9cfa80a28
|
4
|
+
data.tar.gz: 7abc3b2317f69fd4e9ea5512f1e1570363e81ca7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 63e024ec606d1f8001cf01b190c7fb752929e3899981f472d4d65a08d210da631063bff3515d84e8404b9bf50c322e0ad3f5eedcb40560a312d7db8aecd6e914
|
7
|
+
data.tar.gz: b5da9f46c20158383ffb0a28832783b9b7dc02234663e6302cae15047392656bd7cddc8eb545df0d7f0a0aef2544204a24cfbd3049aa326d4f6248e4a033da9b
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Igor Barbosa
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
# Note Formatter
|
2
|
+
I made this ruby script during the development of my final project at UFF - Universidade Federal Fluminense. I needed to format the quick notes that we took during our meetings into a more complete txt file.
|
3
|
+
|
4
|
+
This script formats a plain txt with some markups into a txt which describes the date, location, duration, attendees and tasks we discussed in the meetings.
|
data/bin/note_formatter
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
options = {}
|
6
|
+
OptionParser.new do |opts|
|
7
|
+
opts.banner = "Usage: note_formatter [options]"
|
8
|
+
|
9
|
+
opts.on("-nNOTE_PATH", "--note_path=NOTE_PATH", "Note path") do |n|
|
10
|
+
options[:note_path] = n
|
11
|
+
end
|
12
|
+
|
13
|
+
opts.on("-dDIRECTORY", "--directory=DIRECTORY", "Directory where the formatted txt will be saved") do |d|
|
14
|
+
options[:directory] = d
|
15
|
+
end
|
16
|
+
|
17
|
+
opts.on("-h", "--help", "Prints this help") do
|
18
|
+
puts opts
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
end.parse!
|
22
|
+
|
23
|
+
require 'note_formatter'
|
24
|
+
raise OptionParser::MissingArgument, 'You need to specify the note path with -n option. See note_formatter -h for help.'if options[:note_path].nil?
|
data/configs.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
general:
|
2
|
+
pt-BR:
|
3
|
+
date_time: "Data e hora:"
|
4
|
+
location: "Local:"
|
5
|
+
attendees: "Participantes:"
|
6
|
+
duration: "Duração:"
|
7
|
+
tasks: "Tarefas:"
|
8
|
+
markdown:
|
9
|
+
"*": "* "
|
10
|
+
">": " > "
|
11
|
+
ata_tcc:
|
12
|
+
time: "15:30"
|
13
|
+
location: "Sala 451 - Instituto de Computação"
|
14
|
+
duration: "1:00"
|
15
|
+
attendees: "Igor Barbosa, Tiago Cândido, Raphael Guerra"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Helpers
|
2
|
+
module Configuration
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
def config
|
6
|
+
@config || YAML.load_file('configs.yml')
|
7
|
+
end
|
8
|
+
|
9
|
+
# localization
|
10
|
+
def l(key, language = "pt-BR")
|
11
|
+
config["general"][language][key]
|
12
|
+
end
|
13
|
+
|
14
|
+
# markdown
|
15
|
+
def m(key)
|
16
|
+
config["general"]["markdown"][key]
|
17
|
+
end
|
18
|
+
|
19
|
+
# format
|
20
|
+
def f(key, format)
|
21
|
+
config[format][key]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'helpers/configuration'
|
2
|
+
module NoteFormatter
|
3
|
+
|
4
|
+
class Formatter
|
5
|
+
include Helpers::Configuration
|
6
|
+
|
7
|
+
attr_accessor :format, :note
|
8
|
+
|
9
|
+
def initialize(format, note)
|
10
|
+
@format = format
|
11
|
+
@note = note
|
12
|
+
end
|
13
|
+
|
14
|
+
def format_file
|
15
|
+
file = File.new("./#{note.date}.txt", "w")
|
16
|
+
header file
|
17
|
+
body file
|
18
|
+
file.close
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def header(file)
|
24
|
+
file.puts("#{l 'date_time'} #{note.date} #{f 'time', format}\n\n")
|
25
|
+
file.puts("#{l 'location'} #{f 'location', format}\n\n")
|
26
|
+
file.puts("#{l 'duration'} #{f 'duration', format}\n\n")
|
27
|
+
file.puts("#{l 'attendees'} #{f 'attendees', format}\n\n\n")
|
28
|
+
end
|
29
|
+
|
30
|
+
def body(file)
|
31
|
+
file.puts("#{l 'tasks'}\n\n")
|
32
|
+
note.tasks.each { |key, value| file.puts("#{m value} #{key}") }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
require 'date'
|
3
|
+
require 'note_formatter/formatter'
|
4
|
+
require 'note_formatter/note'
|
5
|
+
|
6
|
+
module NoteFormatter
|
7
|
+
|
8
|
+
def self.test(options)
|
9
|
+
|
10
|
+
f = File.open(options[:note_path], "r")
|
11
|
+
|
12
|
+
a = f.readlines
|
13
|
+
|
14
|
+
notes = []
|
15
|
+
note = nil
|
16
|
+
|
17
|
+
a.each do |line|
|
18
|
+
if line[0] == "!"
|
19
|
+
notes << note if note
|
20
|
+
note = Note.new line.gsub(/[!\n]/,"")
|
21
|
+
elsif (line[0] =~ /[*>]/) && note
|
22
|
+
task = ({ line.gsub(/[*>\n]/,"") => line[0] })
|
23
|
+
note.tasks.merge!(task)
|
24
|
+
elsif (line[0] == "$")
|
25
|
+
notes << note if note
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
notes.each { |n| Formatter.new("ata_tcc", n).format_file }
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: note_formatter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Igor Barbosa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-31 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Formats a simple quick note txt file into a more complete one with location,
|
14
|
+
duration, atendees and tasks.
|
15
|
+
email: igorbarbosa.p@gmail.com
|
16
|
+
executables:
|
17
|
+
- note_formatter
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- LICENSE
|
22
|
+
- README.md
|
23
|
+
- bin/note_formatter
|
24
|
+
- configs.yml
|
25
|
+
- lib/helpers/configuration.rb
|
26
|
+
- lib/note_formatter.rb
|
27
|
+
- lib/note_formatter/formatter.rb
|
28
|
+
- lib/note_formatter/note.rb
|
29
|
+
homepage: http://rubygems.org/gems/note_formatter
|
30
|
+
licenses:
|
31
|
+
- MIT
|
32
|
+
metadata: {}
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubyforge_project:
|
49
|
+
rubygems_version: 2.4.8
|
50
|
+
signing_key:
|
51
|
+
specification_version: 4
|
52
|
+
summary: A note formatter
|
53
|
+
test_files: []
|