Module: Opal::Connect::ConnectPlugins::Dom::ClassMethods

Defined in:
lib/opal/connect/rspec.rb,
lib/opal/connect/plugins/dom.rb

Instance Method Summary collapse

Instance Method Details

#cacheObject



36
37
38
39
# File 'lib/opal/connect/plugins/dom.rb', line 36

def cache
  # fix:  instead of {} it needs to use ConnectCache.new
  @cache ||= (Connect.templates[self.name] ||= {})
end

#dom(selector = false) ⇒ Object



7
8
9
10
11
# File 'lib/opal/connect/rspec.rb', line 7

def dom(selector = false)
  d        = Opal::Connect::ConnectPlugins::Dom::Instance.new('html')
  selector = d.find('#rspec-iframe').dom.JS.contents
  Instance.new selector, cache, self
end

#html(scope = false, &block) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/opal/connect/plugins/dom.rb', line 41

def html(scope = false, &block)
  if !block_given?
    HTML::DSL.html(&scope).to_html
  else
    HTML::DSL.scope!(scope).html!(&block).to_html
  end
end

#html_file(caller) ⇒ Object



29
30
31
32
33
# File 'lib/opal/connect/plugins/dom.rb', line 29

def html_file(caller)
  path = "#{Dir.pwd}/.connect/html/#{caller[0][/[^:]*/].sub(Dir.pwd, '')[1..-1].sub('.rb', '.html')}"
  FileUtils.mkdir_p(File.dirname(path))
  path
end