Skip to content

Commit

Permalink
fix hook
Browse files Browse the repository at this point in the history
  • Loading branch information
onyxblade committed Mar 11, 2015
1 parent a0eab44 commit 490a6f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions lib/shenmegui/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ def initialize(str, owner)
end

end

class << self
attr_accessor :elements, :socket
attr_reader :this

def hook(obj)
def hook(obj, target)
case obj
when String
HookedString.new(obj, self)
HookedString.new(obj, target)
when Array
HookedArray.new(obj, self)
HookedArray.new(obj, target)
else
obj
end
Expand All @@ -58,11 +58,11 @@ def handle(msg)
match_data = msg.match(/(.+?):(\d+)(?:->)?({.+?})?/)
command = match_data[1].to_sym
id = match_data[2].to_i
target = elements[id]
if match_data[3]
data = JSON.parse(match_data[3])
data = Hash[data.keys.collect(&:to_sym).zip(data.values.collect{|x| hook x})]
data = Hash[data.keys.collect(&:to_sym).zip(data.values.collect{|x| hook(x, target)})]
end
target = elements[id]
case command
when :sync
target.properties.update(data)
Expand Down
6 changes: 3 additions & 3 deletions shenmegui.gemspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Gem::Specification.new do |s|
s.name = 'shenmegui'
s.version = '0.0.2'
s.date = '2015-03-07'
s.version = '0.1'
s.date = '2015-03-11'
s.summary = "什么鬼!"
s.description = "a simple HTML GUI for Ruby"
s.authors = ["CicholGricenchos"]
s.email = '[email protected]'
s.files = %w{lib static templates}.collect{|p| `ls #{p}`.split("\n").collect{|x| "#{p}/#{x}"}}.flatten
s.files = %w{lib lib/shenmegui static templates}.collect{|p| `ls #{p}`.split("\n").collect{|x| "#{p}/#{x}"}}.flatten
s.homepage = 'https://github.com/CicholGricenchos/shenmegui'
s.license = 'MIT'
s.required_ruby_version = '>= 2.0'
Expand Down

0 comments on commit 490a6f6

Please sign in to comment.