shoes-core 4.0.0.pre10 → 4.0.0.pre11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9dde3be80d20738ebbc4be46c36877fbf22b937220502390e1535dfe2b78073
4
- data.tar.gz: e870b37ec97751911c6a2ca0aa793ef78b2a903ef57e36c6dc7e9cb3751cb2b8
3
+ metadata.gz: b4b04df9c670f569189c22acf3d710762cb070648e055b8caa4df59bd9ee54fc
4
+ data.tar.gz: c3acdfe4ebb5e220cfa34f1c23ca267805c54e0e1140ecd84f0259dfea5fc4aa
5
5
  SHA512:
6
- metadata.gz: 547f206603c5e78dab96fc40b6a8b95f0b884484bf01378cec2625a92700b2f69c35a8a6b97343eb70941569fc531bf134018e7021b16841b509ead5cff42ae9
7
- data.tar.gz: 8d18cfe318b66e676a6d592da37ab007b4544df7c4972b99c4e83ef338822296039a48245ac76e210ccd8e7f2be1d369acb66efad677e2a9d427c7a352820227
6
+ metadata.gz: 4d7b39734d1c215b6d74c9b59c4f3ad6a91f472a7f72dad13881ac05811ced22f44747d021a84ec262e9dff7d0fc72a7ec16b118b4169f7c0358f121c786ab38
7
+ data.tar.gz: ff7a77a85ea9f3c2c73c15ef602a9dda20d90bd95975d4ab2aa35536cdb6383abad68004ec2459b3ef8bb1ce50c85769e5e09c207ac0fa034281b92f65ecd719
data/lib/shoes/color.rb CHANGED
@@ -89,7 +89,7 @@ EOS
89
89
  def normalize_rgb(value)
90
90
  rgb = value.is_a?(Integer) ? value : (255 * value).round
91
91
  return 255 if rgb > 255
92
- return 0 if rgb < 0
92
+ return 0 if rgb.negative?
93
93
  rgb
94
94
  end
95
95
 
@@ -26,7 +26,7 @@ class Shoes
26
26
  end
27
27
 
28
28
  def hexy_object_id
29
- sprintf('0x%08x', object_id * 2)
29
+ format('0x%08x', object_id * 2)
30
30
  end
31
31
  end
32
32
  end
@@ -3,10 +3,10 @@ class Shoes
3
3
  module Common
4
4
  module Remove
5
5
  def remove
6
- parent.remove_child self if parent
7
- gui.remove if gui && gui.respond_to?(:remove)
6
+ parent&.remove_child self
7
+ gui&.remove if gui&.respond_to?(:remove)
8
8
 
9
- @app.remove_mouse_hover_control(self) if @app
9
+ @app&.remove_mouse_hover_control(self)
10
10
  end
11
11
  end
12
12
  end
@@ -14,7 +14,7 @@ class Shoes
14
14
  end
15
15
 
16
16
  def enabled?
17
- !(state.to_s == DISABLED_STATE)
17
+ state.to_s != DISABLED_STATE
18
18
  end
19
19
 
20
20
  def update_from_state
data/lib/shoes/console.rb CHANGED
@@ -1,8 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
  class Shoes
3
3
  class Console
4
+ attr_reader :messages, :message_stacks
5
+
4
6
  def initialize
5
7
  @messages = []
8
+ @message_stacks = []
6
9
  end
7
10
 
8
11
  def show
@@ -18,12 +21,11 @@ class Shoes
18
21
  end
19
22
 
20
23
  def create_app
21
- # Capture messages for access inside our app block
22
- messages = @messages
24
+ # Capture ourself for access inside our app block
25
+ console = self
23
26
 
24
27
  @app = Shoes.app do
25
- @messages = messages
26
- @message_stacks = []
28
+ @console = console
27
29
 
28
30
  stack do
29
31
  flow do
@@ -32,11 +34,16 @@ class Shoes
32
34
  tagline "Shoes Console", stroke: white
33
35
  end
34
36
 
35
- button "Clear", margin: 6, width: 80, height: 40, right: 10 do
36
- @messages.clear
37
+ button "Copy", margin: 6, width: 80, height: 40, right: 170 do
38
+ @console.copy
39
+ end
40
+
41
+ button "Save", margin: 6, width: 80, height: 40, right: 90 do
42
+ @console.save
43
+ end
37
44
 
38
- @message_stacks.each(&:remove)
39
- @message_stacks.clear
45
+ button "Clear", margin: 6, width: 80, height: 40, right: 10 do
46
+ @console.clear
40
47
  end
41
48
  end
42
49
  end
@@ -73,7 +80,7 @@ class Shoes
73
80
 
74
81
  @app.instance_exec do
75
82
  append do
76
- @message_stacks << stack do
83
+ @console.message_stacks << stack do
77
84
  background "#f1f5e1" if index.even?
78
85
  background rgb(220, 220, 220) if index.odd?
79
86
  para type, stroke: blue
@@ -87,5 +94,32 @@ class Shoes
87
94
  end
88
95
  end
89
96
  end
97
+
98
+ def formatted_messages
99
+ @messages.inject("") do |memo, (type, message)|
100
+ "#{memo}#{type.to_s.capitalize}\n #{message}\n\n"
101
+ end
102
+ end
103
+
104
+ def copy
105
+ @app.clipboard = formatted_messages if messages.any?
106
+ end
107
+
108
+ def save
109
+ filename = @app.ask_save_file
110
+
111
+ if filename
112
+ File.open(filename, "w") do |f|
113
+ f.write(formatted_messages)
114
+ end
115
+ end
116
+ end
117
+
118
+ def clear
119
+ messages.clear
120
+
121
+ message_stacks.each(&:remove)
122
+ message_stacks.clear
123
+ end
90
124
  end
91
125
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  class Shoes
4
4
  module Core
5
- VERSION = "4.0.0.pre10"
5
+ VERSION = "4.0.0.pre11"
6
6
  end
7
7
  end
@@ -182,7 +182,7 @@ class Shoes
182
182
  end
183
183
 
184
184
  def negative?(result)
185
- result && result < 0
185
+ result && result.negative?
186
186
  end
187
187
 
188
188
  def calculate_negative(result)
@@ -233,7 +233,7 @@ class Shoes
233
233
  end
234
234
 
235
235
  def adjust_start_for_center(value)
236
- value - extent / 2 if extent && extent > 0
236
+ value - extent / 2 if extent && extent.positive?
237
237
  end
238
238
  end
239
239
 
@@ -56,7 +56,7 @@ class Shoes
56
56
 
57
57
  # needed for the specs (jay multi threading and specs)
58
58
  def join_thread
59
- @thread.join unless @thread.nil?
59
+ @thread&.join
60
60
  end
61
61
 
62
62
  def percent
@@ -65,7 +65,7 @@ class Shoes
65
65
  end
66
66
 
67
67
  def abort
68
- @thread.exit if @thread
68
+ @thread&.exit
69
69
  end
70
70
 
71
71
  # shoes 3 compatibility
@@ -23,6 +23,14 @@ class Shoes
23
23
  self.fullscreen = true if @dsl.start_as_fullscreen?
24
24
  end
25
25
 
26
+ def open?
27
+ true
28
+ end
29
+
30
+ def focus
31
+ true
32
+ end
33
+
26
34
  def quit
27
35
  end
28
36
 
@@ -6,6 +6,10 @@ class Shoes
6
6
  nil
7
7
  end
8
8
 
9
+ def dialog_chooser(*_args)
10
+ "#{Dir.tmpdir}/test_file_delete_after"
11
+ end
12
+
9
13
  def confirm(_msg = '')
10
14
  true
11
15
  end
data/lib/shoes/slot.rb CHANGED
@@ -89,7 +89,7 @@ class Shoes
89
89
  end
90
90
 
91
91
  def bump_parent_current_position(height_delta)
92
- return unless height_delta > 0
92
+ return unless height_delta.positive?
93
93
  return unless parent.respond_to?(:bump_current_position)
94
94
 
95
95
  parent.bump_current_position(self, height_delta)
@@ -79,7 +79,7 @@ class Shoes
79
79
 
80
80
  until candidate
81
81
  entered_index = @input.readline.to_i
82
- if entered_index > 0
82
+ if entered_index.positive?
83
83
  candidate = candidates[entered_index - 1]
84
84
  break if candidate
85
85
  end
data/lib/shoes/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Shoes
4
- VERSION = "4.0.0.pre10"
4
+ VERSION = "4.0.0.pre11"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shoes-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.pre10
4
+ version: 4.0.0.pre11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Team Shoes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-17 00:00:00.000000000 Z
11
+ date: 2017-08-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Shoes is the best little GUI toolkit for Ruby. Shoes makes building for
14
14
  Mac, Windows, and Linux super simple. This is the DSL for writing your app. You'll