ethical_clothing 0.2.0

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: 6d273dfb0f5e7403525be8237341fdfa6bc07ff6
4
+ data.tar.gz: 18f110031a27997870646a5b599dbda0d2f35f6d
5
+ SHA512:
6
+ metadata.gz: d51d47698337fdd4e06e60b17a2104a953c3a839ae33ccd9d6d6772d384954606d95a311af16faac1bb8430ce0c39be0952c5391ba38ba6082abd5d7b5ccdbb5
7
+ data.tar.gz: dc7c950548c33274490a6758f2232a6137b232b3187befdf12d9ce1bc17b6ccb23340be0f95fd82dd8be863c28fbfe52af9b490c0dc9eae171e6fe7e8f5d832e
data/.DS_Store ADDED
Binary file
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at katleiahramos@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'poltergeist', :require => 'phantomjs/poltergeist'
4
+ gem 'phantomjs'
5
+ gem 'pry'
6
+
7
+
8
+
9
+
10
+ # git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
11
+ #
12
+ # # Specify your gem's dependencies in ethical_clothing.gemspec
13
+ # gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,47 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.5.2)
5
+ public_suffix (>= 2.0.2, < 4.0)
6
+ capybara (2.18.0)
7
+ addressable
8
+ mini_mime (>= 0.1.3)
9
+ nokogiri (>= 1.3.3)
10
+ rack (>= 1.0.0)
11
+ rack-test (>= 0.5.4)
12
+ xpath (>= 2.0, < 4.0)
13
+ cliver (0.3.2)
14
+ coderay (1.1.2)
15
+ method_source (0.9.0)
16
+ mini_mime (1.0.0)
17
+ mini_portile2 (2.3.0)
18
+ nokogiri (1.8.2)
19
+ mini_portile2 (~> 2.3.0)
20
+ phantomjs (2.1.1.0)
21
+ poltergeist (1.17.0)
22
+ capybara (~> 2.1)
23
+ cliver (~> 0.3.1)
24
+ websocket-driver (>= 0.2.0)
25
+ pry (0.11.3)
26
+ coderay (~> 1.1.0)
27
+ method_source (~> 0.9.0)
28
+ public_suffix (3.0.2)
29
+ rack (2.0.4)
30
+ rack-test (1.0.0)
31
+ rack (>= 1.0, < 3)
32
+ websocket-driver (0.7.0)
33
+ websocket-extensions (>= 0.1.0)
34
+ websocket-extensions (0.1.3)
35
+ xpath (3.0.0)
36
+ nokogiri (~> 1.8)
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ phantomjs
43
+ poltergeist
44
+ pry
45
+
46
+ BUNDLED WITH
47
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Katleiah
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,50 @@
1
+ # EthicalClothing
2
+
3
+ This [Ruby Gem](https://rubygems.org/gems/ethical_clothing/) provides a CLI to view a list of ethical clothing brands and get the brand's information.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ethical_clothing'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ethical_clothing
20
+
21
+ If you are using this gem on a MAC, install Phantom JS using the instructions below:
22
+
23
+ - Homebrew: ```$ brew install phantomjs```
24
+ - MacPorts: ```$ sudo port install phantomjs```
25
+
26
+ ## Usage
27
+
28
+ Type the following line and follow the on-screen prompts.
29
+
30
+ ```ruby
31
+ $ ethical-clothing
32
+ ```
33
+
34
+ ## Development
35
+
36
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
37
+
38
+ 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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/katleiahramos/ethical_clothing. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
47
+
48
+ ## Code of Conduct
49
+
50
+ Everyone interacting in the EthicalClothing project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/katleiahramos/ethical_clothing/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #require "bundler/setup"
4
+ require "../lib/ethical_clothing"
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(__FILE__)
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ require '../lib/ethical_clothing'
3
+
4
+ #
5
+ puts "---------Welcome to the Ethical Clothing ClI App-----------"
6
+ puts "A few things to note: "
7
+ puts ""
8
+ puts "Ethical fashion (or slow fashion or sustainable fashion) simply means that the retailer is transparent about where they're sourcing their clothes, that they pay fairly, and use materials that are organic, un-harmful, or recycled when possible. "
9
+ puts ""
10
+ puts "....one moment, we are collecting your brands..."
11
+ puts ""
12
+ EthicalClothing::Scraper.get_and_create_brands
13
+ puts ""
14
+ puts ".........."
15
+ puts ""
16
+ puts "....."
17
+ puts ""
18
+ EthicalClothing::Scraper.match
19
+
20
+ EthicalClothing::CLI.new.call
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
Binary file
@@ -0,0 +1,33 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "ethical_clothing/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ethical_clothing"
8
+ spec.version = EthicalClothing::VERSION
9
+ spec.authors = ["Katleiah"]
10
+ spec.email = ["katleiahramos@gmail.com"]
11
+ spec.summary = %q{Access to a list of ethical clothing brands and their information.}
12
+ spec.homepage = "https://github.com/katleiahramos/ethical_clothing-CLI-app"
13
+ spec.license = "MIT"
14
+
15
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
16
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
17
+ # if spec.respond_to?(:metadata)
18
+ # spec.metadata["allowed_push_host"] = ": Set to 'http://mygemserver.com'"
19
+ # else
20
+ # raise "RubyGems 2.0 or newer is required to protect against " \
21
+ # "public gem pushes."
22
+ # end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
25
+ f.match(%r{^(test|spec|features)/})
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.16"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ end
@@ -0,0 +1,29 @@
1
+ require_relative './scraper.rb'
2
+
3
+ class EthicalClothing::Brand
4
+ attr_accessor :name, :description
5
+ attr_reader :price_range, :url
6
+
7
+
8
+ @@all = []
9
+
10
+ def initialize(name, price_range, url)
11
+ @name = name
12
+ @price_range = price_range
13
+ @url = url
14
+ self.save
15
+ end
16
+
17
+
18
+
19
+ def self.all
20
+ @@all
21
+ end
22
+
23
+
24
+ def save
25
+ @@all << self
26
+ end
27
+
28
+
29
+ end
@@ -0,0 +1,63 @@
1
+ class EthicalClothing::CLI
2
+ def call
3
+ list_brands
4
+ menu
5
+ end
6
+
7
+
8
+
9
+
10
+ def list_brands
11
+ brands_sorted = EthicalClothing::Brand.all.sort_by {|brand| brand.name}
12
+ puts ""
13
+ puts "---------- Ethical Clothing Brands: ----------"
14
+ puts ""
15
+ brands_sorted.each_with_index do |brand, index|
16
+ puts "#{index + 1}. #{brand.name}"
17
+ end
18
+ puts ""
19
+ end
20
+
21
+
22
+ def menu
23
+ input = nil
24
+ while input != 'exit'
25
+ puts ""
26
+ puts "Enter the number of a brand to see more details, or type 'list' to see the list of brands, or type 'exit'."
27
+ puts ""
28
+ input = gets.strip.downcase.gsub("'", "")
29
+
30
+ #checks for valid input (integer that exists as an index in array of all brands)
31
+ if input.to_i > 0 && EthicalClothing::Brand.all[input.to_i - 1 ]
32
+ brands_sorted = EthicalClothing::Brand.all.sort_by {|brand| brand.name}
33
+ brand = brands_sorted[input.to_i - 1]
34
+ puts ""
35
+ puts "-------------#{brand.name}------------------"
36
+ puts ""
37
+ puts "Price Range | #{brand.price_range}"
38
+ puts ""
39
+ puts "Description | #{brand.description}"
40
+ puts ""
41
+ puts "Webiste | #{brand.url} "
42
+ puts ""
43
+ puts ""
44
+ elsif input == 'list'
45
+ list_brands
46
+ elsif input == 'exit'
47
+ puts ""
48
+ puts "Goodbye!"
49
+ puts ""
50
+ else
51
+ puts ""
52
+ puts "Sorry, I don't recognize that input."
53
+ end
54
+ end
55
+
56
+
57
+ end
58
+
59
+
60
+
61
+
62
+
63
+ end
@@ -0,0 +1,76 @@
1
+
2
+ require_relative './brands.rb'
3
+ require 'pry'
4
+ require 'capybara/poltergeist'
5
+
6
+
7
+ class EthicalClothing::Scraper
8
+
9
+ #scrape page and instantiate brands
10
+ def self.get_and_create_brands
11
+ session = Capybara::Session.new(:poltergeist)
12
+ session.visit("http://simplylivandco.com/blog/best-places-to-buy-affordable-ethical-fashion")
13
+ brand_elements = session.all("h3")
14
+
15
+ brand_elements.each do |element|
16
+ #grab brand name, price, and url
17
+ #Skip any element that is not a brand
18
+ if element.text.include?(':')
19
+ info = element.text.split(':')
20
+ name = info[0]
21
+ price = info[1]
22
+ url = element.first('a')['href']
23
+
24
+ brand = EthicalClothing::Brand.new(name, price, url)
25
+
26
+ else
27
+ nil
28
+ end
29
+ end
30
+ nil
31
+ end
32
+
33
+ #scrape website for description
34
+ def self.get_description
35
+ session = Capybara::Session.new(:poltergeist)
36
+ session.visit("http://simplylivandco.com/blog/best-places-to-buy-affordable-ethical-fashion")
37
+ desc_holder = []
38
+ desc_elements = session.all("p")
39
+
40
+ desc_elements.each do |element|
41
+ if element.text == ""
42
+ element = "Not Available"
43
+ else
44
+ desc_holder << element.text
45
+ end
46
+ end
47
+
48
+ #get rid of extra elements that are not descriptions
49
+ 3.times do
50
+ desc_holder.shift
51
+ end
52
+ desc_holder
53
+
54
+
55
+ end
56
+
57
+ #Add description as attribute to to brand instance
58
+ def self.match
59
+ descs = self.get_description
60
+ brands = EthicalClothing::Brand.all
61
+
62
+ #iterate through brands and descriptions and match them based on index
63
+ i = 0
64
+ brands.each do |brand|
65
+ j = 0
66
+ descs.each do |desc|
67
+ brand.description = desc if i == j
68
+ j += 1
69
+ end
70
+ i += 1
71
+ end
72
+ #Get rid of second "Bamboo Body that appears twice on website list"
73
+ EthicalClothing::Brand.all.delete_at(39)
74
+ end
75
+
76
+ end
@@ -0,0 +1,3 @@
1
+ module EthicalClothing
2
+ VERSION = "0.2.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ require_relative './ethical_clothing/version.rb'
2
+ require_relative './ethical_clothing/cli.rb'
3
+ require_relative './ethical_clothing/brands.rb'
4
+ require_relative './ethical_clothing/scraper.rb'
5
+
6
+ #acts as environment,
data/spec.md ADDED
@@ -0,0 +1,6 @@
1
+ # Specifications for the CLI Assessment
2
+
3
+ Specs:
4
+ - [x] Have a CLI for interfacing with the application
5
+ - [x] Pull data from an external source
6
+ - [x] Implement both list and detail views
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ethical_clothing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Katleiah
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-05-08 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
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
+ description:
42
+ email:
43
+ - katleiahramos@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".DS_Store"
49
+ - CODE_OF_CONDUCT.md
50
+ - Gemfile
51
+ - Gemfile.lock
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - bin/console
56
+ - bin/ethical-clothing
57
+ - bin/setup
58
+ - ethical_clothing-0.1.0.gem
59
+ - ethical_clothing.gemspec
60
+ - lib/ethical_clothing.rb
61
+ - lib/ethical_clothing/brands.rb
62
+ - lib/ethical_clothing/cli.rb
63
+ - lib/ethical_clothing/scraper.rb
64
+ - lib/ethical_clothing/version.rb
65
+ - spec.md
66
+ homepage: https://github.com/katleiahramos/ethical_clothing-CLI-app
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.6.14
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Access to a list of ethical clothing brands and their information.
90
+ test_files: []