ppcurses 0.0.20 → 0.0.21

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe151d61b5bf29dae4280f3422b6106fea406b21
4
- data.tar.gz: c0be3f30ab62c20888e5220dc1dded0ef17f2415
3
+ metadata.gz: 3e13a98dcd617b53a1631b1383fdfa318fb879cc
4
+ data.tar.gz: 5766d143ec924f6bfc4acc65ce4cf2f0b47ed489
5
5
  SHA512:
6
- metadata.gz: 1221859d3336c956570f7b4b0b94da6ca5955dd93aa7210bcf640b1078624a0aa15dd4649ebe1e9fcf860e2e66b5bb9e345e3e892160576a09513201b9c42f7e
7
- data.tar.gz: ef0afd3ceb8e67ca8e3086f2e1dda9cb34b660eec811d07a4328681920103e3f34afd4bdbbf6d9126ee4ac3ae3fdc4157a063d526e92270a69aa0101bc240384
6
+ metadata.gz: fe412137a6a950c0d8743952a01699ce678bdf3ae85cb3876adb0df532c94b9d8835c5fda19ff24adc0d713d75376d298d87b812424e462857f3fe86e6f9f188
7
+ data.tar.gz: e52e99c64f9cb9b31910c02fdd0d35054fcbdd2830c93c6a1f642036028b19363dc79cc6e802f6181f495b4d287dc27cb8ca4a111a7ad37c045f9cf94d94ac44
@@ -1,4 +1,4 @@
1
- require "curses"
1
+ require 'curses'
2
2
  include Curses
3
3
 
4
4
  module PPCurses
@@ -1,39 +1,40 @@
1
- require "curses"
1
+ require 'curses'
2
2
 
3
+ #noinspection RubyResolve
3
4
  module PPCurses
4
5
  class BaseAction
5
6
 
6
- def setWindow(win)
7
+ def set_window(win)
7
8
  @win = win
8
9
  end
9
10
 
10
- def xPadding()
11
- return self.winPadding()
11
+ def x_padding
12
+ self.win_padding()
12
13
  end
13
14
 
14
- def winPadding()
15
- return 2
15
+ def win_padding
16
+ 2
16
17
  end
17
18
 
18
- def winWidth()
19
- Curses.cols - winPadding()
19
+ def win_width
20
+ Curses.cols - win_padding()
20
21
  end
21
22
 
22
- def winHeight()
23
- Curses.lines - winPadding()
23
+ def win_height
24
+ Curses.lines - win_padding()
24
25
  end
25
26
 
26
- def createWindow()
27
- @win = Window.new( winHeight(), winWidth(),
28
- winPadding()/2, winPadding()/2)
27
+ def create_window
28
+ @win = Window.new( win_height(), win_width(),
29
+ win_padding()/2, win_padding()/2)
29
30
  @win.clear
30
- @win.box("|", "-")
31
- @win.setpos(@win.cury()+1, xPadding() )
31
+ @win.box('|', '-')
32
+ @win.setpos(@win.cury()+1, x_padding() )
32
33
  end
33
34
 
34
- def show()
35
+ def show
35
36
  if @win.nil?
36
- self.createWindow()
37
+ self.create_window()
37
38
  end
38
39
 
39
40
  @win.refresh
@@ -1,29 +1,30 @@
1
1
  require_relative 'PromptAction.rb'
2
2
 
3
+ #noinspection RubyResolve
3
4
  module PPCurses
4
5
 
5
6
  class GetBooleanAction < PromptAction
6
7
 
7
8
  def initialize(prompt)
8
9
  super(prompt)
9
- @state = false;
10
+ @state = false
10
11
  end
11
12
 
12
- def printPrompt()
13
+ def print_prompt
13
14
  super()
14
- @win.addstr("No [")
15
- if (@state == false) then @win.addstr("X") else @win.addstr(" ") end
16
- @win.addstr("] Yes [")
17
- if (@state == true) then @win.addstr("X") else @win.addstr(" ") end
18
- @win.addstr("]")
15
+ @win.addstr('No [')
16
+ if @state then @win.addstr(' ') else @win.addstr('X') end
17
+ @win.addstr('] Yes [')
18
+ if @state then @win.addstr('X') else @win.addstr(' ') end
19
+ @win.addstr(']')
19
20
  end
20
21
 
21
22
 
22
- def execute()
23
- printPrompt()
23
+ def execute
24
+ print_prompt()
24
25
  # Enables reading arrow keys in getch
25
26
  @win.keypad(true)
26
- while(1)
27
+ while 1
27
28
  noecho
28
29
  c = @win.getch
29
30
 
@@ -32,14 +33,14 @@ module PPCurses
32
33
  if c == 10 then break end
33
34
 
34
35
  echo
35
- printPrompt()
36
+ print_prompt()
36
37
  end
37
38
  echo
38
39
  end
39
40
 
40
41
  def data
41
- if @state == false then return "0" end
42
- "1"
42
+ if @state then return '1' end
43
+ '0'
43
44
  end
44
45
 
45
46
  end
@@ -1,8 +1,8 @@
1
1
  require_relative 'BaseAction.rb'
2
2
 
3
+ #noinspection RubyResolve
3
4
  module PPCurses
4
5
 
5
-
6
6
  # An action that contains an array of prompt actions.
7
7
  # It can be used to group together multiple prompt actions.
8
8
  #
@@ -12,51 +12,51 @@ class GetDataAction < BaseAction
12
12
  @actions = actions
13
13
  unless @actions.nil?
14
14
  @actions.each do |action|
15
- action.setParentAction(self)
15
+ action.set_parent_action(self)
16
16
  end
17
17
  end
18
18
  end
19
19
 
20
- def beforeActions()
20
+ def before_actions
21
21
  # Stub for classes that extend
22
22
  end
23
23
 
24
- def afterActions()
24
+ def after_actions
25
25
  # Stub for classes that extend
26
26
  end
27
27
 
28
28
 
29
- def data()
29
+ def data
30
30
  values = []
31
31
  @actions.each do |action|
32
32
  values.push(action.data())
33
33
  end
34
- return values
34
+ values
35
35
  end
36
36
 
37
- def createWindow()
37
+ def create_window
38
38
  super()
39
39
  # Assign window to actions
40
40
  unless @actions.nil?
41
41
  @actions.each do |action|
42
- action.setWindow(@win)
42
+ action.set_window(@win)
43
43
  end
44
44
  end
45
45
  end
46
46
 
47
- def execute()
48
- createWindow()
47
+ def execute
48
+ create_window()
49
49
  echo
50
50
 
51
- @win.setpos(@win.cury,xPadding())
51
+ @win.setpos(@win.cury,x_padding())
52
52
 
53
- self.beforeActions()
53
+ self.before_actions()
54
54
 
55
55
  @actions.each do |action|
56
56
  action.execute
57
57
  end
58
58
 
59
- self.afterActions()
59
+ self.after_actions()
60
60
 
61
61
  noecho
62
62
  @win.clear
@@ -64,23 +64,23 @@ class GetDataAction < BaseAction
64
64
  @win.close
65
65
  end
66
66
 
67
- def printLine(string)
68
- @win.setpos(@win.cury(), winPadding())
67
+ def print_line(string)
68
+ @win.setpos(@win.cury(), win_padding())
69
69
  @win.addstr(string)
70
- @win.setpos(@win.cury() + 1, winPadding())
70
+ @win.setpos(@win.cury() + 1, win_padding())
71
71
  end
72
72
 
73
- def printSuccessLine(string)
73
+ def print_success_line(string)
74
74
  init_pair(1, COLOR_GREEN, COLOR_BLACK)
75
75
  @win.attron(color_pair(1))
76
- self.printLine(string)
76
+ self.print_line(string)
77
77
  @win.attroff(color_pair(1))
78
78
  end
79
79
 
80
- def printErrorLine(string)
80
+ def print_error_line(string)
81
81
  init_pair(1, COLOR_RED, COLOR_BLACK)
82
82
  @win.attron(color_pair(1))
83
- self.printLine(string)
83
+ self.print_line(string)
84
84
  @win.attroff(color_pair(1))
85
85
  end
86
86
 
@@ -1,5 +1,6 @@
1
1
  require_relative 'BaseAction.rb'
2
2
 
3
+ #noinspection RubyResolve
3
4
  module PPCurses
4
5
 
5
6
  class GetEnumeratedStringAction < PromptAction
@@ -10,52 +11,53 @@ module PPCurses
10
11
  super(prompt)
11
12
 
12
13
  # verify enumeration is an array
13
- if ( enumeration.respond_to?('each_with_index') == false ) then
14
+ unless enumeration.respond_to?('each_with_index') then
14
15
  raise
15
16
  end
17
+
16
18
  @options = enumeration
17
- @currOption = 0
19
+ @current_option = 0
18
20
  end
19
21
 
20
- def printPrompt()
22
+ def print_prompt
21
23
  super()
22
24
  @options.each_with_index do |option, index|
23
25
  @win.addstr(option)
24
- if ( index == @currOption ) then
25
- @win.addstr(" [X] ")
26
+ if index == @current_option then
27
+ @win.addstr(' [X] ')
26
28
  else
27
- @win.addstr(" [ ] ")
29
+ @win.addstr(' [ ] ')
28
30
  end
29
31
 
30
32
  end
31
33
  end
32
34
 
33
- def execute()
34
- printPrompt()
35
+ def execute
36
+ print_prompt()
35
37
  # Enables reading arrow keys in getch
36
38
  @win.keypad(true)
37
- while(1)
39
+ while 1
38
40
  noecho
39
41
  c = @win.getch
40
42
 
41
- if c == KEY_LEFT then @currOption = @currOption-1 end
42
- if c == KEY_RIGHT then @currOption= @currOption+1 end
43
+ if c == KEY_LEFT then @current_option = @current_option-1 end
44
+ if c == KEY_RIGHT then @current_option= @current_option+1 end
43
45
  if c == 10 then break end
44
46
 
45
- if (@currOption < 0 ) then @currOption = @options.length-1 end
46
- if (@currOption > @options.length-1 ) then @currOption = 0 end
47
+ if @current_option < 0 then @current_option = @options.length-1 end
48
+ if @current_option > @options.length-1 then @current_option = 0 end
47
49
 
48
50
  echo
49
- printPrompt()
51
+ print_prompt()
50
52
  end
51
53
  echo
52
54
  # Go to next line so that further actions to overwrite
53
55
  # the choice
54
- @win.setpos(@win.cury() + 1, xPadding())
56
+ @win.setpos(@win.cury() + 1, x_padding())
55
57
  end
56
58
 
57
59
  def data
58
- @options[@currOption]
60
+ @options[@current_option]
59
61
  end
60
62
 
61
63
  end
@@ -1,16 +1,17 @@
1
1
  require_relative 'PromptAction.rb'
2
2
 
3
+ #noinspection RubyResolve
3
4
  module PPCurses
4
5
 
5
6
  class GetIntegerAction < PromptAction
6
7
 
7
- def execute()
8
+ def execute
8
9
  y = @win.cury()
9
- @data = ""
10
+ @data = ''
10
11
  begin
11
- @win.setpos(y,xPadding())
12
+ @win.setpos(y,x_padding())
12
13
  @win.clrtoeol()
13
- @win.box("|", "-")
14
+ @win.box('|', '-')
14
15
  @win.addstr(@prompt)
15
16
  echo
16
17
  @data = @win.getstr()
@@ -1,5 +1,6 @@
1
1
  require_relative 'BaseAction.rb'
2
2
 
3
+ #noinspection RubyResolve
3
4
  module PPCurses
4
5
 
5
6
  class InsertSQLDataAction < GetDataAction
@@ -10,51 +11,57 @@ module PPCurses
10
11
  @db = db
11
12
  end
12
13
 
13
- def winHeight()
14
+ def win_height
14
15
  8 + @actions.length
15
16
  end
16
17
 
17
- def afterActions()
18
- preparedSql = @sql
19
- dataArray = []
18
+ def after_actions
19
+ prepared_sql = @sql
20
+ data_array = []
20
21
 
21
22
  @actions.each do |action|
22
- preparedSql = preparedSql.sub('?', action.data)
23
- dataArray.push(action.data)
23
+ prepared_sql = prepared_sql.sub('?', action.data)
24
+ data_array.push(action.data)
24
25
  end
25
26
 
26
- self.promptToChangeData(preparedSql, dataArray)
27
+ self.prompt_to_change_data(prepared_sql, data_array)
27
28
 
28
29
  end
29
30
 
30
- def promptToChangeData(userDisplaySQL, dataArray)
31
- self.printLine(userDisplaySQL)
31
+ #
32
+ # returns true if data was inserted
33
+ #
34
+ def prompt_to_change_data(user_display_sql, data_array)
35
+ self.print_line(user_display_sql)
32
36
 
33
37
  proceed = GetBooleanAction.new('Proceed? ')
34
- proceed.setParentAction(self)
35
- proceed.setWindow(@win)
38
+ proceed.set_parent_action(self)
39
+ proceed.set_window(@win)
36
40
  proceed.execute()
37
41
 
38
- if proceed.data == '1' then
39
- self.printLine('')
42
+ did_insert = false
43
+
44
+ if proceed.data == '1'
45
+ self.print_line('')
40
46
  begin
41
- prepStatement = @db.prepare(@sql)
42
- prepStatement.bind_params(dataArray)
43
- prepStatement.execute()
44
- prepStatement.close()
45
- self.printSuccessLine('Execution successful')
47
+ prep_statement = @db.prepare(@sql)
48
+ prep_statement.bind_params(data_array)
49
+ prep_statement.execute()
50
+ prep_statement.close()
51
+ did_insert = true
52
+ self.print_success_line('Execution successful')
46
53
  rescue SQLite3::Exception => e
47
- self.printErrorLine('Exception occurred')
48
- self.printErrorLine(e.message)
54
+ self.print_error_line('Exception occurred')
55
+ self.print_error_line(e.message)
49
56
  ensure
50
- self.printLine('')
51
- self.printLine('< Press any key to continue > ')
57
+ self.print_line('')
58
+ self.print_line('< Press any key to continue > ')
52
59
  @win.getch()
53
60
  end
54
61
 
55
62
  end
56
63
 
57
-
64
+ did_insert
58
65
  end
59
66
 
60
67
  end
@@ -2,11 +2,11 @@ require_relative 'BaseAction.rb'
2
2
 
3
3
  module PPCurses
4
4
  class NulAction < BaseAction
5
- def initialize( )
5
+ def initialize
6
6
  end
7
7
 
8
8
 
9
- def execute()
9
+ def execute
10
10
  end
11
11
 
12
12
  end
@@ -1,5 +1,6 @@
1
1
  require_relative 'BaseAction.rb'
2
2
 
3
+ #noinspection RubyResolve
3
4
  module PPCurses
4
5
  class PromptAction < BaseAction
5
6
 
@@ -7,25 +8,25 @@ module PPCurses
7
8
  @prompt = prompt
8
9
  end
9
10
 
10
- def setParentAction(action)
11
+ def set_parent_action(action)
11
12
  @parent = action
12
13
  end
13
14
 
14
- def xPadding()
15
+ def x_padding
15
16
  if @parent.nil?
16
- return self.winPadding()
17
+ self.win_padding()
17
18
  else
18
- return @parent.winPadding()
19
+ @parent.win_padding()
19
20
  end
20
21
  end
21
22
 
22
- def printPrompt()
23
- @win.setpos(@win.cury(), xPadding())
23
+ def print_prompt
24
+ @win.setpos(@win.cury(), x_padding())
24
25
  @win.addstr(@prompt)
25
26
  end
26
27
 
27
- def execute()
28
- printPrompt()
28
+ def execute
29
+ print_prompt()
29
30
  echo
30
31
  @data = @win.getstr()
31
32
  noecho
@@ -8,9 +8,9 @@ module PPCurses
8
8
 
9
9
  end
10
10
 
11
- def execute()
11
+ def execute
12
12
  @menu.show()
13
- @menu.getMenuSelection()
13
+ @menu.menu_selection()
14
14
  end
15
15
 
16
16
  end
@@ -1,18 +1,18 @@
1
1
  class BaseMenu
2
2
 
3
- def setSubMenu(menu)
4
- @subMenu = menu
3
+ def set_sub_menu(menu)
4
+ @sub_menu = menu
5
5
  end
6
6
 
7
7
  def hide()
8
8
  @win.clear
9
9
  @win.refresh
10
10
 
11
- @subMenu.hide() if @subMenu
11
+ @sub_menu.hide() if @sub_menu
12
12
  end
13
13
 
14
- def getSelectedMenuName()
15
- return @items[@selection]
14
+ def selected_menu_name()
15
+ @items[@selection]
16
16
  end
17
17
 
18
18
  end
@@ -7,21 +7,21 @@ module PPCurses
7
7
  @menu1 = menu1
8
8
  @menu2 = menu2
9
9
 
10
- @menu1.setSubMenu(menu2)
10
+ @menu1.set_sub_menu(menu2)
11
11
 
12
12
  end
13
13
 
14
- def show()
14
+ def show
15
15
  @menu1.show()
16
16
  @menu2.show()
17
17
  end
18
18
 
19
19
 
20
- def getMenuSelection()
21
- @menu1.getMenuSelection()
20
+ def menu_selection
21
+ @menu1.menu_selection()
22
22
  end
23
23
 
24
- def close()
24
+ def close
25
25
  @menu1.close()
26
26
  @menu2.close()
27
27
  end
@@ -2,115 +2,115 @@
2
2
  # http://www.ruby-doc.org/stdlib-1.9.3/libdoc/curses/rdoc/Curses.html
3
3
 
4
4
  require_relative 'BaseMenu.rb'
5
- require "curses"
5
+ require 'curses'
6
6
 
7
7
  module PPCurses
8
- class Menu < BaseMenu
9
-
10
- def initialize( menuItems, actionItems )
11
- @items = Array.new
12
-
13
- @maxMenuWidth = 0
14
-
15
- menuItems.each do |item|
16
- @items.push item
17
- if item.length > @maxMenuWidth then @maxMenuWidth = item.length end
18
- end
19
-
20
- @selection = 0
21
-
22
- unless actionItems.nil?
23
- @actions = Array.new
24
- actionItems.each do |item|
25
- @actions.push item
26
- end
27
- end
28
-
29
- winHeight = @items.length + 4
30
- winWidth = @maxMenuWidth + 4
31
- @win = Window.new(winHeight,winWidth,(lines-winHeight) / 2, (cols-winWidth)/2)
32
-
33
- @win.timeout=-1
34
- # Enables reading arrow keys in getch
35
- @win.keypad(true)
8
+ #noinspection RubyResolve
9
+ class Menu < BaseMenu
10
+
11
+ def initialize( menu_items, action_items )
12
+ @items = Array.new
13
+ @actions = Array.new
14
+ @selection = 0
15
+
16
+ max_menu_width = 0
17
+
18
+ menu_items.each do |item|
19
+ @items.push item
20
+ if item.length > max_menu_width then max_menu_width = item.length end
21
+ end
22
+
23
+ unless action_items.nil?
24
+ action_items.each do |item|
25
+ @actions.push item
26
+ end
27
+ end
28
+
29
+ w_height = @items.length + 4
30
+ w_width = max_menu_width + 4
31
+ @win = Window.new(w_height,w_width,(lines-w_height) / 2, (cols-w_width)/2)
32
+
33
+ @win.timeout=-1
34
+ # Enables reading arrow keys in getch
35
+ @win.keypad(true)
36
36
  end
37
37
 
38
- def show()
39
- @win.box("|", "-")
40
- y = 2
41
- x = 2
42
-
43
- for i in 0...@items.length
44
- @win.setpos(y, x)
45
- if @selection == i then @win.attron(A_REVERSE) end
46
- @win.addstr(@items[i])
47
- if @selection == i then @win.attroff(A_REVERSE) end
48
- y += 1
49
- end
38
+ def show
39
+ @win.box('|', '-')
40
+ y = 2
41
+ x = 2
42
+
43
+ for i in 0...@items.length
44
+ @win.setpos(y, x)
45
+ if @selection == i then @win.attron(A_REVERSE) end
46
+ @win.addstr(@items[i])
47
+ if @selection == i then @win.attroff(A_REVERSE) end
48
+ y += 1
49
+ end
50
50
 
51
- @win.refresh
51
+ @win.refresh
52
52
 
53
- @subMenu.show() if @subMenu
53
+ @sub_menu.show() if @sub_menu
54
54
  end
55
55
 
56
- def setGlobalAction(action)
57
- @gAction = action
56
+ def set_global_action(action)
57
+ @global_action = action
58
58
  end
59
59
 
60
- def getMenuSelection()
60
+ def menu_selection
61
61
 
62
- while(1)
63
- c = @win.getch
62
+ while 1
63
+ c = @win.getch
64
64
 
65
- processed = self.handleMenuSelection(c)
65
+ not_processed = !self.handle_menu_selection(c)
66
66
 
67
- if c == 27 then # ESCAPE
68
- self.hide()
69
- break
70
- end
67
+ if c == 27 # ESCAPE
68
+ self.hide()
69
+ break
70
+ end
71
71
 
72
- if processed == false then
73
- @subMenu.handleMenuSelection(c) if @subMenu
74
- end
72
+ if not_processed then
73
+ @sub_menu.handle_menu_selection(c) if @sub_menu
74
+ end
75
75
 
76
- end
76
+ end
77
77
 
78
78
  end
79
79
 
80
- def handleMenuSelection(c)
80
+ def handle_menu_selection(c)
81
81
  n_choices = @items.length
82
82
 
83
- if c == KEY_UP then
83
+ if c == KEY_UP
84
84
  if @selection == 0 then @selection = n_choices-1 else @selection -= 1 end
85
85
  self.show()
86
86
  return true
87
87
  end
88
88
 
89
- if c == KEY_DOWN then
89
+ if c == KEY_DOWN
90
90
  if @selection == n_choices-1 then @selection = 0 else @selection += 1 end
91
91
  self.show()
92
92
  return true
93
93
  end
94
94
 
95
- if c == 10 then # ENTER
95
+ if c == 10 # ENTER
96
96
 
97
- unless @gAction.nil?
98
- @gAction.execute()
97
+ unless @global_action.nil?
98
+ @global_action.execute()
99
99
  end
100
100
 
101
101
  unless @actions.nil? or @actions[@selection].nil?
102
- @actions[@selection].execute()
102
+ @actions[@selection].execute()
103
103
  end
104
104
 
105
105
  self.show()
106
106
  return true
107
107
  end
108
108
 
109
- return false
109
+ false
110
110
  end
111
111
 
112
112
 
113
- def close()
113
+ def close
114
114
  @win.close()
115
115
  end
116
116
 
@@ -2,38 +2,40 @@
2
2
  require_relative 'BaseMenu.rb'
3
3
 
4
4
  module PPCurses
5
+ #noinspection RubyResolve
5
6
  class RadioMenu < BaseMenu
6
7
 
7
- def initialize( menuItems, actionItems )
8
+ def initialize( menu_items, action_items )
8
9
  @items = Array.new
10
+ @actions = Array.new
9
11
 
10
- @menuLength = 0
12
+ @menu_length = 0
11
13
 
12
- menuItems.each do |item|
14
+ menu_items.each do |item|
13
15
  @items.push item
14
- @menuLength += item.length + 5
16
+ @menu_length += item.length + 5
15
17
  end
16
18
 
17
19
  @selection = 0
18
20
 
19
- unless actionItems.nil?
20
- @actions = Array.new
21
- actionItems.each do |item|
21
+ unless action_items.nil?
22
+
23
+ action_items.each do |item|
22
24
  @actions.push item
23
25
  end
24
26
  end
25
27
 
26
- winWidth = @menuLength + 4
28
+ w_width = @menu_length + 4
27
29
 
28
- @win = Window.new(3, winWidth ,0, (cols - winWidth) / 2)
30
+ @win = Window.new(3, w_width ,0, (cols - w_width) / 2)
29
31
 
30
32
  @win.timeout=-1
31
33
  # Enables reading arrow keys in getch
32
34
  @win.keypad(true)
33
35
  end
34
36
 
35
- def show()
36
- @win.box("|", "-")
37
+ def show
38
+ @win.box('|', '-')
37
39
  y = 1
38
40
  x = 2
39
41
 
@@ -41,7 +43,7 @@ module PPCurses
41
43
 
42
44
  for i in 0...@items.length
43
45
  @win.addstr( @items[i] )
44
- if @selection == i then @win.addstr(" [*] ") else @win.addstr(" [ ] " ) end
46
+ if @selection == i then @win.addstr(' [*] ') else @win.addstr(' [ ] ') end
45
47
  end
46
48
 
47
49
  @win.refresh
@@ -49,14 +51,14 @@ module PPCurses
49
51
  end
50
52
 
51
53
 
52
- def getMenuSelection()
54
+ def menu_selection
53
55
 
54
- while(1)
56
+ while 1
55
57
  c = @win.getch
56
58
 
57
- processed = self.handleMenuSelection(c)
59
+ self.handle_menu_selection(c)
58
60
 
59
- if c == 27 then # ESCAPE
61
+ if c == 27 # ESCAPE
60
62
  @win.clear
61
63
  @win.refresh
62
64
  break
@@ -67,15 +69,15 @@ module PPCurses
67
69
  end
68
70
 
69
71
 
70
- def handleMenuSelection(c)
72
+ def handle_menu_selection(c)
71
73
  n_choices = @items.length
72
74
 
73
- if c == KEY_RIGHT then
75
+ if c == KEY_RIGHT
74
76
  if @selection < n_choices - 1 then @selection += 1 else @selection = 0 end
75
77
  self.show()
76
78
  end
77
79
 
78
- if c == KEY_LEFT then
80
+ if c == KEY_LEFT
79
81
  if @selection > 0 then @selection -= 1 else @selection = n_choices-1 end
80
82
  self.show()
81
83
  end
@@ -90,7 +92,7 @@ module PPCurses
90
92
 
91
93
 
92
94
 
93
- def close()
95
+ def close
94
96
  @win.close()
95
97
  end
96
98
 
@@ -3,18 +3,18 @@
3
3
  require 'rubygems'
4
4
  require_relative '../lib/ppcurses.rb'
5
5
 
6
- def displayMenu()
7
- centerMenu = PPCurses::Menu.new( [ "Press", "<ESCAPE>", "to Quit" ], nil )
8
- radioMenu = PPCurses::RadioMenu.new( [ "Wow", "two", "menus!" ], nil )
6
+ def display_menu
7
+ center_menu = PPCurses::Menu.new( [ 'Press', '<ESCAPE>', 'to Quit'], nil )
8
+ radio_menu = PPCurses::RadioMenu.new( %w(Wow two menus!), nil )
9
9
 
10
- mainMenu = PPCurses::CompositeMenu.new(centerMenu, radioMenu)
10
+ main_menu = PPCurses::CompositeMenu.new(center_menu, radio_menu)
11
11
 
12
12
 
13
- mainMenu.show()
14
- mainMenu.getMenuSelection()
15
- mainMenu.close()
13
+ main_menu.show()
14
+ main_menu.menu_selection()
15
+ main_menu.close()
16
16
  end
17
17
 
18
18
  screen = PPCurses::Screen.new()
19
- screen.run { displayMenu() }
19
+ screen.run { display_menu() }
20
20
 
data/test/displayMenu.rb CHANGED
@@ -3,13 +3,13 @@
3
3
  require 'rubygems'
4
4
  require_relative '../lib/ppcurses.rb'
5
5
 
6
- def displayMenu()
7
- mainMenu = PPCurses::Menu.new( [ "Press", "<ESCAPE>", "to Quit" ], nil )
8
- mainMenu.show()
9
- mainMenu.getMenuSelection()
10
- mainMenu.close()
6
+ def display_menu
7
+ main_menu = PPCurses::Menu.new( [ 'Press', '<ESCAPE>', 'to Quit'], nil )
8
+ main_menu.show()
9
+ main_menu.menu_selection()
10
+ main_menu.close()
11
11
  end
12
12
 
13
13
  screen = PPCurses::Screen.new()
14
- screen.run { displayMenu() }
14
+ screen.run { display_menu() }
15
15
 
@@ -3,14 +3,14 @@
3
3
  require 'rubygems'
4
4
  require_relative '../lib/ppcurses.rb'
5
5
 
6
- action = PPCurses::GetBooleanAction.new("Is the sky blue? ");
6
+ action = PPCurses::GetBooleanAction.new('Is the sky blue? ')
7
7
 
8
- def doBooleanAction(action)
8
+ def do_boolean_action(action)
9
9
  action.show()
10
10
  action.execute()
11
11
  end
12
12
 
13
13
  screen = PPCurses::Screen.new()
14
- screen.run { doBooleanAction(action) }
14
+ screen.run { do_boolean_action(action) }
15
15
 
16
- puts "Value input was: " + action.data()
16
+ puts 'Value input was: ' + action.data()
@@ -3,17 +3,17 @@
3
3
  require 'rubygems'
4
4
  require_relative '../lib/ppcurses.rb'
5
5
 
6
- intAction = PPCurses::GetIntegerAction.new("Input Integer : ");
7
- stringAction = PPCurses::GetStringAction.new("Input your name: ");
6
+ integer_action = PPCurses::GetIntegerAction.new("Input Integer : ")
7
+ string_action = PPCurses::GetStringAction.new("Input your name: ")
8
8
 
9
- action = PPCurses::GetDataAction.new( [intAction, stringAction] )
9
+ action = PPCurses::GetDataAction.new( [integer_action, string_action] )
10
10
 
11
- def doIntegerAction(action)
11
+ def do_integer_action(action)
12
12
  action.show()
13
13
  action.execute()
14
14
  end
15
15
 
16
16
  screen = PPCurses::Screen.new()
17
- screen.run { doIntegerAction(action) }
17
+ screen.run { do_integer_action(action) }
18
18
 
19
- puts "Value input was: " + action.data().to_s()
19
+ puts 'Value input was: ' + action.data().to_s()
@@ -3,15 +3,14 @@
3
3
  require 'rubygems'
4
4
  require_relative '../lib/ppcurses.rb'
5
5
 
6
- action = PPCurses::GetEnumeratedStringAction.new("Media Type? ",
7
- ["CD", "Vinyl", "MP3"] );
6
+ action = PPCurses::GetEnumeratedStringAction.new('Media Type? ', %w(CD Vinyl MP3))
8
7
 
9
- def doAction(action)
8
+ def do_action(action)
10
9
  action.show()
11
10
  action.execute()
12
11
  end
13
12
 
14
13
  screen = PPCurses::Screen.new()
15
- screen.run { doAction(action) }
14
+ screen.run { do_action(action) }
16
15
 
17
- puts "Value input was: " + action.data()
16
+ puts 'Value input was: ' + action.data()
@@ -3,14 +3,14 @@
3
3
  require 'rubygems'
4
4
  require_relative '../lib/ppcurses.rb'
5
5
 
6
- action = PPCurses::GetIntegerAction.new("Input Integer : ");
6
+ action = PPCurses::GetIntegerAction.new('Input Integer : ')
7
7
 
8
- def doIntegerAction(action)
8
+ def do_integer_action(action)
9
9
  action.show()
10
10
  action.execute()
11
11
  end
12
12
 
13
13
  screen = PPCurses::Screen.new()
14
- screen.run { doIntegerAction(action) }
14
+ screen.run { do_integer_action(action) }
15
15
 
16
- puts "Value input was: " + action.data()
16
+ puts 'Value input was: ' + action.data()
@@ -3,14 +3,14 @@
3
3
  require 'rubygems'
4
4
  require_relative '../lib/ppcurses.rb'
5
5
 
6
- action = PPCurses::GetStringAction.new("Input your name: ");
6
+ action = PPCurses::GetStringAction.new('Input your name: ')
7
7
 
8
- def getStringAction(action)
8
+ def get_string_action(action)
9
9
  action.show()
10
10
  action.execute()
11
11
  end
12
12
 
13
13
  screen = PPCurses::Screen.new()
14
- screen.run { getStringAction(action) }
14
+ screen.run { get_string_action(action) }
15
15
 
16
- puts "Value input was: " + action.data()
16
+ puts 'Value input was: ' + action.data()
@@ -4,34 +4,36 @@ require 'rubygems'
4
4
  require_relative '../lib/ppcurses.rb'
5
5
 
6
6
  begin
7
+ #noinspection RubyResolve
7
8
  require 'sqlite3'
8
9
  rescue LoadError => e
9
10
  abort 'Missing dependency! Run: gem install sqlite3'
10
11
  end
11
12
 
12
- stringAction = PPCurses::GetStringAction.new('What is your name? ')
13
- intAction = PPCurses::GetIntegerAction.new('Input an integer? ')
13
+ string_action = PPCurses::GetStringAction.new('What is your name? ')
14
+ integer_action = PPCurses::GetIntegerAction.new('Input an integer? ')
14
15
 
15
- def doAction(action)
16
+ def do_action(action)
16
17
  action.show()
17
18
  action.execute()
18
19
  end
19
20
 
20
21
 
21
- db = SQLite3::Database.open "test.db"
22
+ #noinspection RubyResolve
23
+ db = SQLite3::Database.open 'test.db'
22
24
  db.execute <<-SQL
23
25
  create table testTable (name varchar(30), val int);
24
26
  SQL
25
27
 
26
28
 
27
- sqlAction = PPCurses::InsertSQLDataAction.new( [stringAction, intAction],
28
- "Insert into testTable(name, val) values (?, ?)", db)
29
+ sql_action = PPCurses::InsertSQLDataAction.new( [string_action, integer_action],
30
+ 'Insert into testTable(name, val) values (?, ?)', db)
29
31
 
30
32
  screen = PPCurses::Screen.new()
31
- screen.run { doAction(sqlAction) }
33
+ screen.run { doAction(sql_action) }
32
34
 
33
35
 
34
36
  db.close
35
- File.delete("test.db")
37
+ File.delete('test.db')
36
38
 
37
39
 
data/test/menuInMenu.rb CHANGED
@@ -3,18 +3,18 @@
3
3
  require 'rubygems'
4
4
  require_relative '../lib/ppcurses.rb'
5
5
 
6
- def displayMenu()
7
- mainMenu = PPCurses::Menu.new( [ "Press", "<ESCAPE>", "to Quit" ], nil )
8
- innerMenu = PPCurses::Menu.new( [ "Wow", "another", "menu" ], nil )
6
+ def display_menu
7
+ main_menu = PPCurses::Menu.new( [ 'Press', '<ESCAPE>', 'to Quit'], nil )
8
+ inner_menu = PPCurses::Menu.new( %w(Wow another menu), nil )
9
9
 
10
- menuAction = PPCurses::ShowMenuAction.new(innerMenu)
11
- mainMenu.setGlobalAction(menuAction)
10
+ menu_action = PPCurses::ShowMenuAction.new(inner_menu)
11
+ main_menu.set_global_action(menu_action)
12
12
 
13
- mainMenu.show()
14
- mainMenu.getMenuSelection()
15
- mainMenu.close()
13
+ main_menu.show()
14
+ main_menu.menu_selection()
15
+ main_menu.close()
16
16
  end
17
17
 
18
18
  screen = PPCurses::Screen.new()
19
- screen.run { displayMenu() }
19
+ screen.run { display_menu() }
20
20
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ppcurses
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthieu Cormier
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2013-09-01 00:00:00 Z
12
+ date: 2013-09-08 00:00:00 Z
13
13
  dependencies: []
14
14
 
15
15
  description: Curses abstraction