Class: Spree::TestingSupport::Microdata::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/spree/testing_support/microdata.rb

Overview

code extracted and modified from ‘microdata’ gem

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ Document



8
9
10
11
12
13
14
# File 'lib/spree/testing_support/microdata.rb', line 8

def initialize(content)
  ActiveSupport::Deprecation.warn("    Spree::TestingSupport::Microdata will be removed in Spree 3.4\n  EOS\n  @doc = Nokogiri::HTML(content)\n  @items = extract_items\nend\n", caller)

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



6
7
8
# File 'lib/spree/testing_support/microdata.rb', line 6

def doc
  @doc
end

#itemsObject (readonly)

Returns the value of attribute items.



6
7
8
# File 'lib/spree/testing_support/microdata.rb', line 6

def items
  @items
end

Instance Method Details

#extract_itemsObject



16
17
18
19
20
21
22
23
# File 'lib/spree/testing_support/microdata.rb', line 16

def extract_items
  itemscopes = @doc.search('//*[@itemscope and not(@itemprop)]')
  return nil unless itemscopes

  itemscopes.map do |itemscope|
    Item.new(itemscope)
  end
end