Module: Isomorfeus::Puppetmaster::DSL

Defined in:
lib/isomorfeus/puppetmaster/dsl.rb

Constant Summary collapse

@@launch_options =
nil

Instance Method Summary collapse

Instance Method Details

#default_pageObject



33
34
35
# File 'lib/isomorfeus/puppetmaster/dsl.rb', line 33

def default_page
  session.default_page
end

#goto(uri) ⇒ Object Also known as: visit



37
38
39
40
# File 'lib/isomorfeus/puppetmaster/dsl.rb', line 37

def goto(uri)
  session.goto(uri)
  session.default_page
end

#isomorphic(ruby_source = '', &block) ⇒ Object



43
44
45
46
47
# File 'lib/isomorfeus/puppetmaster/dsl.rb', line 43

def isomorphic(ruby_source = '', &block)
  ruby_source = Isomorfeus::Puppetmaster.block_source_code(&block) if block_given?
  on_server(ruby_source)
  default_page.eval_ruby(ruby_source)
end

#isomorphic_with_opal(ruby_source = '', &block) ⇒ Object



49
50
51
52
53
# File 'lib/isomorfeus/puppetmaster/dsl.rb', line 49

def isomorphic_with_opal(ruby_source = '', &block)
  ruby_source = Isomorfeus::Puppetmaster.block_source_code(&block) if block_given?
  on_server(ruby_source)
  default_page.eval_with_opal(ruby_source)
end

#new_page(uri = nil) ⇒ Object



92
93
94
# File 'lib/isomorfeus/puppetmaster/dsl.rb', line 92

def new_page(uri = nil)
  session.new_page(uri)
end

#new_session(app: nil, args: nil, channel: nil, default_viewport: nil, devtools: nil, dumpio: nil, env: nil, executable_path: nil, handle_SIGINT: nil, handle_SIGTERM: nil, handle_SIGHUP: nil, headless: true, ignore_default_args: nil, ignore_https_errors: nil, pipe: nil, product: :chrome, slow_mo: nil, timeout: nil, user_data_dir: nil) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/isomorfeus/puppetmaster/dsl.rb', line 59

def new_session(app: nil, args: nil, channel: nil, default_viewport: nil, devtools: nil, dumpio: nil,
                env: nil, executable_path: nil, handle_SIGINT: nil, handle_SIGTERM: nil, handle_SIGHUP: nil,
                headless: true, ignore_default_args: nil, ignore_https_errors: nil, pipe: nil,
                product: :chrome, slow_mo: nil, timeout: nil, user_data_dir: nil)
  unless @@launch_options.nil?
    app = app || @@launch_options[:app]
    channel = channel || @@launch_options[:channel]
    devtools = @@launch_options[:devtools].nil? ? devtools : @@launch_options[:devtools]
    default_viewport = default_viewport || @@launch_options[:viewport]
    dumpio = dumpio || @@launch_options[:dumpio]
    env = env || @@launch_options[:env]
    executable_path = executable_path || @@launch_options[:executable_path]
    handle_SIGINT = handle_SIGINT || @@launch_options[:handle_SIGINT]
    handle_SIGTERM = handle_SIGTERM || @@launch_options[:handle_SIGTERM]
    handle_SIGHUP = handle_SIGHUP || @@launch_options[:handle_SIGHUP]
    headless = @@launch_options[:headless].nil? ? headless : @@launch_options[:headless].nil?
    ignore_https_errors = @@launch_options[:ignore_https_errors].nil? ? ignore_https_errors : @@launch_options[:ignore_https_errors]
    pipe = @@launch_options[:pipe].nil? ? pipe : @@launch_options[:pipe]
    product = product || @@launch_options[:product]
    slow_mo = slow_mo || @@launch_options[:slow_mo]
    timeout = timeout || @@launch_options[:timeout]
    user_data_dir = user_data_dir || @@launch_options[:user_data_dir]
  end
  Isomorfeus::Puppetmaster::Session.new(app: (app ? app : Isomorfeus::Puppetmaster.served_app),
                                        args: args, channel: channel&.to_s, devtools: devtools, default_viewport: default_viewport,
                                        dumpio: dumpio, env: env, executable_path: executable_path, handle_SIGINT: handle_SIGINT,
                                        handle_SIGTERM: handle_SIGTERM, handle_SIGHUP: handle_SIGHUP, headless: headless,
                                        ignore_default_args: ignore_default_args, ignore_https_errors: ignore_https_errors,
                                        pipe: pipe, product: product, slow_mo: slow_mo,
                                        timeout: timeout ? timeout : Isomorfeus::Puppetmaster::Session::TIMEOUT,
                                        user_data_dir: user_data_dir)
end

#on_server(ruby_source = '', &block) ⇒ Object



55
56
57
# File 'lib/isomorfeus/puppetmaster/dsl.rb', line 55

def on_server(ruby_source = '', &block)
  Isomorfeus::Puppetmaster.served_app.on_server(ruby_source, &block)
end

#reset_session!Object



101
102
103
104
# File 'lib/isomorfeus/puppetmaster/dsl.rb', line 101

def reset_session!
  @@puppetmaster_session = nil
  nil
end

#sessionObject



112
113
114
# File 'lib/isomorfeus/puppetmaster/dsl.rb', line 112

def session
  @@puppetmaster_session ||= new_session(app: Isomorfeus::Puppetmaster.served_app)
end

#session=(s) ⇒ Object



96
97
98
99
# File 'lib/isomorfeus/puppetmaster/dsl.rb', line 96

def session=(s)
  @@puppetmaster_session = s
  nil
end

#set_launch_options(app: nil, args: nil, channel: nil, default_viewport: nil, devtools: nil, dumpio: nil, env: nil, executable_path: nil, handle_SIGINT: nil, handle_SIGTERM: nil, handle_SIGHUP: nil, headless: true, ignore_default_args: nil, ignore_https_errors: nil, pipe: nil, product: :chrome, slow_mo: nil, timeout: nil, user_data_dir: nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/isomorfeus/puppetmaster/dsl.rb', line 6

def set_launch_options(app: nil, args: nil, channel: nil, default_viewport: nil, devtools: nil, dumpio: nil,
                       env: nil, executable_path: nil, handle_SIGINT: nil, handle_SIGTERM: nil, handle_SIGHUP: nil,
                       headless: true, ignore_default_args: nil, ignore_https_errors: nil, pipe: nil,
                       product: :chrome, slow_mo: nil, timeout: nil, user_data_dir: nil)
  @@launch_options = {
    app: app,
    args: args,
    channel: channel&.to_s,
    devtools: devtools,
    default_viewport: default_viewport,
    dumpio: dumpio,
    env: env,
    executable_path: executable_path,
    handle_SIGINT: handle_SIGINT,
    handle_SIGTERM: handle_SIGTERM,
    handle_SIGHUP: handle_SIGHUP,
    headless: headless,
    ignore_default_args: ignore_default_args,
    ignore_https_errors: ignore_https_errors,
    pipe: pipe,
    product: product.to_s,
    slow_mo: slow_mo,
    timeout: timeout ? timeout : Isomorfeus::Puppetmaster::Session::TIMEOUT,
    user_data_dir: user_data_dir,
  }
end