rebel_legion 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/rebel_legion/cli.rb +0 -1
- data/lib/rebel_legion/costume.rb +2 -4
- data/lib/rebel_legion/costume_category.rb +6 -3
- data/lib/rebel_legion/scraper.rb +7 -5
- data/lib/rebel_legion/version.rb +1 -1
- data/spec/rebel_legion_spec.rb +0 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ceed3b1d12a46cf059955e172ae431fdbf10dab2
|
4
|
+
data.tar.gz: 5c9c56bb17eb687bc988ef119f644581c51a8720
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 979907b36ff4f8142c7ddd017867e37f38f52d2a1d558c90806af5c845fe086942d86f62ef37fcb5520faa4c52526e24b075496d5c63ba791b608a900c62cefb
|
7
|
+
data.tar.gz: 71ad3afc1c32ff88561558271c7ffa1865117e52e9e531c1d33a8601d38d2610645a0b754d3d70e775794ff07455de2c717f536575ab06e2616ddf909c829ef8
|
data/README.md
CHANGED
data/lib/rebel_legion/cli.rb
CHANGED
data/lib/rebel_legion/costume.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class RebelLegion::Costume
|
2
|
-
attr_accessor :name, :url, :details
|
2
|
+
attr_accessor :name, :url, :details
|
3
3
|
attr_reader :costume_category
|
4
4
|
|
5
5
|
@@all = []
|
@@ -22,9 +22,7 @@ class RebelLegion::Costume
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def view_details
|
25
|
-
|
26
|
-
details.each do |detail|
|
27
|
-
i += 1
|
25
|
+
details.each.with_index(1) do |detail, i|
|
28
26
|
puts "#{i}. ".colorize(:yellow) + "#{detail}"
|
29
27
|
end
|
30
28
|
puts "For more info, visit #{url.colorize(:light_cyan)}"
|
@@ -27,11 +27,14 @@ class RebelLegion::CostumeCategory
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def display_costume_names
|
30
|
-
|
31
|
-
costumes.each do |costume|
|
32
|
-
i += 1
|
30
|
+
RebelLegion::Scraper.scrape_costumes_for_category(self) if costumes.empty?
|
31
|
+
costumes.each.with_index(1) do |costume, i|
|
33
32
|
puts "#{i}. ".colorize(:yellow) + "#{costume.name}"
|
34
33
|
end
|
35
34
|
end
|
36
35
|
|
36
|
+
def new_costume(name, url)
|
37
|
+
RebelLegion::Costume.new(name, self, url)
|
38
|
+
end
|
39
|
+
|
37
40
|
end
|
data/lib/rebel_legion/scraper.rb
CHANGED
@@ -7,8 +7,6 @@ class RebelLegion::Scraper
|
|
7
7
|
@costume_pages = {}
|
8
8
|
get_categories("http://www.rebellegion.com/costume-standards/by-category/")
|
9
9
|
make_costume_categories
|
10
|
-
get_and_make_costumes
|
11
|
-
get_costume_details
|
12
10
|
end
|
13
11
|
|
14
12
|
def get_categories(url) # gets the main costume category list
|
@@ -26,18 +24,22 @@ class RebelLegion::Scraper
|
|
26
24
|
|
27
25
|
def get_and_make_costumes # collects titles & urls of costume pages, sends to Costume class
|
28
26
|
RebelLegion::CostumeCategory.all.each do |costume_category|
|
27
|
+
self.class.scrape_costumes_for_category(costume_category)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.scrape_costumes_for_category(costume_category)
|
29
32
|
doc = Nokogiri::HTML(open(costume_category.url))
|
30
33
|
doc.css("div#left-area article.entry-content.clearfix div.et_pt_blogentry.clearfix").each do |costume|
|
31
|
-
|
34
|
+
costume_category.new_costume(costume.css("h2.et_pt_title a").text, costume.css("h2.et_pt_title a").attribute("href").value)
|
32
35
|
end
|
33
|
-
end
|
34
36
|
end
|
35
37
|
|
36
38
|
def get_costume_details # scrapes each costume's details and sends to that costume
|
37
39
|
RebelLegion::Costume.all.each do |costume|
|
38
40
|
doc = Nokogiri::HTML(open(costume.url))
|
39
41
|
doc.css("div#left-area article.entry-content.clearfix div.et-box.et-shadow div.et-box-content").each do |item|
|
40
|
-
if !item.css("ol li").empty?
|
42
|
+
if !item.css("ol li").empty? # edge case
|
41
43
|
item.css("ol li").each { |subitem| costume.details << subitem.text }
|
42
44
|
else
|
43
45
|
costume.details << item.text
|
data/lib/rebel_legion/version.rb
CHANGED
data/spec/rebel_legion_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rebel_legion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shinyrachel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|