such 0.0.0 → 0.1.0

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: 034ecc706d9a4c43a76d423f2c923a6a0d83f1e6
4
- data.tar.gz: 046e83830b08e094b1c3bf5e6105eebf1e15337e
3
+ metadata.gz: 273d09f4d688a045d6a70dd875eb512b2241de79
4
+ data.tar.gz: 09d23e4dfb1159e745dfe4a36df55de114e44e90
5
5
  SHA512:
6
- metadata.gz: cb4627c8552d8b29a0f688428daac053bfcfab9aec5a35c463ea10600344696cce34e2f9860c7d7dd0a0a4b01a9aa1d71ee43ab2f5ec5db262b8f355bb14af58
7
- data.tar.gz: e6456431c3c453541111db1afd0311ddfd1331c61db3557594f8a4f3ae7bc97d351794138f98a4d51780b53bec5ca35bf5824fc0b4a6e17bfebb0cdb0ece5d8e
6
+ metadata.gz: eb329b8288a37f2a788fd9992e0235b2b261e305f1f9320413af205b602ec00fb8d52fdf2dd52969ed604154849272eeb79965b0b3426e0c656874314cd08a4d
7
+ data.tar.gz: 643ef446c8492324a1863c86ad4ad0724926d32370ec3af73e60b675131233e03dcaebd9ebd854a12343a19195c513683f62c4ba1c491b284aaf9e60b2346774
@@ -75,6 +75,12 @@ ZetCode.com[http://zetcode.com/gui/rubygtk/].
75
75
 
76
76
  $ sudo gem install such
77
77
 
78
+ == But wait! One more thing:
79
+
80
+ See link:examples/such_parts_demo in the examples directory
81
+ and link:test/tc_part for hints on how to use the much poweful
82
+ Such::Part module link:lib/such/part.rb
83
+
78
84
  == LICENSE:
79
85
 
80
86
  (The MIT License)
@@ -1,6 +1,8 @@
1
1
  require 'such/version'
2
2
  require 'such/thing'
3
+ require 'such/part'
3
4
  require 'such/such'
4
5
  require 'such/things'
6
+ require 'such/parts'
5
7
  # Requires:
6
8
  #`ruby`
@@ -0,0 +1,29 @@
1
+ module Such
2
+ module Part
3
+ def initialize(*parameters, &block)
4
+ super(*parameters)
5
+ self.class.plugs.each do |plg|
6
+ if /^(?<sym>[^\W_]+)_(?<cls>[^\W_]+)$/=~plg
7
+ plg, sym, cls = method("#{plg}="), "#{sym}!".to_sym, Object.const_get("Such::#{cls}")
8
+ plg.call cls.new(self, sym, &block)
9
+ end
10
+ end
11
+ end
12
+
13
+ def message(*parameters)
14
+ self.class.plugs.each{|plg| method(plg).call.message(*parameters)}
15
+ end
16
+
17
+ def method_missing(plug,*args) # assuming a plug
18
+ super unless args.length==0 and plug=~/^[^\W_]+_[^\W_]+$/
19
+ obj = nil
20
+ self.class.plugs.each do |plg|
21
+ plug = method(plg).call
22
+ if plug.is_a? Such::Part
23
+ break if obj = plug.method(plg).call
24
+ end
25
+ end
26
+ return obj
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,17 @@
1
+ module Such
2
+ module Parts
3
+ def self.make(part, thing, *plugs)
4
+ raise "Superclass(#{thing}) must be a Such::Thing" unless Object.const_get(thing) < Such::Thing
5
+ plugs.each{|plug|
6
+ raise "Plugs must have the form key_class: #{plug}" unless plug=~/^[^\W_]+_[^\W_]+$/
7
+ }
8
+ Such.subclass part, thing, <<-EOT
9
+ attr_accessor :#{plugs.join(', :')}
10
+ def self.plugs
11
+ [:#{plugs.join(', :')}]
12
+ end
13
+ include Such::Part
14
+ EOT
15
+ end
16
+ end
17
+ end
@@ -103,8 +103,13 @@ module Such
103
103
  if block
104
104
  signals.push('clicked') if block and none # TODO: GTK!?
105
105
  signals.each do |signal|
106
- Thing.trace_signal(obj, signal) if $VERBOSE
107
- obj.signal_connect(signal){|*emits| block.call(*emits)} # TODO: GTK!?
106
+ break if signal==''
107
+ begin
108
+ obj.signal_connect(signal){|*emits| block.call(*emits, signal)} # TODO: GTK!?
109
+ Thing.trace_signal(obj, signal) if $VERBOSE
110
+ rescue GLib::NoSignalError
111
+ warn "Warning: no \"#{signal}\" signal for #{obj.class}"
112
+ end
108
113
  end
109
114
  elsif not none
110
115
  warn "Warning: No block given for #{signals.join(',')} on #{obj.class}."
@@ -1,3 +1,3 @@
1
1
  module Such
2
- VERSION = '0.0.0'
2
+ VERSION = '0.1.0'
3
3
  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.0.0
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - carlosjhr64
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-01 00:00:00.000000000 Z
11
+ date: 2014-11-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  Wraps Ruby's Gtk widgets with an alternate constructor
@@ -24,6 +24,8 @@ extra_rdoc_files:
24
24
  files:
25
25
  - README.rdoc
26
26
  - lib/such.rb
27
+ - lib/such/part.rb
28
+ - lib/such/parts.rb
27
29
  - lib/such/such.rb
28
30
  - lib/such/thing.rb
29
31
  - lib/such/things.rb