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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00a15246f890ec0e86c79adcc384740378b24418
4
- data.tar.gz: 16cc876e652b9b6452b2d81f1257a2182d792498
3
+ metadata.gz: ceed3b1d12a46cf059955e172ae431fdbf10dab2
4
+ data.tar.gz: 5c9c56bb17eb687bc988ef119f644581c51a8720
5
5
  SHA512:
6
- metadata.gz: 3a58b16d89e385b081903060f17cb7399ffe70564c1b3d8c6642d4814f4ffbefa89027b128251a73f79abb4177f46d9e95e58f2c2b7a43c7f59215c97772914d
7
- data.tar.gz: e3f83b487b771ac0c60b5754c07bf9bc23028373f21015d24a9004e0b409dd4fe00b046da1a9b885ac354e2161cbb8054af70259650c2f2312d175f07611916c
6
+ metadata.gz: 979907b36ff4f8142c7ddd017867e37f38f52d2a1d558c90806af5c845fe086942d86f62ef37fcb5520faa4c52526e24b075496d5c63ba791b608a900c62cefb
7
+ data.tar.gz: 71ad3afc1c32ff88561558271c7ffa1865117e52e9e531c1d33a8601d38d2610645a0b754d3d70e775794ff07455de2c717f536575ab06e2616ddf909c829ef8
data/README.md CHANGED
@@ -8,7 +8,7 @@ This Ruby gem provides a CLI to view details on membership costume standards for
8
8
 
9
9
  ## Usage
10
10
 
11
- Run and follow the on-screen prompts!
11
+ Run by typing "rebel_legion" and follow the on-screen prompts!
12
12
 
13
13
  ## Development
14
14
 
@@ -3,7 +3,6 @@ class RebelLegion::CLI
3
3
 
4
4
  def call
5
5
  RebelLegion::Scraper.new
6
- # would be nice to have a loading bar here...
7
6
  input = nil
8
7
  welcome
9
8
  view_category_list
@@ -1,5 +1,5 @@
1
1
  class RebelLegion::Costume
2
- attr_accessor :name, :url, :details # probably a bunch more
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
- i = 0
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
- i = 0
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
@@ -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
- RebelLegion::Costume.new(costume.css("h2.et_pt_title a").text, costume_category, costume.css("h2.et_pt_title a").attribute("href").value)
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
@@ -1,3 +1,3 @@
1
1
  module RebelLegion
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -4,8 +4,4 @@ describe RebelLegion do
4
4
  it 'has a version number' do
5
5
  expect(Rebellegion::VERSION).not_to be nil
6
6
  end
7
-
8
- it 'does something useful' do
9
- expect(false).to eq(true)
10
- end
11
7
  end
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.2
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-02-24 00:00:00.000000000 Z
11
+ date: 2016-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler