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



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

def default_page
  session.default_page
end

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



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

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

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



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

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



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

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



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

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

#new_session(app:, 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



58
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
# File 'lib/isomorfeus/puppetmaster/dsl.rb', line 58

def new_session(app:, 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



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

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

#reset_session!Object



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

def reset_session!
  @@puppetmaster_session = nil
  nil
end

#sessionObject



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

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

#session=(s) ⇒ Object



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

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

#set_launch_options(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
# File 'lib/isomorfeus/puppetmaster/dsl.rb', line 6

def set_launch_options(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 = {
    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