Module: Pageify
- Defined in:
- lib/pageify.rb,
lib/pageify/page_object.rb,
lib/pageify/capybara/base.rb,
lib/pageify/capybara/assertions.rb,
lib/pageify/capybara/bulk_actions.rb
Defined Under Namespace
Classes: PageObject
Instance Method Summary collapse
- #createElement(raw_row) ⇒ Object
- #get_procesed(file) ⇒ Object
- #get_session ⇒ Object
- #on(pageObject, &block) ⇒ Object
- #pageify(base_dir) ⇒ Object
- #replace_sections(parent_array, file) ⇒ Object
- #set_session(session_page) ⇒ Object
- #to_page_objects(file) ⇒ Object
Instance Method Details
#createElement(raw_row) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pageify.rb', line 14 def createElement(raw_row) element = PageObject.create(raw_row) define_method(element.name) do |*arguments| unless arguments.eql? [] element.full_selector = (element.self_selector % arguments).strip_quotes.strip else element.full_selector = (element.self_selector % '').strip_quotes.strip end element end element end |
#get_procesed(file) ⇒ Object
45 46 47 48 49 |
# File 'lib/pageify.rb', line 45 def get_procesed (file) rawArray= IO.read(file).split("\n").map{|x| x.rstrip} rawArray -= [""] rawArray = replace_sections(rawArray,file) end |
#get_session ⇒ Object
8 9 10 |
# File 'lib/pageify/capybara/base.rb', line 8 def get_session @@session end |
#on(pageObject, &block) ⇒ Object
48 49 50 |
# File 'lib/pageify/page_object.rb', line 48 def on (pageObject,&block) pageObject.run_block &block end |
#pageify(base_dir) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/pageify.rb', line 5 def pageify(base_dir) base_dir.chomp! '/' all_pages = [] page_files = Dir["#{base_dir}/**/*.yml"]-Dir["#{base_dir}/**/_*.yml"] page_files.each do |file| to_page_objects file end end |
#replace_sections(parent_array, file) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/pageify.rb', line 27 def replace_sections (parent_array,file) processed_parent = [] parent_array.each do |row| if row.lstrip.start_with?":" section_file = "#{File.dirname (file)}/#{row.split(':')[1]}.yml" section_file = "#{File.dirname(section_file)}/_#{File.basename(section_file)}" section_array = get_procesed(section_file) section_array.each_with_index do |value,index| section_array[index] = " " * row.lspace + value end processed_parent = processed_parent + section_array else processed_parent = processed_parent + [row] end end processed_parent end |
#set_session(session_page) ⇒ Object
4 5 6 |
# File 'lib/pageify/capybara/base.rb', line 4 def set_session(session_page) @@session = session_page end |
#to_page_objects(file) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/pageify.rb', line 51 def to_page_objects(file) rawArray = get_procesed(file) parentElement = rawArray.shift page = createElement(parentElement) parent = [page] until rawArray.empty? do thisElement = rawArray.first nextElement = rawArray[1] until parent.last.intend < thisElement.lspace do parent.pop end element = parent.last.createChild(thisElement) rawArray.shift parent << element if rawArray.any? &&thisElement.lspace < nextElement.lspace end end |