rebel_legion 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fb9d88bb80d8d35a6e403bbaa91f629d9e0ca35d
4
+ data.tar.gz: ddc33755ba7c955ffe4b6642d0204039fad665ed
5
+ SHA512:
6
+ metadata.gz: d5c227528fb960cc0b65371583c60359aa094e0dd80b8be97e6995e6138720ec402ffae11dc239e0a88ff3680deb1eba588fa71e41db285ebd18da3b6768d215
7
+ data.tar.gz: 2815ed3df6d570bc8df3002aca60baa7dd92e9310cf958a87e0b732d2dddfa1c129b7a5892001e7130836819a4990f3a3358f34808d1636e0b6855bb84aa57ff
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rebellegion.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 shinyrachel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # RebelLegion
2
+
3
+ This Ruby gem provides a CLI to view details on membership costume standards for the Rebel Legion Star Wars "good guys" costuming organization.
4
+
5
+ ## Installation
6
+
7
+ $ gem install rebel_legion
8
+
9
+ ## Usage
10
+
11
+ Run and follow the on-screen prompts!
12
+
13
+ ## Development
14
+
15
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
16
+
17
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
18
+
19
+ ## Contributing
20
+
21
+ Bug reports and pull requests welcome: https://github.com/shinyrachel/rebel_legion
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rebellegion"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/rebel_legion ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/rebel_legion"
4
+
5
+ RebelLegion::CLI.new.call
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,9 @@
1
+ require "nokogiri"
2
+ require "open-uri"
3
+ require "colorize"
4
+
5
+ require_relative "../lib/rebel_legion/version"
6
+ require_relative "../lib/rebel_legion/cli"
7
+ require_relative "../lib/rebel_legion/scraper"
8
+ require_relative "../lib/rebel_legion/costume"
9
+ require_relative "../lib/rebel_legion/costume_category"
@@ -0,0 +1,59 @@
1
+ class RebelLegion::CLI
2
+ attr_accessor :current_category, :current_category_number
3
+
4
+ def call
5
+ RebelLegion::Scraper.new
6
+ # would be nice to have a loading bar here...
7
+ input = nil
8
+ welcome
9
+ view_category_list
10
+ goodbye
11
+ end
12
+
13
+ def welcome
14
+ puts "THE REBEL LEGION: An International Star Wars Costuming Organization!".colorize(:red)
15
+ puts "Welcome to the Rebel Legion Costume Standards Viewer."
16
+ end
17
+
18
+ def view_category_list
19
+ puts "Select a category of costumes to view by entering a number, or type 'exit':".colorize(:light_red)
20
+ RebelLegion::CostumeCategory.display_all_names
21
+ input = gets.strip
22
+ view_costume_list(input.to_i - 1) if input != "exit"
23
+ end
24
+
25
+ def view_costume_list(number)
26
+ @current_category_number = number
27
+ @current_category = RebelLegion::CostumeCategory.all[number]
28
+ current_category.display_costume_names
29
+ puts "To view a costume's standards for Rebel Legion membership, enter its number.".colorize(:light_red)
30
+ puts "To return to the main menu, enter 'main'. Or, type 'exit'.".colorize(:light_red)
31
+ input = gets.strip
32
+ unless input == "exit"
33
+ if input == "main"
34
+ view_category_list
35
+ else
36
+ view_costume_details(input.to_i - 1)
37
+ end
38
+ end
39
+ end
40
+
41
+ def view_costume_details(number)
42
+ @current_category.costumes[number].view_details
43
+ puts "To go back, enter 'back'.".colorize(:light_red)
44
+ puts "To return to the main menu, enter 'main'. Or, type 'exit'.".colorize(:light_red)
45
+ input = gets.strip
46
+ unless input == "exit"
47
+ case input
48
+ when "back"
49
+ view_costume_list(@current_category_number)
50
+ when "main"
51
+ view_category_list
52
+ end
53
+ end
54
+ end
55
+
56
+ def goodbye
57
+ puts "May the Force be with you...always.".colorize(:red)
58
+ end
59
+ end
@@ -0,0 +1,32 @@
1
+ class RebelLegion::Costume
2
+ attr_accessor :name, :url, :details # probably a bunch more
3
+ attr_reader :costume_category
4
+
5
+ @@all = []
6
+
7
+ def initialize(name, costume_category, url)
8
+ @name = name
9
+ self.costume_category = costume_category
10
+ @url = url
11
+ @details = []
12
+ @@all << self
13
+ end
14
+
15
+ def self.all
16
+ @@all
17
+ end
18
+
19
+ def costume_category=(category)
20
+ @costume_category = category
21
+ category.add_costume(self)
22
+ end
23
+
24
+ def view_details
25
+ i = 0
26
+ details.each do |detail|
27
+ i += 1
28
+ puts "#{i}. ".colorize(:yellow) + "#{detail}"
29
+ end
30
+ puts "For more info, visit #{url.colorize(:light_cyan)}"
31
+ end
32
+ end
@@ -0,0 +1,37 @@
1
+ class RebelLegion::CostumeCategory
2
+ attr_accessor :costumes, :name, :url
3
+
4
+ @@all = []
5
+
6
+ def initialize(name, url)
7
+ @name = name
8
+ @url = url
9
+ @costumes = []
10
+ @@all << self
11
+ end
12
+
13
+ def self.all
14
+ @@all
15
+ end
16
+
17
+ def self.display_all_names
18
+ i = 0
19
+ @@all.each do |category|
20
+ i += 1
21
+ puts "#{i}. ".colorize(:yellow) + "#{category.name}"
22
+ end
23
+ end
24
+
25
+ def add_costume(costume)
26
+ @costumes << costume
27
+ end
28
+
29
+ def display_costume_names
30
+ i = 0
31
+ costumes.each do |costume|
32
+ i += 1
33
+ puts "#{i}. ".colorize(:yellow) + "#{costume.name}"
34
+ end
35
+ end
36
+
37
+ end
@@ -0,0 +1,48 @@
1
+ class RebelLegion::Scraper
2
+ attr_accessor :categories
3
+
4
+ def initialize
5
+ puts "Loading....."
6
+ @categories = {}
7
+ @costume_pages = {}
8
+ get_categories("http://www.rebellegion.com/costume-standards/by-category/")
9
+ make_costume_categories
10
+ get_and_make_costumes
11
+ get_costume_details
12
+ end
13
+
14
+ def get_categories(url) # gets the main costume category list
15
+ doc = Nokogiri::HTML(open(url))
16
+ doc.css("div#left-area article.entry-content.clearfix p").each do |category|
17
+ categories[category.css("a").text] = category.css("a").attribute("href").value
18
+ end
19
+ end
20
+
21
+ def make_costume_categories # sends data to CostumeCategory class
22
+ categories.each do |name, url|
23
+ RebelLegion::CostumeCategory.new(name, url)
24
+ end
25
+ end
26
+
27
+ def get_and_make_costumes # collects titles & urls of costume pages, sends to Costume class
28
+ RebelLegion::CostumeCategory.all.each do |costume_category|
29
+ doc = Nokogiri::HTML(open(costume_category.url))
30
+ 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)
32
+ end
33
+ end
34
+ end
35
+
36
+ def get_costume_details # scrapes each costume's details and sends to that costume
37
+ RebelLegion::Costume.all.each do |costume|
38
+ doc = Nokogiri::HTML(open(costume.url))
39
+ 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?
41
+ item.css("ol li").each { |subitem| costume.details << subitem.text }
42
+ else
43
+ costume.details << item.text
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,3 @@
1
+ module RebelLegion
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ module RebelLegion
2
+ end
3
+
4
+ require_relative "../config/environment"
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require_relative './lib/rebel_legion/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rebel_legion"
8
+ spec.version = RebelLegion::VERSION
9
+ spec.authors = ["shinyrachel"]
10
+ spec.email = ["rachel.kory@gmail.com"]
11
+ spec.summary = "Rebel Legion costume standards viewer"
12
+ spec.description = "Provides details on membership costume standards for the Rebel Legion Star Wars 'good guys' costuming organization"
13
+ spec.homepage = "https://github.com/shinyrachel/rebel_legion"
14
+ spec.license = "MIT"
15
+ spec.executables << "rebel_legion"
16
+ spec.files = `git ls-files`.split($\)
17
+ spec.require_paths = ["lib"]
18
+ spec.bindir = 'bin'
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.9"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_dependency "nokogiri", "~> 0"
23
+ spec.add_dependency "colorize", "~> 0"
24
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe RebelLegion do
4
+ it 'has a version number' do
5
+ expect(Rebellegion::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'does something useful' do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'rebellegion'
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rebel_legion
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - shinyrachel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: colorize
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Provides details on membership costume standards for the Rebel Legion
70
+ Star Wars 'good guys' costuming organization
71
+ email:
72
+ - rachel.kory@gmail.com
73
+ executables:
74
+ - rebel_legion
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - ".travis.yml"
81
+ - CODE_OF_CONDUCT.md
82
+ - Gemfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/rebel_legion
88
+ - bin/setup
89
+ - config/environment.rb
90
+ - lib/rebel_legion.rb
91
+ - lib/rebel_legion/cli.rb
92
+ - lib/rebel_legion/costume.rb
93
+ - lib/rebel_legion/costume_category.rb
94
+ - lib/rebel_legion/scraper.rb
95
+ - lib/rebel_legion/version.rb
96
+ - rebel_legion.gemspec
97
+ - spec/rebel_legion_spec.rb
98
+ - spec/spec_helper.rb
99
+ homepage: https://github.com/shinyrachel/rebel_legion
100
+ licenses:
101
+ - MIT
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.4.6
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: Rebel Legion costume standards viewer
123
+ test_files: []