shoes-core 4.0.0.pre5 → 4.0.0.pre6

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: a1ef269a6d0c75e333dd8592da3a015c91b94aed
4
- data.tar.gz: 5f827551fdacff4074c2bb9050104c83e10ca5e8
3
+ metadata.gz: 3a1616fc9ee94998821bae34f5e523b6bb435e8c
4
+ data.tar.gz: 80be512d070e25a15b46fc9744dd005922bfc1fe
5
5
  SHA512:
6
- metadata.gz: 742d48be0d8c9b7f6d17e8c9d96dc93ed5db1c8076d3430ac1e91d9126d948b996f54ed422a7a2a81e8e646cf1d374484cb457dcd554a370691eee700786e2ff
7
- data.tar.gz: 7388924d45215cb1ae721ef6feed84562c4dd3050c4a35a587f80442258b4579b5006b0e70c445f1a03761ce421a22c66ae770749cc14e7b02780d63226a6925
6
+ metadata.gz: 40702d6e8e3ec2dbb2e7e34c98bdcfd37a741010f34d5a5b0c939c0da3c9ec251b7fe38971094cdbc5288cbde912e30fb04273030b752e0c1ceb149f1ee3dff7
7
+ data.tar.gz: 0dbc92f9dd5a7bd178d998a12456cdca348f8a7b28df320ee6adec3d9fb1d803d157b93302a6c528bbec4a4b14f80c0e4a010300ea2d7e86a6972f3beb1c2092
@@ -0,0 +1 @@
1
+ bin/shoes-stub
@@ -20,11 +20,11 @@ task default: ['install_script']
20
20
  task :install_script do
21
21
  # If we're run via jruby-complete.jar, bindir is within the jar itself so
22
22
  # look for bin based on user directory. Otherwise, prefer Gem.bindir.
23
- if Gem.bindir.start_with?("uri:classloader")
24
- dest_dir = Gem.bindir(Gem.user_dir)
25
- else
26
- dest_dir = Gem.bindir
27
- end
23
+ dest_dir = if Gem.bindir.start_with?("uri:classloader")
24
+ Gem.bindir(Gem.user_dir)
25
+ else
26
+ Gem.bindir
27
+ end
28
28
 
29
29
  if Gem.win_platform?
30
30
  source_path = File.join(Dir.pwd, "shoes.bat")
@@ -57,7 +57,7 @@ class Shoes
57
57
  end
58
58
 
59
59
  def window(options = {}, &block)
60
- options.merge! owner: self
60
+ options[:owner] = self
61
61
  self.class.new(options, &block)
62
62
  end
63
63
 
@@ -14,5 +14,10 @@ class Shoes
14
14
  def focus
15
15
  @gui.focus
16
16
  end
17
+
18
+ def text=(value)
19
+ style(text: value.to_s)
20
+ @gui.text = value.to_s
21
+ end
17
22
  end
18
23
  end
@@ -3,13 +3,13 @@ class Shoes
3
3
  class HexConverter
4
4
  def initialize(hex)
5
5
  @hex = validate(hex) || fail(ArgumentError, "Bad hex color: #{hex}")
6
- @red, @green, @blue = hex_to_rgb(pad_if_necessary @hex)
6
+ @red, @green, @blue = hex_to_rgb(pad_if_necessary(@hex))
7
7
  end
8
8
 
9
9
  def to_rgb
10
10
  [@red, @green, @blue]
11
11
  end
12
-
12
+
13
13
  private
14
14
 
15
15
  def hex_to_rgb(hex)
@@ -25,7 +25,6 @@ class Shoes
25
25
  after_initialize(*args)
26
26
  end
27
27
 
28
-
29
28
  # This method will get called with the incoming styles hash and the
30
29
  # other arguments passed to initialize.
31
30
  #
@@ -18,6 +18,7 @@ class Shoes
18
18
  end
19
19
 
20
20
  private
21
+
21
22
  def enabled?
22
23
  !(state.to_s == DISABLED_STATE)
23
24
  end
@@ -1 +1,2 @@
1
+ require 'logger'
1
2
  require 'shoes/dsl'
@@ -1,5 +1,5 @@
1
1
  class Shoes
2
2
  module Core
3
- VERSION = "4.0.0.pre5"
3
+ VERSION = "4.0.0.pre6"
4
4
  end
5
5
  end
@@ -202,7 +202,7 @@ class Shoes
202
202
  end
203
203
 
204
204
  def int_from_string(result)
205
- (result.gsub(' ', '')).to_i
205
+ result.delete(' ').to_i
206
206
  end
207
207
 
208
208
  NUMBER_REGEX = /^-?\s*\d+/
@@ -88,7 +88,7 @@ class Shoes
88
88
  def margin=(margin)
89
89
  margin = [margin, margin, margin, margin] unless margin.is_a? Array
90
90
  self.margin_left, self.margin_top,
91
- self.margin_right, self.margin_bottom = margin
91
+ self.margin_right, self.margin_bottom = margin
92
92
  end
93
93
 
94
94
  def needs_positioning?
@@ -582,8 +582,8 @@ EOS
582
582
  Shoes::Keyrelease.new @__app__, &blk
583
583
  end
584
584
 
585
- def append(&blk)
586
- blk.call if blk
585
+ def append
586
+ yield if block_given?
587
587
  end
588
588
 
589
589
  def visit(url)
@@ -5,7 +5,6 @@ class Shoes
5
5
  include Common::Changeable
6
6
  include Common::State
7
7
 
8
-
9
8
  def before_initialize(styles, text)
10
9
  styles[:text] = text.to_s
11
10
  end
@@ -13,10 +13,13 @@ class Shoes
13
13
 
14
14
  extend Forwardable
15
15
 
16
- DEFAULT_OPTIONS = { width: 600,
17
- height: 500,
18
- title: "Shoes 4",
19
- resizable: true }.freeze
16
+ DEFAULT_OPTIONS = {
17
+ width: 600,
18
+ height: 500,
19
+ title: "Shoes 4",
20
+ resizable: true,
21
+ border: true
22
+ }.freeze
20
23
 
21
24
  def initialize(app, opts, &blk)
22
25
  @app = app
@@ -161,17 +164,15 @@ class Shoes
161
164
  end
162
165
 
163
166
  def create_execution_block(blk)
164
- if blk
165
- execution_blk = proc do
166
- execute_block blk
167
- end
168
- elsif Shoes::URL.urls.keys.any? { |page| page.match '/' }
169
- execution_blk = proc do
170
- app.visit '/'
171
- end
172
- else
173
- execution_blk = nil
174
- end
167
+ execution_blk = if blk
168
+ proc do
169
+ execute_block blk
170
+ end
171
+ elsif Shoes::URL.urls.keys.any? { |page| page.match '/' }
172
+ proc do
173
+ app.visit '/'
174
+ end
175
+ end
175
176
  execution_blk
176
177
  end
177
178
 
@@ -26,12 +26,12 @@ class Shoes
26
26
  # Doesn't use Common::Clickable because of URL flavor option clicks
27
27
  def setup_click(blk)
28
28
  if blk.nil?
29
- if @style[:click].respond_to? :call
30
- blk = @style[:click]
31
- else
32
- # Slightly awkward, but we need App, not InternalApp, to call visit
33
- blk = proc { app.app.visit @style[:click] }
34
- end
29
+ blk = if @style[:click].respond_to? :call
30
+ @style[:click]
31
+ else
32
+ # Slightly awkward, but we need App, not InternalApp, to call visit
33
+ proc { app.app.visit @style[:click] }
34
+ end
35
35
  end
36
36
 
37
37
  click(&blk)
@@ -2,7 +2,6 @@ class Shoes
2
2
  module Logger
3
3
  class Ruby < SimpleDelegator
4
4
  def initialize(device = STDERR)
5
- require 'logger'
6
5
  logger = ::Logger.new(device)
7
6
  logger.formatter = proc do |severity, _datetime, _progname, message|
8
7
  "%s: %s\n" % [severity, message]
@@ -166,8 +166,8 @@ class Shoes
166
166
 
167
167
  def position_contents
168
168
  @current_position = CurrentPosition.new element_left,
169
- element_top,
170
- element_top
169
+ element_top,
170
+ element_top
171
171
 
172
172
  contents.each do |element|
173
173
  next if element.hidden?
@@ -285,10 +285,10 @@ class Shoes
285
285
 
286
286
  def compute_content_height
287
287
  max_bottom = contents.
288
- select(&:takes_up_space?).
289
- reject(&:hidden?).
290
- map(&:absolute_bottom).
291
- max
288
+ select(&:takes_up_space?).
289
+ reject(&:hidden?).
290
+ map(&:absolute_bottom).
291
+ max
292
292
 
293
293
  if max_bottom
294
294
  max_bottom - self.element_top + NEXT_ELEMENT_OFFSET
@@ -21,10 +21,10 @@ class Shoes
21
21
  end
22
22
  end
23
23
 
24
- def prepend(&blk)
24
+ def prepend
25
25
  @prepending_index = 0
26
26
  @prepending = true
27
- blk.call
27
+ yield if block_given?
28
28
  @prepending = false
29
29
  end
30
30
 
@@ -33,6 +33,10 @@ class Shoes
33
33
  @gui.in_bounds?(*args)
34
34
  end
35
35
 
36
+ def takes_up_space?
37
+ @style[:align] != "right"
38
+ end
39
+
36
40
  def remove
37
41
  super
38
42
  links.each do |link|
@@ -101,11 +105,11 @@ class Shoes
101
105
 
102
106
  # If our endpoint is before our start, it's an empty string. We treat
103
107
  # those specially with the (0...0) range that has an empty count.
104
- if end_point < start_point
105
- range = (0...0)
106
- else
107
- range = start_point..end_point
108
- end
108
+ range = if end_point < start_point
109
+ (0...0)
110
+ else
111
+ start_point..end_point
112
+ end
109
113
 
110
114
  styles[range] ||= []
111
115
  styles[range] << text
@@ -125,7 +129,7 @@ class Shoes
125
129
  style_regex = /none|bold|normal|oblique|italic/i # TODO: add more
126
130
 
127
131
  font_family = type.gsub(style_regex, '').gsub(size_regex, '')
128
- .split(',').map { |x| x.strip.gsub(/["]/, '') }
132
+ .split(',').map { |x| x.strip.gsub(/["]/, '') }
129
133
 
130
134
  @style[:font] = font_family.first unless (font_family.size == 1 &&
131
135
  font_family[0] == "") || font_family.size == 0
@@ -35,13 +35,13 @@ class Shoes
35
35
  # If we've gotten an explicit width, use that but check that we fit still
36
36
  # Last but certainly not least, consult what's remaining in our parent.
37
37
  def desired_width(containing = nil)
38
- if containing
39
- desired = parent.absolute_left + containing - absolute_left
40
- elsif element_width
41
- desired = [element_width, remaining_in_parent].min
42
- else
43
- desired = remaining_in_parent
44
- end
38
+ desired = if containing
39
+ parent.absolute_left + containing - absolute_left
40
+ elsif element_width
41
+ [element_width, remaining_in_parent].min
42
+ else
43
+ remaining_in_parent
44
+ end
45
45
 
46
46
  desired - margin_left - margin_right
47
47
  end
@@ -74,8 +74,8 @@ class Shoes
74
74
  end
75
75
 
76
76
  def name_for_candidate(candidate)
77
- /.*lib\/shoes\/(.*)\/generate-backend.rb/.match(candidate)
78
- return "shoes-#{$1.gsub('/', '-')}"
77
+ /.*lib\/shoes\/(.*)\/generate-backend.rb/ =~ candidate
78
+ return "shoes-#{$1.tr('/', '-')}"
79
79
  end
80
80
 
81
81
  def write_backend(generator_file, bin_dir)
@@ -1,3 +1,3 @@
1
1
  class Shoes
2
- VERSION = "4.0.0.pre5"
2
+ VERSION = "4.0.0.pre6"
3
3
  end
@@ -23,6 +23,7 @@ describe Shoes::Button do
23
23
 
24
24
  it { is_expected.to respond_to :click }
25
25
  it { is_expected.to respond_to :focus }
26
+ it { is_expected.to respond_to :text= }
26
27
 
27
28
  describe "initialize" do
28
29
  its(:parent) { should eq(parent) }
@@ -32,6 +33,14 @@ describe Shoes::Button do
32
33
  its(:state) { should eq("disabled") }
33
34
  end
34
35
 
36
+ describe ".text=" do
37
+ it "changes the text" do
38
+ expect(subject.gui).to receive(:text=).with("something else")
39
+ subject.text = "something else"
40
+ expect(subject.text).to eq "something else"
41
+ end
42
+ end
43
+
35
44
  describe "relative dimensions" do
36
45
  subject { Shoes::Button.new(app, parent, "text", relative_opts, input_block) }
37
46
  it_behaves_like "object with relative dimensions"
@@ -211,23 +211,23 @@ describe Shoes::Color do
211
211
  end
212
212
 
213
213
  describe "comparable" do
214
- let(:color_1) { Shoes::Color.new(255, 69, 0) }
214
+ let(:color1) { Shoes::Color.new(255, 69, 0) }
215
215
  let(:red) {Shoes::Color.new 255, 0, 0}
216
216
  let(:green) {Shoes::Color.new 0, 255, 0}
217
217
 
218
218
  it "is equal when values are equal" do
219
- color_2 = Shoes::Color.new(255, 69, 0)
220
- expect(color_1).to eq(color_2)
219
+ color2 = Shoes::Color.new(255, 69, 0)
220
+ expect(color1).to eq(color2)
221
221
  end
222
222
 
223
223
  it "is less than when darker" do
224
- color_2 = Shoes::Color.new(255, 70, 0)
225
- expect(color_1).to be < color_2
224
+ color2 = Shoes::Color.new(255, 70, 0)
225
+ expect(color1).to be < color2
226
226
  end
227
227
 
228
228
  it "is greater than when lighter" do
229
- color_2 = Shoes::Color.new(255, 68, 0)
230
- expect(color_1).to be > color_2
229
+ color2 = Shoes::Color.new(255, 68, 0)
230
+ expect(color1).to be > color2
231
231
  end
232
232
 
233
233
  it 'does not claim for full red and full green to be equal' do
@@ -250,13 +250,13 @@ describe Shoes::Color do
250
250
  end
251
251
 
252
252
  context "same rgb values" do
253
- let(:color_2) { Shoes::Color.new(255, 69, 0, 254) }
253
+ let(:color2) { Shoes::Color.new(255, 69, 0, 254) }
254
254
  it "is less than when less opaque" do
255
- expect(color_2).to be < color_1
255
+ expect(color2).to be < color1
256
256
  end
257
257
 
258
258
  it "is greater than when more opaque" do
259
- expect(color_1).to be > color_2
259
+ expect(color1).to be > color2
260
260
  end
261
261
  end
262
262
  end
@@ -309,8 +309,8 @@ describe "Shoes built in gray" do
309
309
  end
310
310
 
311
311
  it 'hangles 0.93 right as well' do
312
- result_93 = (0.93 * 255).to_i
313
- expect(app.gray(0.93)).to eq(Shoes::Color.new(result_93, result_93, result_93))
312
+ result93 = (0.93 * 255).to_i
313
+ expect(app.gray(0.93)).to eq(Shoes::Color.new(result93, result93, result93))
314
314
  end
315
315
 
316
316
  it 'also has a grey alias for our BE friends' do
@@ -288,7 +288,7 @@ describe Shoes::Dimension do
288
288
  describe '#in_bounds?' do
289
289
  let(:absolute_start) {20}
290
290
  let(:extent) {100}
291
- let(:absolute_end) {20 + 100 -ONE_PIXEL} # -1 due to pixel counting adjustment
291
+ let(:absolute_end) {20 + 100 - ONE_PIXEL} # -1 due to pixel counting adjustment
292
292
 
293
293
  before :each do
294
294
  subject.absolute_start = absolute_start
@@ -9,23 +9,23 @@ describe Shoes::Gradient do
9
9
  let(:new_color) { Shoes::COLORS[:limegreen] }
10
10
 
11
11
  it "is equal when values are equal" do
12
- gradient_2 = Shoes::Gradient.new(color1, color2)
13
- expect(subject).to eq(gradient_2)
12
+ gradient2 = Shoes::Gradient.new(color1, color2)
13
+ expect(subject).to eq(gradient2)
14
14
  end
15
15
 
16
16
  it "is not equal when color 1 is different" do
17
- gradient_2 = Shoes::Gradient.new(new_color, color2)
18
- expect(subject).not_to eq(gradient_2)
17
+ gradient2 = Shoes::Gradient.new(new_color, color2)
18
+ expect(subject).not_to eq(gradient2)
19
19
  end
20
20
 
21
21
  it "is not equal when color 2 is different" do
22
- gradient_2 = Shoes::Gradient.new(new_color, color2)
23
- expect(subject).not_to eq(gradient_2)
22
+ gradient2 = Shoes::Gradient.new(new_color, color2)
23
+ expect(subject).not_to eq(gradient2)
24
24
  end
25
25
 
26
26
  it "is not equal to just a color" do
27
- gradient_2 = Shoes::Gradient.new(color1, new_color)
28
- expect(subject).not_to eq(gradient_2)
27
+ gradient2 = Shoes::Gradient.new(color1, new_color)
28
+ expect(subject).not_to eq(gradient2)
29
29
  end
30
30
  end
31
31
  end
@@ -47,6 +47,22 @@ describe Shoes::TextBlock do
47
47
  end
48
48
  end
49
49
 
50
+ describe "#takes_up_space?" do
51
+ it "does with default alignment" do
52
+ expect(text_block.takes_up_space?).to eq(true)
53
+ end
54
+
55
+ it "does when left aligned" do
56
+ text_block.align = "left"
57
+ expect(text_block.takes_up_space?).to eq(true)
58
+ end
59
+
60
+ it "doesn't when right aligned" do
61
+ text_block.align = "right"
62
+ expect(text_block.takes_up_space?).to eq(false)
63
+ end
64
+ end
65
+
50
66
  describe "#to_s" do
51
67
  it "is the same as #text" do
52
68
  text = text_block.text
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.pre5
4
+ version: 4.0.0.pre6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Team Shoes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-14 00:00:00.000000000 Z
11
+ date: 2016-11-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Shoes is the best little GUI toolkit for Ruby. Shoes makes building for Mac, Windows, and Linux super simple. This is the DSL for writing your app. You'll need a backend to run it.
14
14
  email:
@@ -267,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
267
267
  version: 1.3.1
268
268
  requirements: []
269
269
  rubyforge_project:
270
- rubygems_version: 2.4.8
270
+ rubygems_version: 2.6.6
271
271
  signing_key:
272
272
  specification_version: 4
273
273
  summary: The best little DSL for the best little GUI toolkit for Ruby.
@@ -376,4 +376,3 @@ test_files:
376
376
  - spec/shoes/widget_spec.rb
377
377
  - spec/shoes_spec.rb
378
378
  - spec/spec_helper.rb
379
- has_rdoc:
data/bin/shoes DELETED
@@ -1,62 +0,0 @@
1
- #!/usr/bin/env sh
2
-
3
- # This script is symlinked to be present as both bin/shoes and bin/shoes-stub
4
- # See ext/install/Rakefile for the full explanation of why we do that.
5
-
6
- # Don't try to cd on an empty $NEXT_DIR (link in same directory)
7
- mac_move_to_link_dir () {
8
- # Skip if already in link directory
9
- NEXT_DIR=$(dirname $1)
10
- if [[ -n "$NEXT_DIR" ]]; then
11
- cd $NEXT_DIR
12
- fi
13
- }
14
-
15
- mac_readlink_f () {
16
- # based on http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac
17
-
18
- # A relative or absolute path to a file, potentially a symlink
19
- LINK=$1
20
-
21
- if [ ! -L "$LINK" ] ; then
22
- # Not a link, all good
23
- echo $LINK
24
- return
25
- fi
26
-
27
- # http://bosker.wordpress.com/2012/02/12/bash-scripters-beware-of-the-cdpath/
28
- unset CDPATH
29
-
30
- # Look up links until we find something that is not a symlink
31
- while [ -L "$LINK" ] ; do
32
- mac_move_to_link_dir $LINK
33
- RELATIVE_LINK=$(basename $LINK)
34
- LINK=$(readlink $RELATIVE_LINK)
35
- done
36
-
37
- # Now PATH is an unqualified file name, but we're in its directory, so turn
38
- # it into an absolute path by prefixing with the current working directory.
39
-
40
- PHYS_DIR=`pwd -P`
41
- RESULT=$PHYS_DIR/$LINK
42
- echo $RESULT
43
- }
44
-
45
- case "${MACHTYPE:-}${OSTYPE:-}" in
46
- (*darwin*)
47
- SCRIPT=$(mac_readlink_f $0);;
48
- (*)
49
- # see http://stackoverflow.com/a/1638397/1810896
50
- SCRIPT=$(readlink -f "$0");;
51
- esac
52
-
53
- SCRIPTPATH=$(dirname "$SCRIPT")
54
-
55
- BACKEND_FILE="$SCRIPTPATH/shoes-backend"
56
- if [ ! -e "$BACKEND_FILE" ]
57
- then
58
- $SCRIPTPATH/shoes-picker $SCRIPTPATH
59
- fi
60
-
61
- BACKEND_COMMAND=$(cat $BACKEND_FILE)
62
- SHOES_BIN_DIR=$SCRIPTPATH $BACKEND_COMMAND $@