such 0.3.0 → 0.4.0

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
  SHA1:
3
- metadata.gz: 4afc36d6359d3c503b0d03515002407d49ea8481
4
- data.tar.gz: 9ac2e9cfb23196cc7a4b8617e225e0d8f7acc361
3
+ metadata.gz: 69f8edd38b0a7e373c70c896c47a08c629af311a
4
+ data.tar.gz: 72b897561c138e4efc85facdc39300f5b27a3386
5
5
  SHA512:
6
- metadata.gz: 6c860f4ab47f32acb9423f370ef7233f22361139c69f14f711f3c3fc1396fed3f1a57daffd4384b385995a145a9fdaf9864bd4e3ab0c17048e2edcbd43f1db8d
7
- data.tar.gz: de85415afe96746685132700cff1c31329a606cee99ef12500c74ed37e29b585690c4f3ab370eac90f188360884a01ad8cdca957793811b08ba8910b06ba35e6
6
+ metadata.gz: e9f866da5f5971f67cee50008942332fcdb2e3377b81ba4e7ee30d0b5dc1ed3ef223e7706a8f4f0627bdfe3b65dd57a188c69ea167ee3b11f4ebe803263caf08
7
+ data.tar.gz: 0452ec9e456484ec83b53103c766288e71c1d9d12ca38b63d4d745af3ae578a797263462dfacf61f5505757299e8e0937b99ed2af0ad5574aefa16374d5ccf2b
data/README.rdoc CHANGED
@@ -59,7 +59,7 @@ One can configure Symbol keys to represent metadata about a widget:
59
59
  )
60
60
 
61
61
  The examples in this repository are reworks of the examples given in
62
- ZetCode.com[http://zetcode.com/gui/rubygtk/].
62
+ ZetCode.com[http://zetcode.com/gui/rubygtk/] (back in 2015).
63
63
 
64
64
  === Features:
65
65
 
@@ -84,7 +84,7 @@ Such::Part module link:lib/such/part.rb
84
84
 
85
85
  (The MIT License)
86
86
 
87
- Copyright (c) 2015
87
+ Copyright (c) 2017
88
88
 
89
89
  Permission is hereby granted, free of charge, to any person obtaining
90
90
  a copy of this software and associated documentation files (the
data/lib/such.rb CHANGED
@@ -1,8 +1,10 @@
1
- require 'such/version'
1
+ module Such
2
+ VERSION = '0.4.0'
3
+ end
2
4
  require 'such/thing'
3
- require 'such/part'
4
5
  require 'such/such'
5
6
  require 'such/things'
7
+ require 'such/part'
6
8
  require 'such/parts'
7
9
  # Requires:
8
10
  #`ruby`
data/lib/such/such.rb CHANGED
@@ -1,14 +1,14 @@
1
1
  module Such
2
2
  def self.subclass(clss, sprclss="Gtk::#{clss}", body='include Such::Thing')
3
3
  code = <<-CODE
4
- class #{clss} < #{sprclss}
5
- #{body}
6
- end
4
+ class #{clss} < #{sprclss}
5
+ #{body}
6
+ end
7
7
  CODE
8
8
  begin
9
9
  eval code
10
10
  rescue Exception
11
- warn code
11
+ $stderr.puts code if $VERBOSE
12
12
  raise $!
13
13
  end
14
14
  end
data/lib/such/thing.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Such
2
2
  module Thing
3
- INTOS = [:set_submenu, :pack_start, :append, :add] # TODO:GTK!?
3
+ INTOS = [:set_submenu, :pack_start, :append, :add] # TODO:TK!?
4
4
 
5
5
  PARAMETERS = {}
6
6
  def self.configure(conf)
@@ -57,15 +57,19 @@ module Such
57
57
  end
58
58
 
59
59
  def self.which_method(container, methods=INTOS)
60
- methods.each{|mthd| return mthd if container.respond_to?(mthd)}
61
- raise "Don't know how to put into #{container.class}."
60
+ mthd = methods.detect{|m| container.respond_to?(m)}
61
+ raise "Don't know how to put into #{container.class}." if mthd.nil?
62
+ return mthd
62
63
  end
63
64
 
64
65
  def self.into(obj, container=nil, mthd=nil, *args)
65
66
  if container
66
- mthd=Thing.which_method(container) unless mthd
67
- unless mthd.class==Symbol and container.respond_to?(mthd)
68
- raise "Need container & method. Got #{container.class}##{mthd}(#{obj.class}...)"
67
+ if mthd
68
+ unless mthd.class==Symbol and container.respond_to?(mthd)
69
+ raise "Need container & method. Got #{container.class}##{mthd}(#{obj.class}...)"
70
+ end
71
+ else
72
+ mthd=Thing.which_method(container)
69
73
  end
70
74
  Thing.trace_method(container, mthd, [obj.class,*args]) if $VERBOSE
71
75
  container.method(mthd).call(obj, *args)
@@ -81,11 +85,8 @@ module Such
81
85
  m.call(*args)
82
86
  rescue ArgumentError, TypeError
83
87
  # Assume user meant to iterate. Note that the heuristic is not perfect.
84
- $stderr.puts "# Iterated Method #{mthd} ^^^" if $VERBOSE
88
+ $stderr.puts "# Iterated Method #{mthd}." if $VERBOSE
85
89
  [*args].each{|arg| m.call(*arg)}
86
- if $!.class == ArgumentError and not m.arity == 1
87
- warn "Warning: Iterated method's arity not one."
88
- end
89
90
  end
90
91
  end
91
92
 
@@ -102,11 +103,11 @@ module Such
102
103
  return if signals.first==''
103
104
  none = (signals.length==0)
104
105
  if block
105
- signals.push('clicked') if block and none # TODO: GTK!?
106
+ signals.push('clicked') if block and none # TODO: TK!?
106
107
  signals.each do |signal|
107
108
  break if signal==''
108
109
  begin
109
- obj.signal_connect(signal){|*emits| block.call(*emits, signal)} # TODO: GTK!?
110
+ obj.signal_connect(signal){|*emits| block.call(*emits, signal)} # TODO: TK!?
110
111
  Thing.trace_signal(obj, signal) if $VERBOSE
111
112
  rescue GLib::NoSignalError
112
113
  warn "Warning: no \"#{signal}\" signal for #{obj.class}"
data/lib/such/things.rb CHANGED
@@ -9,7 +9,7 @@ module Such
9
9
  begin
10
10
  Such.subclass(clss.name.sub(/^.*::/, ''))
11
11
  rescue Exception
12
- warn "#{$!.class}:\t#{clss}"
12
+ $stderr.puts "#{$!.class}:\t#{clss}" if $VERBOSE
13
13
  end
14
14
  end
15
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: such
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - carlosjhr64
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-15 00:00:00.000000000 Z
11
+ date: 2017-07-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  Wraps widgets with an alternate constructor
@@ -28,7 +28,6 @@ files:
28
28
  - lib/such/such.rb
29
29
  - lib/such/thing.rb
30
30
  - lib/such/things.rb
31
- - lib/such/version.rb
32
31
  homepage: https://github.com/carlosjhr64/such
33
32
  licenses:
34
33
  - MIT
@@ -50,9 +49,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
49
  - !ruby/object:Gem::Version
51
50
  version: '0'
52
51
  requirements:
53
- - 'ruby: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]'
52
+ - 'ruby: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]'
54
53
  rubyforge_project:
55
- rubygems_version: 2.4.5.1
54
+ rubygems_version: 2.6.11
56
55
  signing_key:
57
56
  specification_version: 4
58
57
  summary: Wraps widgets with an alternate constructor which factors out the configuration
data/lib/such/version.rb DELETED
@@ -1,3 +0,0 @@
1
- module Such
2
- VERSION = '0.3.0'
3
- end