ppcurses 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/ppcurses/actions/GetDataAction.rb +0 -25
- data/lib/ppcurses/actions/InsertSQLDataAction.rb +37 -3
- data/test/insertSQLAction.rb +7 -4
- metadata +30 -26
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fccb788c15daa168a581b6f693245887568e3905
|
4
|
+
data.tar.gz: 7ad5bb726061c0f42c4c658284045240ba72ff88
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 38e5a901de135487d7a590928e8302c47cfc5d20b40eef3788a7d18c2a7f2417a33ba79343d6676e709ead93cdc17f790334208b08eeeee0ee5439083f39363e
|
7
|
+
data.tar.gz: 661785c84688acdfa4bd392a1e3327f335e5829f08d8cd4da9fc172fe0510965d0797e0104e239b0a7e1dce3757aab59a11eebffdaf9ca2139c414793480912b
|
@@ -84,33 +84,8 @@ class GetDataAction < BaseAction
|
|
84
84
|
@win.attroff(color_pair(1))
|
85
85
|
end
|
86
86
|
|
87
|
-
def promptToChangeData(preparedSQL)
|
88
|
-
self.printLine(preparedSQL)
|
89
|
-
|
90
|
-
proceed = GetBooleanAction.new("Proceed? ")
|
91
|
-
proceed.setParentAction(self)
|
92
|
-
proceed.setWindow(@win)
|
93
|
-
proceed.execute()
|
94
|
-
|
95
|
-
if proceed.data == "1" then
|
96
|
-
self.printLine("")
|
97
|
-
begin
|
98
|
-
@db.execute preparedSQL
|
99
|
-
self.printSuccessLine("Execution successful")
|
100
|
-
rescue SQLite3::Exception => e
|
101
|
-
self.printErrorLine("Exception occurred")
|
102
|
-
self.printErrorLine(e.message)
|
103
|
-
ensure
|
104
|
-
self.printLine("")
|
105
|
-
self.printLine("< Press any key to continue > ")
|
106
|
-
@win.getch()
|
107
|
-
end
|
108
|
-
|
109
|
-
end
|
110
87
|
|
111
88
|
|
112
|
-
end
|
113
|
-
|
114
89
|
end
|
115
90
|
|
116
91
|
end
|
@@ -11,16 +11,50 @@ module PPCurses
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def winHeight()
|
14
|
-
|
14
|
+
8 + @actions.length
|
15
15
|
end
|
16
16
|
|
17
17
|
def afterActions()
|
18
18
|
preparedSql = @sql
|
19
|
+
dataArray = []
|
20
|
+
|
19
21
|
@actions.each do |action|
|
20
|
-
preparedSql = preparedSql.sub(
|
22
|
+
preparedSql = preparedSql.sub('?', action.data)
|
23
|
+
dataArray.push(action.data)
|
21
24
|
end
|
22
25
|
|
23
|
-
self.promptToChangeData(preparedSql)
|
26
|
+
self.promptToChangeData(preparedSql, dataArray)
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def promptToChangeData(userDisplaySQL, dataArray)
|
31
|
+
self.printLine(userDisplaySQL)
|
32
|
+
|
33
|
+
proceed = GetBooleanAction.new('Proceed? ')
|
34
|
+
proceed.setParentAction(self)
|
35
|
+
proceed.setWindow(@win)
|
36
|
+
proceed.execute()
|
37
|
+
|
38
|
+
if proceed.data == '1' then
|
39
|
+
self.printLine('')
|
40
|
+
begin
|
41
|
+
prepStatement = db.prepare(sql)
|
42
|
+
prepStatement.bind_params(dataArray)
|
43
|
+
prepStatement.execute()
|
44
|
+
prepStatement.close()
|
45
|
+
self.printSuccessLine('Execution successful')
|
46
|
+
rescue SQLite3::Exception => e
|
47
|
+
self.printErrorLine('Exception occurred')
|
48
|
+
self.printErrorLine(e.message)
|
49
|
+
ensure
|
50
|
+
self.printLine('')
|
51
|
+
self.printLine('< Press any key to continue > ')
|
52
|
+
@win.getch()
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
|
24
58
|
end
|
25
59
|
|
26
60
|
end
|
data/test/insertSQLAction.rb
CHANGED
@@ -6,11 +6,11 @@ require_relative '../lib/ppcurses.rb'
|
|
6
6
|
begin
|
7
7
|
require 'sqlite3'
|
8
8
|
rescue LoadError => e
|
9
|
-
abort
|
9
|
+
abort 'Missing dependency! Run: gem install sqlite3'
|
10
10
|
end
|
11
11
|
|
12
|
-
stringAction = PPCurses::GetStringAction.new(
|
13
|
-
intAction = PPCurses::GetIntegerAction.new(
|
12
|
+
stringAction = PPCurses::GetStringAction.new('What is your name? ')
|
13
|
+
intAction = PPCurses::GetIntegerAction.new('Input an integer? ')
|
14
14
|
|
15
15
|
def doAction(action)
|
16
16
|
action.show()
|
@@ -25,10 +25,13 @@ SQL
|
|
25
25
|
|
26
26
|
|
27
27
|
sqlAction = PPCurses::InsertSQLDataAction.new( [stringAction, intAction],
|
28
|
-
"Insert into testTable(name, val) values (
|
28
|
+
"Insert into testTable(name, val) values (?, ?)", db)
|
29
29
|
|
30
30
|
screen = PPCurses::Screen.new()
|
31
31
|
screen.run { doAction(sqlAction) }
|
32
32
|
|
33
|
+
|
33
34
|
db.close
|
34
35
|
File.delete("test.db")
|
36
|
+
|
37
|
+
|
metadata
CHANGED
@@ -1,22 +1,26 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ppcurses
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.19
|
6
5
|
platform: ruby
|
7
|
-
authors:
|
6
|
+
authors:
|
8
7
|
- Matthieu Cormier
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
|
11
|
+
|
12
|
+
date: 2013-08-18 00:00:00 Z
|
13
13
|
dependencies: []
|
14
|
+
|
14
15
|
description: Curses abstraction
|
15
16
|
email: mcormier@preenandprune.com
|
16
17
|
executables: []
|
18
|
+
|
17
19
|
extensions: []
|
20
|
+
|
18
21
|
extra_rdoc_files: []
|
19
|
-
|
22
|
+
|
23
|
+
files:
|
20
24
|
- lib/ppcurses/actions/BaseAction.rb
|
21
25
|
- lib/ppcurses/actions/GetBooleanAction.rb
|
22
26
|
- lib/ppcurses/actions/GetDataAction.rb
|
@@ -46,29 +50,29 @@ files:
|
|
46
50
|
- README.rdoc
|
47
51
|
homepage: https://github.com/mcormier/ppcurses
|
48
52
|
licenses: []
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
\n / \\___________/ \\\n \\_____________________/\n\n"
|
53
|
+
|
54
|
+
metadata: {}
|
55
|
+
|
56
|
+
post_install_message: "\n ( ) ( ) )\n ) ( ) ( (\n ( ) ( ) )\n _____________\n <_____________> ___\n | |/ _ \\\n | mmm | | |\n | coffee |_| |\n ___| |\\___/ \n / \\___________/ \\\n \\_____________________/\n\n"
|
53
57
|
rdoc_options: []
|
54
|
-
|
58
|
+
|
59
|
+
require_paths:
|
55
60
|
- lib
|
56
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
-
|
64
|
-
|
65
|
-
- - ! '>='
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '0'
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- &id001
|
64
|
+
- ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "0"
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- *id001
|
68
70
|
requirements: []
|
71
|
+
|
69
72
|
rubyforge_project:
|
70
|
-
rubygems_version:
|
73
|
+
rubygems_version: 2.0.3
|
71
74
|
signing_key:
|
72
|
-
specification_version:
|
75
|
+
specification_version: 4
|
73
76
|
summary: Convenience classes when using curses
|
74
77
|
test_files: []
|
78
|
+
|