wlog 1.0.0 → 1.0.5
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/.rspec +1 -0
- data/README.md +57 -9
- data/Rakefile +24 -0
- data/bin/wlog +10 -0
- data/lib/wlog/commands/archive_finished_issues.rb +20 -0
- data/lib/wlog/commands/archive_issues.rb +22 -0
- data/lib/wlog/commands/concat_description.rb +8 -2
- data/lib/wlog/commands/delete_issue.rb +31 -0
- data/lib/wlog/commands/innit_db.rb +0 -2
- data/lib/wlog/commands/make_csv.rb +7 -1
- data/lib/wlog/commands/new_entry.rb +7 -2
- data/lib/wlog/commands/replace_pattern.rb +4 -6
- data/lib/wlog/commands/taint_setup.rb +18 -0
- data/lib/wlog/db_registry.rb +3 -5
- data/lib/wlog/domain.rb +13 -0
- data/lib/wlog/domain/attachment.rb +25 -17
- data/lib/wlog/domain/helpers.rb +4 -0
- data/lib/wlog/domain/issue.rb +77 -23
- data/lib/wlog/domain/key_value.rb +21 -17
- data/lib/wlog/domain/log_entry.rb +35 -21
- data/lib/wlog/domain/session.rb +17 -0
- data/lib/wlog/domain/sql_modules/issue_sql.rb +13 -5
- data/lib/wlog/domain/static_configurations.rb +9 -0
- data/lib/wlog/domain/sys_config.rb +76 -6
- data/lib/wlog/domain/template_engine.rb +55 -0
- data/lib/wlog/domain/timelog_helper.rb +53 -0
- data/lib/wlog/sql/seq/2.sql +4 -0
- data/lib/wlog/{domain → tech}/ansi_colors.rb +7 -6
- data/lib/wlog/tech/uncolored_string.rb +14 -0
- data/lib/wlog/tech/wlog_string.rb +23 -0
- data/lib/wlog/ui/bootstrap.rb +18 -0
- data/lib/wlog/ui/cli_interface.rb +94 -34
- data/lib/wlog/ui/commands/create_issue.rb +8 -4
- data/lib/wlog/ui/issue_ui.rb +47 -41
- data/lib/wlog/ui/setup_wizard.rb +34 -0
- data/lib/wlog/version.rb +1 -1
- data/spec/domain/attachment_spec.rb +59 -0
- data/spec/domain/commands/concat_desc_spec.rb +51 -0
- data/spec/domain/commands/new_entry_spec.rb +41 -0
- data/spec/domain/commands/replace_pattern_spec.rb +46 -0
- data/spec/domain/issue_spec.rb +127 -0
- data/spec/domain/key_value_spec.rb +42 -0
- data/spec/domain/log_entry_spec.rb +85 -0
- data/spec/domain/sys_config_spec.rb +38 -0
- data/spec/make_db.rb +8 -0
- data/spec/old-databases/README.md +6 -0
- data/spec/old-databases/default +0 -0
- data/spec/tech/uncolored_string.rb +20 -0
- data/spec/tech/wlog_string_spec.rb +46 -0
- data/wlog.gemspec +5 -3
- metadata +44 -6
- data/spec/key_vale_spec.rb +0 -9
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'readline'
|
2
|
+
require 'wlog/domain/sys_config'
|
3
|
+
require 'wlog/commands/taint_setup'
|
4
|
+
|
5
|
+
module Wlog
|
6
|
+
# This is the ui that is displayed whenever we detect that it is the first
|
7
|
+
# time that the application runs. Use this
|
8
|
+
# __ONLY__ for system wide configuration
|
9
|
+
# @author Simon Symeonidis
|
10
|
+
class SetupWizard
|
11
|
+
def initialize
|
12
|
+
end
|
13
|
+
|
14
|
+
# Call this to prompt the user for things
|
15
|
+
def run
|
16
|
+
get_setting
|
17
|
+
SysConfig.store_config('ansi', @input)
|
18
|
+
TaintSetup.new.execute
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def get_setting
|
24
|
+
question = "Do you use a terminal that supports ANSI colors? [yes/no] :"
|
25
|
+
until ['yes', 'no'].include? input
|
26
|
+
@input = Readline.readline(question)
|
27
|
+
@input.chomp!
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
attr :input
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
data/lib/wlog/version.rb
CHANGED
@@ -0,0 +1,59 @@
|
|
1
|
+
require_relative '../make_db'
|
2
|
+
require 'wlog/db_registry'
|
3
|
+
require 'wlog/domain/attachment'
|
4
|
+
require 'wlog/domain/log_entry'
|
5
|
+
require 'wlog/domain/issue'
|
6
|
+
|
7
|
+
require 'turntables/turntable'
|
8
|
+
|
9
|
+
include Wlog
|
10
|
+
|
11
|
+
describe Attachment do
|
12
|
+
|
13
|
+
db_name = './default'
|
14
|
+
|
15
|
+
class FileMock
|
16
|
+
attr_accessor :filename, :data, :path
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_mock_file
|
20
|
+
fm = FileMock.new
|
21
|
+
fm.filename = "thefile.txt"
|
22
|
+
fm.data = "This is my text data."
|
23
|
+
fm.path = "/home/user/"
|
24
|
+
fm end
|
25
|
+
|
26
|
+
before(:all) do
|
27
|
+
make_testing_db(db_name)
|
28
|
+
@db = DbRegistry.new(db_name)
|
29
|
+
@issue = Issue.new(@db)
|
30
|
+
@log_entry = LogEntry.new(@db)
|
31
|
+
|
32
|
+
@issue.description = "This is my issue"
|
33
|
+
@issue.insert
|
34
|
+
@log_entry.issue_id = @issue.id
|
35
|
+
@log_entry.description = "This is my log_entry"
|
36
|
+
@log_entry.insert
|
37
|
+
end
|
38
|
+
|
39
|
+
after(:all) do
|
40
|
+
FileUtils.rm db_name
|
41
|
+
end
|
42
|
+
|
43
|
+
# Note: this example uses issue, but this will be valid for whatever other
|
44
|
+
# type we want to associate to this class.
|
45
|
+
it "should insert given polymorphic type" do
|
46
|
+
file = create_mock_file
|
47
|
+
attach = Attachment.new(@db, Issue.name, @issue.id)
|
48
|
+
attach.filename = file.filename
|
49
|
+
attach.data = file.data
|
50
|
+
attach.insert
|
51
|
+
check = Attachment.find(@db, Issue.name, @issue.id)
|
52
|
+
expect(check).to_not eq(nil)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should return nil if something is not found" do
|
56
|
+
expect(Attachment.find(@db, Issue.name, 123123123)).to eq(nil)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require_relative '../../make_db'
|
2
|
+
require 'wlog/db_registry'
|
3
|
+
require 'wlog/domain/attachment'
|
4
|
+
require 'wlog/domain/log_entry'
|
5
|
+
require 'wlog/domain/issue'
|
6
|
+
|
7
|
+
require 'turntables/turntable'
|
8
|
+
|
9
|
+
|
10
|
+
require 'wlog/commands/concat_description'
|
11
|
+
|
12
|
+
include Wlog
|
13
|
+
|
14
|
+
describe ConcatDescription do
|
15
|
+
|
16
|
+
db_name = './default'
|
17
|
+
|
18
|
+
before(:all) do
|
19
|
+
make_testing_db(db_name)
|
20
|
+
@db = DbRegistry.new(db_name)
|
21
|
+
@issue = Issue.new(@db)
|
22
|
+
@log_entry = LogEntry.new(@db)
|
23
|
+
@previous_description = "This is my log_entry"
|
24
|
+
|
25
|
+
@issue.description = "This is my issue"
|
26
|
+
@issue.insert
|
27
|
+
@log_entry.issue_id = @issue.id
|
28
|
+
@log_entry.description = @previous_description
|
29
|
+
@log_entry.insert
|
30
|
+
end
|
31
|
+
|
32
|
+
after(:all) do
|
33
|
+
FileUtils.rm db_name
|
34
|
+
end
|
35
|
+
|
36
|
+
# I know, tests should not really look for implementation details, but things
|
37
|
+
# in our case *should* really inherit the command interface.
|
38
|
+
it "should inherit from commandable" do
|
39
|
+
command = ConcatDescription.new(@db, @log_entry.id, "asd")
|
40
|
+
expect(command.is_a? Commandable).to eq(true)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should concatenate a string on command execution" do
|
44
|
+
addition = " my addition"
|
45
|
+
command = ConcatDescription.new(@db, @log_entry.id, addition)
|
46
|
+
command.execute
|
47
|
+
new_le = LogEntry.find(@db, @log_entry.id)
|
48
|
+
expect(new_le.description).to eq(@previous_description + addition)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative '../../make_db'
|
2
|
+
require 'wlog/db_registry'
|
3
|
+
require 'wlog/domain/attachment'
|
4
|
+
require 'wlog/domain/log_entry'
|
5
|
+
require 'wlog/domain/issue'
|
6
|
+
require 'wlog/commands/new_entry'
|
7
|
+
|
8
|
+
require 'turntables/turntable'
|
9
|
+
|
10
|
+
include Wlog
|
11
|
+
|
12
|
+
describe NewEntry do
|
13
|
+
|
14
|
+
db_name = './default'
|
15
|
+
|
16
|
+
before(:all) do
|
17
|
+
make_testing_db(db_name)
|
18
|
+
@db = DbRegistry.new(db_name)
|
19
|
+
@issue = Issue.new(@db)
|
20
|
+
@issue.description = 'my issue'
|
21
|
+
@issue.insert
|
22
|
+
end
|
23
|
+
|
24
|
+
after(:all) do
|
25
|
+
FileUtils.rm db_name
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should insert a new entry on execution" do
|
29
|
+
command = NewEntry.new(@db, "my desc", @issue.id)
|
30
|
+
command.execute
|
31
|
+
expect(LogEntry.find_all(@db).count).to eq(1)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should create 5 more inserts on 5 more executions" do
|
35
|
+
previous = LogEntry.find_all(@db).count
|
36
|
+
command = NewEntry.new(@db, "my desc", @issue.id)
|
37
|
+
5.times{ command.execute }
|
38
|
+
expect(LogEntry.find_all(@db).count).to eq(5 + previous)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require_relative '../../make_db'
|
2
|
+
require 'wlog/db_registry'
|
3
|
+
require 'wlog/domain/log_entry'
|
4
|
+
require 'wlog/domain/issue'
|
5
|
+
|
6
|
+
require 'turntables/turntable'
|
7
|
+
require 'wlog/commands/replace_pattern'
|
8
|
+
|
9
|
+
include Wlog
|
10
|
+
|
11
|
+
describe ReplacePattern do
|
12
|
+
db_name = './default'
|
13
|
+
before(:all) do
|
14
|
+
make_testing_db(db_name)
|
15
|
+
@db = DbRegistry.new(db_name)
|
16
|
+
@issue = Issue.new(@db)
|
17
|
+
@log_entry = LogEntry.new(@db)
|
18
|
+
@previous_description = "This is my log_entry"
|
19
|
+
|
20
|
+
@issue.description = "This is my issue"
|
21
|
+
@issue.insert
|
22
|
+
@log_entry.issue_id = @issue.id
|
23
|
+
@log_entry.description = @previous_description
|
24
|
+
@log_entry.insert
|
25
|
+
end
|
26
|
+
|
27
|
+
after(:all) do
|
28
|
+
FileUtils.rm db_name
|
29
|
+
end
|
30
|
+
|
31
|
+
# I know, tests should not really look for implementation details, but things
|
32
|
+
# in our case *should* really inherit the command interface.
|
33
|
+
it "should inherit from commandable" do
|
34
|
+
command = ReplacePattern.new(@db, @log_entry.id, "asd", "ASD")
|
35
|
+
expect(command.is_a? Commandable).to eq(true)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should replace a string in LogEntry on command execution" do
|
39
|
+
addition = " my addition"
|
40
|
+
command = ReplacePattern.new(@db, @log_entry.id, 'log_entry', 'wlog_entry')
|
41
|
+
command.execute
|
42
|
+
new_le = LogEntry.find(@db, @log_entry.id)
|
43
|
+
expect(new_le.description).to eq('This is my wlog_entry')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require_relative '../make_db'
|
2
|
+
require 'wlog/db_registry'
|
3
|
+
require 'wlog/domain/issue'
|
4
|
+
|
5
|
+
require 'turntables/turntable'
|
6
|
+
|
7
|
+
include Wlog
|
8
|
+
|
9
|
+
describe Issue do
|
10
|
+
|
11
|
+
db_name = './default'
|
12
|
+
|
13
|
+
before(:all) do
|
14
|
+
make_testing_db(db_name)
|
15
|
+
@db = DbRegistry.new(db_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
after(:all) do
|
19
|
+
FileUtils.rm db_name
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should insert an issue" do
|
23
|
+
issue = Issue.new(@db)
|
24
|
+
issue.description = "Some issue"
|
25
|
+
issue.mark_started!
|
26
|
+
issue.insert
|
27
|
+
|
28
|
+
ret = @db.last_row_from('issues')
|
29
|
+
expect(ret.size).to eq(1)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should delete an issue" do
|
33
|
+
issue = Issue.new(@db)
|
34
|
+
issue.description = "Delete issue"
|
35
|
+
issue.mark_started!
|
36
|
+
issue.insert
|
37
|
+
|
38
|
+
issue.delete
|
39
|
+
ret = Issue.find(@db, issue.id)
|
40
|
+
expect(ret).to eq(nil)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should mark itself as new" do
|
44
|
+
issue = Issue.new(@db)
|
45
|
+
issue.mark_started!
|
46
|
+
expect(issue.status).to eq(0)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should mark itself as working" do
|
50
|
+
issue = Issue.new(@db)
|
51
|
+
issue.mark_working!
|
52
|
+
expect(issue.status).to eq(1)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should mark itself as finished" do
|
56
|
+
issue = Issue.new(@db)
|
57
|
+
issue.mark_finished!
|
58
|
+
expect(issue.status).to eq(2)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should return nil on issue that is not found" do
|
62
|
+
issue = Issue.find(@db, 123123123)
|
63
|
+
expect(issue).to eq(nil)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should find all the inserted values" do
|
67
|
+
issue1 = Issue.new(@db)
|
68
|
+
issue2 = Issue.new(@db)
|
69
|
+
issue3 = Issue.new(@db)
|
70
|
+
|
71
|
+
issue1.description = "find me 1"
|
72
|
+
issue2.description = "find me 2"
|
73
|
+
issue3.description = "find me 3"
|
74
|
+
|
75
|
+
issue1.insert
|
76
|
+
issue2.insert
|
77
|
+
issue3.insert
|
78
|
+
|
79
|
+
arr = Issue.find_all(@db)
|
80
|
+
descs = arr.collect{|issue| issue.description}
|
81
|
+
existing = descs & ["find me 1", "find me 2", "find me 3"]
|
82
|
+
expect(existing.size).to eq(3)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should not insert an existing value twice" do
|
86
|
+
issue = Issue.new(@db)
|
87
|
+
issue.description = "Add me once"
|
88
|
+
previous = Issue.find_all(@db).count
|
89
|
+
issue.insert
|
90
|
+
issue.insert
|
91
|
+
issue.insert
|
92
|
+
issue.insert
|
93
|
+
newcount = Issue.find_all(@db).count
|
94
|
+
expect(newcount).to eq(previous + 1)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should update with valid information" do
|
98
|
+
issue = Issue.new(@db)
|
99
|
+
previous = "Update me"
|
100
|
+
after = "UPDATED"
|
101
|
+
issue.description = previous
|
102
|
+
issue.insert
|
103
|
+
issue.description = after
|
104
|
+
issue.update
|
105
|
+
|
106
|
+
uissue = Issue.find(@db, issue.id)
|
107
|
+
expect(uissue.description).to eq(after)
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should find all finished issues" do
|
111
|
+
4.times do
|
112
|
+
iss = Issue.new(@db)
|
113
|
+
iss.description = "hello"
|
114
|
+
iss.mark_finished!
|
115
|
+
iss.insert
|
116
|
+
end
|
117
|
+
issues = Issue.find_all_finished(@db)
|
118
|
+
|
119
|
+
issues.each do |iss|
|
120
|
+
expect(iss.status).to eq(2)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should accept attachments" do
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require_relative '../make_db'
|
2
|
+
require 'wlog/db_registry'
|
3
|
+
require 'wlog/domain/key_value'
|
4
|
+
|
5
|
+
require 'turntables/turntable'
|
6
|
+
|
7
|
+
include Wlog
|
8
|
+
|
9
|
+
describe KeyValue do
|
10
|
+
|
11
|
+
db_name = "./default"
|
12
|
+
|
13
|
+
before(:all) do
|
14
|
+
make_testing_db(db_name)
|
15
|
+
@kv = KeyValue.new(DbRegistry.new(db_name))
|
16
|
+
end
|
17
|
+
|
18
|
+
after(:all) do
|
19
|
+
FileUtils.rm db_name
|
20
|
+
end
|
21
|
+
|
22
|
+
it "Should insert a value" do
|
23
|
+
@kv.put!('last_check', '2012')
|
24
|
+
expect(@kv.get('last_check')).to eq('2012')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "Should insert a value only once" do
|
28
|
+
@kv.put!('new_check', '2012')
|
29
|
+
@kv.put!('new_check', '2013')
|
30
|
+
db = SQLite3::Database.new db_name
|
31
|
+
ret = db.execute('select * from key_values where key = ?', 'new_check')
|
32
|
+
expect(ret.size).to eq(1)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "Should update a previously inserted value" do
|
36
|
+
@kv.put!('my_value', '123')
|
37
|
+
@kv.put!('my_value', '321')
|
38
|
+
expect(@kv.get('my_value')).to eq('321')
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require_relative '../make_db'
|
2
|
+
require 'wlog/db_registry'
|
3
|
+
require 'wlog/domain/log_entry'
|
4
|
+
require 'wlog/domain/issue'
|
5
|
+
|
6
|
+
require 'turntables/turntable'
|
7
|
+
|
8
|
+
include Wlog
|
9
|
+
|
10
|
+
describe LogEntry do
|
11
|
+
|
12
|
+
db_name = './default'
|
13
|
+
|
14
|
+
before(:all) do
|
15
|
+
make_testing_db(db_name)
|
16
|
+
@db = DbRegistry.new(db_name)
|
17
|
+
@issue = Issue.new(@db)
|
18
|
+
@issue.description = "Attach logs to me!"
|
19
|
+
@issue.insert
|
20
|
+
end
|
21
|
+
|
22
|
+
after(:all) do
|
23
|
+
FileUtils.rm db_name
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should be inserted" do
|
27
|
+
le = LogEntry.new(@db)
|
28
|
+
desc = "This is a log description"
|
29
|
+
le.description = desc
|
30
|
+
le.issue_id = @issue.id
|
31
|
+
le.insert
|
32
|
+
|
33
|
+
other = LogEntry.find(@db, le.id)
|
34
|
+
expect(other.description).to eq(desc)
|
35
|
+
expect(other.issue_id).to eq(@issue.id)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should handle something that is not found properly" do
|
39
|
+
le = LogEntry.find(@db, 12123123123)
|
40
|
+
expect(le).to eq(nil)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should not be inserted more than once" do
|
44
|
+
previous = LogEntry.find_all(@db).count
|
45
|
+
le = LogEntry.new(@db)
|
46
|
+
le.description = "derp"
|
47
|
+
le.issue_id = @issue.id
|
48
|
+
4.times{ le.insert }
|
49
|
+
after = LogEntry.find_all(@db).count
|
50
|
+
expect(after).to eq(previous + 1)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should be deleted from the issue" do
|
54
|
+
le = LogEntry.new(@db)
|
55
|
+
le.description = "derp derp derp"
|
56
|
+
le.issue_id = @issue.id
|
57
|
+
le.insert
|
58
|
+
id = le.id
|
59
|
+
le.delete
|
60
|
+
check = LogEntry.find(@db, id)
|
61
|
+
expect(check).to eq(nil)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should update to new information" do
|
65
|
+
le = LogEntry.new(@db)
|
66
|
+
before = "derp"
|
67
|
+
after = "herp"
|
68
|
+
le.description = before
|
69
|
+
le.issue_id = @issue.id
|
70
|
+
le.insert
|
71
|
+
le.description = after
|
72
|
+
le.update
|
73
|
+
check = LogEntry.find(@db, le.id)
|
74
|
+
|
75
|
+
expect(check.description).to eq(after)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should not be created if no issue id bound" do
|
79
|
+
le = LogEntry.new(@db)
|
80
|
+
le.description = "DERP"
|
81
|
+
expect{le.insert}.to raise_error('Need issue_id')
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|