scrapers 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9714ca4691bf79afd82dd1bac8588919703faf66
4
- data.tar.gz: 2de713c77701348724b080af2d039739c2e33b67
3
+ metadata.gz: 4896b8aea0625256112a05ca839b9b9775a4ff85
4
+ data.tar.gz: 994a36cc3a5b97eda32c53838c2f519a008e8f0f
5
5
  SHA512:
6
- metadata.gz: 1efecf60008126c24dee448e948ce49e9f187cac161732d5bb61ca171219e927116a05d799c676dbb789d0ed4e175837defe5889855076d3bad8090462249b25
7
- data.tar.gz: e8d1d51f9dae5a2072b3f3282704982f1ab3483f2727c9ebcbc3a0c70aa3b58d1f1a7588bbd439fe762978ad69acd3093f7237c3ab5e1a9b04eef7228951b28c
6
+ metadata.gz: 94d1e19c786ed926aaaa15c56d72fffcdf0157e25ec60cea8b4dd76313b72cf112da0297f39aefed7ab41a26c18589e96706815de0469795bc749450056171ad
7
+ data.tar.gz: 7368f28e2bf91a5063acc6e37a68285a87f3cbbf8de534d66218acde300f5e6fc28b7e7935daf5c4232d6a2056fbb9b087034aa5e324ed0b1e6f3f1ccf9e9de5
data/bin/new_scraper ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'bundler/setup'
4
+ require 'thor'
5
+ require 'scrapers'
6
+ require "active_support/core_ext/string/inflections"
7
+ require 'pry'
8
+
9
+ class NewScraper < Thor::Group
10
+ include Thor::Actions
11
+
12
+ argument :name
13
+ class_option :test_framework, :aliases => "-T", :default => :spec
14
+
15
+ def self.source_root
16
+ File.expand_path("../../", __FILE__)
17
+ end
18
+
19
+
20
+ def create_lib_file
21
+ template("templates/new_scraper.tt", "lib/scrapers/#{name.underscore}.rb")
22
+ end
23
+
24
+ def create_test_file
25
+
26
+ if %w[test_unit minitest test].include?(options["test_framework"])
27
+ test = "test"
28
+ else
29
+ test = "spec"
30
+ end
31
+
32
+ template("templates/new_scraper_#{test}.tt", "#{test}/scrapers/#{name.underscore}_#{test}.rb")
33
+ end
34
+
35
+ end
36
+
37
+ NewScraper.start
@@ -2,7 +2,7 @@ module Scrapers
2
2
  module Version
3
3
 
4
4
  MAJOR = 1
5
- MINOR = 3
5
+ MINOR = 4
6
6
  BUILD = 0
7
7
 
8
8
  end
@@ -0,0 +1,18 @@
1
+ # -*- ruby -*-
2
+ require 'mechanize'
3
+
4
+ module Scrapers
5
+ module <%= name %>
6
+
7
+ def self.scrape(url)
8
+ results = Hash.new
9
+
10
+ Mechanize.start(url) do |m|
11
+
12
+ end
13
+
14
+ results
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ # -*- ruby -*-
2
+ require 'spec_helper'
3
+ require 'scrapers/<%= name.underscore %>'
4
+
5
+ module Scrapers
6
+
7
+ describe <%= name %> do
8
+ it{should respond_to :scrape}
9
+ context "scraping" do
10
+ before(:all) do
11
+ @comic = VCR.use_cassette('<%= name.underscore %>') do
12
+ @result = Scrapers::<%= name %>.scrape
13
+ end
14
+ end
15
+
16
+ it {expect(@result).to_not be_nil}
17
+
18
+ end
19
+ end
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrapers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tamara Temple
@@ -169,6 +169,7 @@ description: A library of web site scrapers utilizing mechanize and other goodie
169
169
  email:
170
170
  - tamouse@gmail.com
171
171
  executables:
172
+ - new_scraper
172
173
  - rubytapas
173
174
  extensions: []
174
175
  extra_rdoc_files: []
@@ -180,6 +181,7 @@ files:
180
181
  - LICENSE.txt
181
182
  - README.md
182
183
  - Rakefile
184
+ - bin/new_scraper
183
185
  - bin/rubytapas
184
186
  - lib/scrapers.rb
185
187
  - lib/scrapers/allrecipes.rb
@@ -205,6 +207,8 @@ files:
205
207
  - spec/scrapers/xkcd_spec.rb
206
208
  - spec/scrapers_spec.rb
207
209
  - spec/spec_helper.rb
210
+ - templates/new_scraper.tt
211
+ - templates/new_scraper_spec.tt
208
212
  - vcr_cassettes/allrecipes_morning-glory-muffins-i.yml
209
213
  - vcr_cassettes/disconews_history-of-space.yml
210
214
  - vcr_cassettes/download-newfile.yml