scrapify 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/pizza.rb +10 -0
- data/lib/scrapify.rb +2 -1
- data/lib/scrapify/base.rb +8 -7
- data/lib/scrapify/scraper.rb +24 -0
- data/lib/scrapify/version.rb +1 -1
- data/spec/pizza.rb +1 -1
- data/spec/scraper_spec.rb +22 -0
- data/spec/scrapify_spec.rb +1 -177
- data/spec/shared/scrapify.rb +178 -0
- data/spec/spec_helper.rb +2 -1
- metadata +20 -15
- data/lib/meta_define.rb +0 -5
data/examples/pizza.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
class Pizza
|
2
|
+
include Scrapify::Base
|
3
|
+
html "http://www.dominos.co.in/menuDetails_ajx.php?catgId=1"
|
4
|
+
|
5
|
+
attribute :name, css: ".menu_lft li a"
|
6
|
+
attribute :image_url, xpath: "//li//input//@value"
|
7
|
+
attribute :price, css: ".price", regex: /([\d\.]+)/
|
8
|
+
|
9
|
+
key :name
|
10
|
+
end
|
data/lib/scrapify.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'scrapify/version'
|
2
2
|
require 'active_support/core_ext/class/attribute_accessors'
|
3
|
+
require 'active_support/core_ext/hash/keys'
|
3
4
|
require 'nokogiri'
|
4
5
|
require 'uri'
|
5
6
|
require 'net/http'
|
6
|
-
require 'meta_define'
|
7
7
|
require 'scrapify/base'
|
8
|
+
require 'scrapify/scraper'
|
8
9
|
require 'json'
|
9
10
|
require 'jsonify'
|
data/lib/scrapify/base.rb
CHANGED
@@ -27,11 +27,12 @@ module Scrapify
|
|
27
27
|
|
28
28
|
def attribute(name, options={}, &block)
|
29
29
|
add_attribute(name)
|
30
|
+
options = options.symbolize_keys
|
30
31
|
parser = options[:xpath] ? :xpath : :css
|
31
32
|
selector = options[parser]
|
32
33
|
matcher = /#{options[:regex]}/ if options[:regex]
|
33
34
|
to_array = options[:array]
|
34
|
-
|
35
|
+
define_singleton_method "#{name}_values" do
|
35
36
|
self.doc ||= parse_html
|
36
37
|
self.doc.send(parser, selector).map do |element|
|
37
38
|
if block
|
@@ -86,21 +87,21 @@ module Scrapify
|
|
86
87
|
end
|
87
88
|
|
88
89
|
def define_finders
|
89
|
-
|
90
|
+
define_singleton_method :all do
|
90
91
|
count.times.map do |index|
|
91
92
|
find_by_index index
|
92
93
|
end
|
93
94
|
end
|
94
95
|
|
95
|
-
|
96
|
+
define_singleton_method :first do
|
96
97
|
find_by_index 0
|
97
98
|
end
|
98
99
|
|
99
|
-
|
100
|
+
define_singleton_method :last do
|
100
101
|
find_by_index count - 1
|
101
102
|
end
|
102
103
|
|
103
|
-
|
104
|
+
define_singleton_method :find_by_index do |index|
|
104
105
|
return if index.nil? or index < 0
|
105
106
|
attributes = Hash[attribute_names.map {|attribute| [attribute, send("#{attribute}_values")[index]]}]
|
106
107
|
self.new(attributes)
|
@@ -108,13 +109,13 @@ module Scrapify
|
|
108
109
|
end
|
109
110
|
|
110
111
|
def define_count(key_attribute)
|
111
|
-
|
112
|
+
define_singleton_method :count do
|
112
113
|
send("#{key_attribute}_values").size
|
113
114
|
end
|
114
115
|
end
|
115
116
|
|
116
117
|
def define_find_by_id(key_attribute)
|
117
|
-
|
118
|
+
define_singleton_method :find do |key_value|
|
118
119
|
index = send("#{key_attribute}_values").index(key_value)
|
119
120
|
find_by_index index
|
120
121
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Scrapify
|
2
|
+
class Scraper
|
3
|
+
def initialize(url, key_attr, attributes)
|
4
|
+
@scraper = Class.new
|
5
|
+
@scraper.send(:include, Scrapify::Base)
|
6
|
+
@scraper.html url
|
7
|
+
@scraper.key key_attr.to_sym
|
8
|
+
attributes.symbolize_keys.each do |attr, options|
|
9
|
+
options = options.symbolize_keys
|
10
|
+
custom_block = options.delete(:block)
|
11
|
+
@scraper.attribute attr, options, &custom_block
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def method_missing(method, *args, &block)
|
16
|
+
return @scraper.send(method, *args, &block) if @scraper.respond_to?(method)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def respond_to?(method, include_private=false)
|
21
|
+
@scraper.respond_to?(method, include_private) || super
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/scrapify/version.rb
CHANGED
data/spec/pizza.rb
CHANGED
@@ -8,7 +8,7 @@ class Pizza
|
|
8
8
|
attribute :ingredients, css: ".ingredients", regex: /contains (\w+)/, array: true
|
9
9
|
attribute :ingredient_urls, css: '.references ol li' do |element|
|
10
10
|
element.children.map do |child|
|
11
|
-
|
11
|
+
child.attributes['href'].value if child.attributes['href']
|
12
12
|
end.compact
|
13
13
|
end
|
14
14
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'test_models'
|
3
|
+
require 'active_support/core_ext/hash/keys'
|
4
|
+
|
5
|
+
describe Scrapify::Scraper do
|
6
|
+
def self.attributes
|
7
|
+
{:name => {:css => ".menu_lft li a"},
|
8
|
+
:image_url => {:xpath => "//li//input//@value"},
|
9
|
+
:price => {:css => ".price", :regex => /([\d\.]+)/},
|
10
|
+
:ingredients => {:css => ".ingredients", :regex => /contains (\w+)/, :array => true},
|
11
|
+
:ingredient_urls => {:css => ".references ol li",
|
12
|
+
:block => lambda{|element| element.children.map{|child| child.attributes['href'].value if child.attributes['href']}.compact}
|
13
|
+
}}
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.attributes_with_string_keys
|
17
|
+
attributes.each_with_object({}){|(k,v),h| h[k.to_s] = v.stringify_keys}
|
18
|
+
end
|
19
|
+
|
20
|
+
it_should_behave_like "Scrapify", Scrapify::Scraper.new(::Pizza.url, :name, attributes)
|
21
|
+
it_should_behave_like "Scrapify", Scrapify::Scraper.new(::Pizza.url, 'name', attributes_with_string_keys)
|
22
|
+
end
|
data/spec/scrapify_spec.rb
CHANGED
@@ -2,181 +2,5 @@ require 'spec_helper'
|
|
2
2
|
require 'test_models'
|
3
3
|
|
4
4
|
describe Scrapify do
|
5
|
-
|
6
|
-
before do
|
7
|
-
@pizza_url = "http://www.dominos.co.in/menuDetails_ajx.php?catgId=1"
|
8
|
-
FakeWeb.register_uri :get, @pizza_url,
|
9
|
-
:cache_control => "private, s-maxage=0, max-age=0, must-revalidate",
|
10
|
-
:age => 51592,
|
11
|
-
:length => 12312,
|
12
|
-
:body => <<-HTML
|
13
|
-
<ul class="menu_lft">
|
14
|
-
<li>
|
15
|
-
<a> chicken supreme </a><input value="chicken.jpg">
|
16
|
-
<span class='price'>(1.23)</span>
|
17
|
-
<span class='ingredients'>
|
18
|
-
<ol>
|
19
|
-
<li>contains corn</li>
|
20
|
-
<li>contains tomato</li>
|
21
|
-
<ol>
|
22
|
-
</span>
|
23
|
-
<span class='references'><ol><li></li></ol></span
|
24
|
-
</li>
|
25
|
-
<li>
|
26
|
-
<a>veg supreme</a><input value="veg.jpg">
|
27
|
-
<span class='price'>(2.34)</span>
|
28
|
-
<span class='ingredients'>
|
29
|
-
<ol>
|
30
|
-
<li>contains mushroom</li>
|
31
|
-
<li>contains jalapeno</li>
|
32
|
-
<ol>
|
33
|
-
</span>
|
34
|
-
<span class='references'><ol><li></li></ol></span
|
35
|
-
</li>
|
36
|
-
<li>
|
37
|
-
<a>pepperoni</a><input value="pepperoni.jpg">
|
38
|
-
<span class='price'>(3.45)</span>
|
39
|
-
<span class='ingredients'></span>
|
40
|
-
<span class='references'><ol><li></li></ol></span
|
41
|
-
</li>
|
42
|
-
<li>
|
43
|
-
<a>chicken golden delight</a><input value="golden.jpg">
|
44
|
-
<span class='price'>(4.56)</span>
|
45
|
-
<span class='ingredients'/>
|
46
|
-
<span class='references'>
|
47
|
-
<ol>
|
48
|
-
<li>
|
49
|
-
<div href='chicken.html'>chicken</div>
|
50
|
-
<div href='delight.html'>delight</div>
|
51
|
-
</li>
|
52
|
-
</ol>
|
53
|
-
</span>
|
54
|
-
</li>
|
55
|
-
</ul>
|
56
|
-
HTML
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should return attribute names" do
|
60
|
-
::Pizza.attribute_names.should == [:name, :image_url, :price, :ingredients, :ingredient_urls]
|
61
|
-
end
|
62
|
-
|
63
|
-
describe "html" do
|
64
|
-
it "should store url" do
|
65
|
-
::Pizza.url.should == @pizza_url
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should parse html and fetch attributes using css" do
|
69
|
-
::Pizza.name_values.should == ['chicken supreme', 'veg supreme', 'pepperoni', 'chicken golden delight']
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should parse html and fetch attributes using xpath" do
|
73
|
-
::Pizza.image_url_values.should == ['chicken.jpg', 'veg.jpg', 'pepperoni.jpg', 'golden.jpg']
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should parse html and extract attributes using regex" do
|
77
|
-
::Pizza.price_values.should == ['1.23', '2.34', '3.45', '4.56']
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should parse html and extract multiple attributes using regex" do
|
81
|
-
::Pizza.ingredients_values.should == [['corn','tomato'], ['mushroom','jalapeno'], [], []]
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'should accept block to yield attribute values' do
|
85
|
-
::Pizza.ingredient_urls_values.should == [[], [], [], ['chicken.html', 'delight.html']]
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should strip content" do
|
89
|
-
::Pizza.first.name.should == 'chicken supreme'
|
90
|
-
end
|
91
|
-
|
92
|
-
describe "cache headers" do
|
93
|
-
it "should return the http headers" do
|
94
|
-
::Pizza.http_cache_header.should == {
|
95
|
-
"cache-control" => "private, s-maxage=0, max-age=0, must-revalidate",
|
96
|
-
"age" => 51592,
|
97
|
-
}
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe "find" do
|
103
|
-
it "should find element by key" do
|
104
|
-
pizza = ::Pizza.find('pepperoni')
|
105
|
-
pizza.should_not be_nil
|
106
|
-
pizza.name.should == 'pepperoni'
|
107
|
-
pizza.image_url.should == 'pepperoni.jpg'
|
108
|
-
end
|
109
|
-
|
110
|
-
it "should be nil if element does not exist" do
|
111
|
-
pizza = ::Pizza.find('mushroom')
|
112
|
-
pizza.should be_nil
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
describe "first" do
|
117
|
-
it "should fetch first matching element" do
|
118
|
-
first_pizza = ::Pizza.first
|
119
|
-
first_pizza.name.should == 'chicken supreme'
|
120
|
-
first_pizza.image_url.should == 'chicken.jpg'
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
describe "last" do
|
125
|
-
it "should fetch last matching element" do
|
126
|
-
last_pizza = ::Pizza.last
|
127
|
-
last_pizza.name.should == 'chicken golden delight'
|
128
|
-
last_pizza.image_url.should == 'golden.jpg'
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
describe "all" do
|
133
|
-
it "should fetch all objects" do
|
134
|
-
pizzas = ::Pizza.all
|
135
|
-
pizzas.size.should == 4
|
136
|
-
pizzas.map(&:name).should == ['chicken supreme', 'veg supreme', 'pepperoni', 'chicken golden delight']
|
137
|
-
pizzas.map(&:image_url).should == ['chicken.jpg', 'veg.jpg', 'pepperoni.jpg', 'golden.jpg']
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
describe "count" do
|
142
|
-
it "should return number of matching elements" do
|
143
|
-
::Pizza.count.should == 4
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
describe "attributes" do
|
148
|
-
it "should return attributes hash" do
|
149
|
-
first_pizza = ::Pizza.first
|
150
|
-
first_pizza.attributes.should == {
|
151
|
-
name: "chicken supreme",
|
152
|
-
image_url: "chicken.jpg",
|
153
|
-
price: '1.23',
|
154
|
-
ingredients: ['corn', 'tomato'],
|
155
|
-
ingredient_urls: []
|
156
|
-
}
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
describe "to_json" do
|
161
|
-
it "should convert attributes to json" do
|
162
|
-
first_pizza = ::Pizza.first
|
163
|
-
first_pizza.to_json.should == {
|
164
|
-
name: "chicken supreme",
|
165
|
-
image_url: "chicken.jpg",
|
166
|
-
price: '1.23',
|
167
|
-
ingredients: ['corn', 'tomato'],
|
168
|
-
ingredient_urls: []
|
169
|
-
}.to_json
|
170
|
-
end
|
171
|
-
|
172
|
-
it "should convert array to json" do
|
173
|
-
pizzas = ::Pizza.all
|
174
|
-
pizzas.to_json.should == [
|
175
|
-
{name: "chicken supreme", image_url: "chicken.jpg", price: '1.23', ingredients: ['corn', 'tomato'], :ingredient_urls => []},
|
176
|
-
{name: "veg supreme", image_url: "veg.jpg", price: '2.34', ingredients: ['mushroom', 'jalapeno'], :ingredient_urls => []},
|
177
|
-
{name: "pepperoni", image_url: "pepperoni.jpg", price: '3.45', ingredients: [], :ingredient_urls => []},
|
178
|
-
{name: "chicken golden delight", image_url: "golden.jpg", price: '4.56', ingredients: [], :ingredient_urls => ['chicken.html', 'delight.html']},
|
179
|
-
].to_json
|
180
|
-
end
|
181
|
-
end
|
5
|
+
it_should_behave_like "Scrapify", ::Pizza
|
182
6
|
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
shared_examples_for "Scrapify" do |klass_or_object|
|
2
|
+
before do
|
3
|
+
@pizza_url = "http://www.dominos.co.in/menuDetails_ajx.php?catgId=1"
|
4
|
+
FakeWeb.register_uri :get, @pizza_url,
|
5
|
+
:cache_control => "private, s-maxage=0, max-age=0, must-revalidate",
|
6
|
+
:age => 51592,
|
7
|
+
:length => 12312,
|
8
|
+
:body => <<-HTML
|
9
|
+
<ul class="menu_lft">
|
10
|
+
<li>
|
11
|
+
<a> chicken supreme </a><input value="chicken.jpg">
|
12
|
+
<span class='price'>(1.23)</span>
|
13
|
+
<span class='ingredients'>
|
14
|
+
<ol>
|
15
|
+
<li>contains corn</li>
|
16
|
+
<li>contains tomato</li>
|
17
|
+
<ol>
|
18
|
+
</span>
|
19
|
+
<span class='references'><ol><li></li></ol></span
|
20
|
+
</li>
|
21
|
+
<li>
|
22
|
+
<a>veg supreme</a><input value="veg.jpg">
|
23
|
+
<span class='price'>(2.34)</span>
|
24
|
+
<span class='ingredients'>
|
25
|
+
<ol>
|
26
|
+
<li>contains mushroom</li>
|
27
|
+
<li>contains jalapeno</li>
|
28
|
+
<ol>
|
29
|
+
</span>
|
30
|
+
<span class='references'><ol><li></li></ol></span
|
31
|
+
</li>
|
32
|
+
<li>
|
33
|
+
<a>pepperoni</a><input value="pepperoni.jpg">
|
34
|
+
<span class='price'>(3.45)</span>
|
35
|
+
<span class='ingredients'></span>
|
36
|
+
<span class='references'><ol><li></li></ol></span
|
37
|
+
</li>
|
38
|
+
<li>
|
39
|
+
<a>chicken golden delight</a><input value="golden.jpg">
|
40
|
+
<span class='price'>(4.56)</span>
|
41
|
+
<span class='ingredients'/>
|
42
|
+
<span class='references'>
|
43
|
+
<ol>
|
44
|
+
<li>
|
45
|
+
<div href='chicken.html'>chicken</div>
|
46
|
+
<div href='delight.html'>delight</div>
|
47
|
+
</li>
|
48
|
+
</ol>
|
49
|
+
</span>
|
50
|
+
</li>
|
51
|
+
</ul>
|
52
|
+
HTML
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should return attribute names" do
|
56
|
+
klass_or_object.attribute_names.should == [:name, :image_url, :price, :ingredients, :ingredient_urls]
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "html" do
|
60
|
+
it "should store url" do
|
61
|
+
klass_or_object.url.should == @pizza_url
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should parse html and fetch attributes using css" do
|
65
|
+
klass_or_object.name_values.should == ['chicken supreme', 'veg supreme', 'pepperoni', 'chicken golden delight']
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should parse html and fetch attributes using xpath" do
|
69
|
+
klass_or_object.image_url_values.should == ['chicken.jpg', 'veg.jpg', 'pepperoni.jpg', 'golden.jpg']
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should parse html and extract attributes using regex" do
|
73
|
+
klass_or_object.price_values.should == ['1.23', '2.34', '3.45', '4.56']
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should parse html and extract multiple attributes using regex" do
|
77
|
+
klass_or_object.ingredients_values.should == [['corn','tomato'], ['mushroom','jalapeno'], [], []]
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should accept block to yield attribute values' do
|
81
|
+
klass_or_object.ingredient_urls_values.should == [[], [], [], ['chicken.html', 'delight.html']]
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should strip content" do
|
85
|
+
klass_or_object.first.name.should == 'chicken supreme'
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "cache headers" do
|
89
|
+
it "should return the http headers" do
|
90
|
+
klass_or_object.http_cache_header.should == {
|
91
|
+
"cache-control" => "private, s-maxage=0, max-age=0, must-revalidate",
|
92
|
+
"age" => 51592,
|
93
|
+
}
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "find" do
|
99
|
+
it "should find element by key" do
|
100
|
+
pizza = klass_or_object.find('pepperoni')
|
101
|
+
pizza.should_not be_nil
|
102
|
+
pizza.name.should == 'pepperoni'
|
103
|
+
pizza.image_url.should == 'pepperoni.jpg'
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should be nil if element does not exist" do
|
107
|
+
pizza = klass_or_object.find('mushroom')
|
108
|
+
pizza.should be_nil
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "first" do
|
113
|
+
it "should fetch first matching element" do
|
114
|
+
first_pizza = klass_or_object.first
|
115
|
+
first_pizza.name.should == 'chicken supreme'
|
116
|
+
first_pizza.image_url.should == 'chicken.jpg'
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "last" do
|
121
|
+
it "should fetch last matching element" do
|
122
|
+
last_pizza = klass_or_object.last
|
123
|
+
last_pizza.name.should == 'chicken golden delight'
|
124
|
+
last_pizza.image_url.should == 'golden.jpg'
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe "all" do
|
129
|
+
it "should fetch all objects" do
|
130
|
+
pizzas = klass_or_object.all
|
131
|
+
pizzas.size.should == 4
|
132
|
+
pizzas.map(&:name).should == ['chicken supreme', 'veg supreme', 'pepperoni', 'chicken golden delight']
|
133
|
+
pizzas.map(&:image_url).should == ['chicken.jpg', 'veg.jpg', 'pepperoni.jpg', 'golden.jpg']
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe "count" do
|
138
|
+
it "should return number of matching elements" do
|
139
|
+
klass_or_object.count.should == 4
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe "attributes" do
|
144
|
+
it "should return attributes hash" do
|
145
|
+
first_pizza = klass_or_object.first
|
146
|
+
first_pizza.attributes.should == {
|
147
|
+
name: "chicken supreme",
|
148
|
+
image_url: "chicken.jpg",
|
149
|
+
price: '1.23',
|
150
|
+
ingredients: ['corn', 'tomato'],
|
151
|
+
ingredient_urls: []
|
152
|
+
}
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "to_json" do
|
157
|
+
it "should convert attributes to json" do
|
158
|
+
first_pizza = klass_or_object.first
|
159
|
+
first_pizza.to_json.should == {
|
160
|
+
name: "chicken supreme",
|
161
|
+
image_url: "chicken.jpg",
|
162
|
+
price: '1.23',
|
163
|
+
ingredients: ['corn', 'tomato'],
|
164
|
+
ingredient_urls: []
|
165
|
+
}.to_json
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should convert array to json" do
|
169
|
+
pizzas = klass_or_object.all
|
170
|
+
pizzas.to_json.should == [
|
171
|
+
{name: "chicken supreme", image_url: "chicken.jpg", price: '1.23', ingredients: ['corn', 'tomato'], :ingredient_urls => []},
|
172
|
+
{name: "veg supreme", image_url: "veg.jpg", price: '2.34', ingredients: ['mushroom', 'jalapeno'], :ingredient_urls => []},
|
173
|
+
{name: "pepperoni", image_url: "pepperoni.jpg", price: '3.45', ingredients: [], :ingredient_urls => []},
|
174
|
+
{name: "chicken golden delight", image_url: "golden.jpg", price: '4.56', ingredients: [], :ingredient_urls => ['chicken.html', 'delight.html']},
|
175
|
+
].to_json
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scrapify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-28 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70233941360460 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70233941360460
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: mocha
|
27
|
-
requirement: &
|
27
|
+
requirement: &70233941359980 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70233941359980
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: fakeweb
|
38
|
-
requirement: &
|
38
|
+
requirement: &70233941359460 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70233941359460
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: nokogiri
|
49
|
-
requirement: &
|
49
|
+
requirement: &70233941358800 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70233941358800
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: activesupport
|
60
|
-
requirement: &
|
60
|
+
requirement: &70233941358220 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70233941358220
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: json
|
71
|
-
requirement: &
|
71
|
+
requirement: &70233941351380 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70233941351380
|
80
80
|
description: ScrApify scraps static html sites to RESTlike APIs
|
81
81
|
email:
|
82
82
|
- sathish316@gmail.com
|
@@ -88,15 +88,18 @@ files:
|
|
88
88
|
- Gemfile
|
89
89
|
- README.md
|
90
90
|
- Rakefile
|
91
|
+
- examples/pizza.rb
|
91
92
|
- lib/jsonify.rb
|
92
|
-
- lib/meta_define.rb
|
93
93
|
- lib/scrapify.rb
|
94
94
|
- lib/scrapify/base.rb
|
95
|
+
- lib/scrapify/scraper.rb
|
95
96
|
- lib/scrapify/version.rb
|
96
97
|
- scrapify.gemspec
|
97
98
|
- spec/jsonify_spec.rb
|
98
99
|
- spec/pizza.rb
|
100
|
+
- spec/scraper_spec.rb
|
99
101
|
- spec/scrapify_spec.rb
|
102
|
+
- spec/shared/scrapify.rb
|
100
103
|
- spec/spec_helper.rb
|
101
104
|
- spec/test_models.rb
|
102
105
|
homepage: http://www.github.com/sathish316/scrapify
|
@@ -126,6 +129,8 @@ summary: ScrApify scraps static html sites to scraESTlike APIs
|
|
126
129
|
test_files:
|
127
130
|
- spec/jsonify_spec.rb
|
128
131
|
- spec/pizza.rb
|
132
|
+
- spec/scraper_spec.rb
|
129
133
|
- spec/scrapify_spec.rb
|
134
|
+
- spec/shared/scrapify.rb
|
130
135
|
- spec/spec_helper.rb
|
131
136
|
- spec/test_models.rb
|