Class: HTMLPageObject

Inherits:
Object
  • Object
show all
Includes:
DataFactory, Foundry, StringFactory, Workflows
Defined in:
lib/sambal-cle/data_objects/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Workflows

menu_link, #open_my_site_by_name, #reset

Constructor Details

#initialize(browser, opts = {}) ⇒ HTMLPageObject

Returns a new instance of HTMLPageObject.



103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/sambal-cle/data_objects/resource.rb', line 103

def initialize(browser, opts={})
  @browser = browser

  defaults = {
      :name=>random_alphanums,
      :description=>random_multiline(100, 15, :alpha),
      :html=>"<body>Body</body>"
  }
  options = defaults.merge(opts)

  set_options(options)
  requires @site
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



101
102
103
# File 'lib/sambal-cle/data_objects/resource.rb', line 101

def description
  @description
end

#folderObject

Returns the value of attribute folder.



101
102
103
# File 'lib/sambal-cle/data_objects/resource.rb', line 101

def folder
  @folder
end

#htmlObject Also known as: content

Returns the value of attribute html.



101
102
103
# File 'lib/sambal-cle/data_objects/resource.rb', line 101

def html
  @html
end

#nameObject Also known as: title

Returns the value of attribute name.



101
102
103
# File 'lib/sambal-cle/data_objects/resource.rb', line 101

def name
  @name
end

#siteObject

Returns the value of attribute site.



101
102
103
# File 'lib/sambal-cle/data_objects/resource.rb', line 101

def site
  @site
end

#urlObject Also known as: href

Returns the value of attribute url.



101
102
103
# File 'lib/sambal-cle/data_objects/resource.rb', line 101

def url
  @url
end

Instance Method Details

#createObject



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/sambal-cle/data_objects/resource.rb', line 121

def create
  open_my_site_by_name @site
  resources
  on_page Resources do |page|
    page.create_html_page_in @folder
  end
  on_page EditHTMLPageContent do |page|
    page.enter_source_text page.editor, @html
    page.continue
  end
  on_page EditHTMLPageProperties do |page|
    page.name.set @name
    page.description.set @description
    # Put more here as needed later
    page.finish
  end
  on_page Resources do |page|
    @url = page.href(@name)
  end
end

#edit_content(html_source) ⇒ Object



142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/sambal-cle/data_objects/resource.rb', line 142

def edit_content(html_source)
  open_my_site_by_name @site
  resources
  on Resources do |fileslist|
    fileslist.open_folder @folder unless fileslist.item(@name).present? || @folder==nil
    fileslist.edit_content @name
  end
  on EditHTMLPageContent do |edit|
    edit.enter_source_text edit.editor, html_source
    edit.continue
  end
  @html=html_source
end