Austins_Top_Yoga_Studios 0.1.1 → 0.2.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
  SHA256:
3
- metadata.gz: 15c980cd85611090db0ff3875f841aaf2e20d41b05e1c13765f62a3492ee2fee
4
- data.tar.gz: 4cc30b6569e3354a3949f3ffd3c2643c8b05b9b252d7a6b890616cba8a9be852
3
+ metadata.gz: edc672f4f2a17c381c3af66681d6d0b46cff4ad91c52458c4d92d16f13c63236
4
+ data.tar.gz: bd9bbb66fb239d0d0b31f51720cd651f3ff11394e6c5e95a173a0a04147a18d8
5
5
  SHA512:
6
- metadata.gz: 454c1dbd5484aac8225c442c0a8dd7cbf9679d55c8d5dea9ea1cbde7013921ae4371747427054dc43d63adc850325679743f4dd165a5f420e526f4a6786152ab
7
- data.tar.gz: c7333cc3d3200bb2e1ba7d165e248f009646ee5aff65bfebdf1bbac16a1431fe31cb722c0ae792ab93e4c60f4ad907725250ff0724c93112df893db987079d06
6
+ metadata.gz: ab85d2a269fd7c7899c75ff0a877f9693b9b6e52215dffc191944130c241965574bd3d57e969bb99508543a953cf5cb1f973dbc10b880eea3d06067887c561f6
7
+ data.tar.gz: 4df20be410e4241800c991dd71975045233625bc1b4c6a605477a5cb700ea2a16fc1e2609d8b5a44747d63a5dcbfea86de59142cd88e62a15c0de7d42329a267
data/Gemfile CHANGED
@@ -4,6 +4,3 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in Austins_Top_Yoga_Studios.gemspec
6
6
  gemspec
7
-
8
- gem 'Austins_Top_Yoga_Studios'
9
-
@@ -2,5 +2,6 @@ require 'open-uri'
2
2
  require 'nokogiri'
3
3
 
4
4
  require_relative './Austins_Top_Yoga_Studios/version'
5
+ require_relative './Austins_Top_Yoga_Studios/scraper'
5
6
  require_relative './Austins_Top_Yoga_Studios/studio'
6
- require_relative './Austins_Top_Yoga_Studios/cli'
7
+ require_relative './Austins_Top_Yoga_Studios/cli'
@@ -1,12 +1,12 @@
1
1
  class AustinsTopYogaStudios::CLI
2
-
2
+
3
3
  attr_reader :input
4
-
4
+
5
5
  def call
6
6
  menu
7
7
  goodbye
8
8
  end
9
-
9
+
10
10
  def list_studios
11
11
  puts "Here are 18 amazing yoga studios in Austin, Tx"
12
12
  sleep(1.8)
@@ -15,29 +15,29 @@ class AustinsTopYogaStudios::CLI
15
15
  puts "#{index}. #{s.name}"
16
16
  end
17
17
  end
18
-
19
-
18
+
19
+
20
20
  def menu
21
21
  while input != "exit"
22
- puts ""
23
- puts "Enter the number of which yoga studio you would like more information about or hit list to display the studios:"
24
-
25
- @input = gets.strip.downcase
26
-
22
+ puts ""
23
+ puts "Enter the number of which yoga studio you would like more information about or hit list to display the studios:"
24
+
25
+ @input = gets.strip.downcase
26
+
27
27
  if input == "list"
28
- list_studios
28
+ list_studios
29
29
  elsif input.to_i.between?(1, AustinsTopYogaStudios::Studio.all.length)
30
- the_studio = AustinsTopYogaStudios::Studio.all[input.to_i - 1]
31
- puts "#{the_studio.name} - #{the_studio.paragraph}"
30
+ the_studio = AustinsTopYogaStudios::Studio.all[input.to_i - 1]
31
+ puts "#{the_studio.name} - #{the_studio.paragraph}"
32
32
  elsif input == "exit"
33
- break
34
- else
35
- puts "Do not understand what you mean... type 1-18 or type exit to exit"
33
+ break
34
+ else
35
+ puts "Do not understand what you mean... type 1-18 or type exit to exit"
36
+ end
36
37
  end
37
- end
38
- end
39
-
40
- def goodbye
41
- puts "See you later! As always, namaste."
42
- end
43
- end
38
+ end
39
+
40
+ def goodbye
41
+ puts "See you later! As always, namaste."
42
+ end
43
+ end
@@ -0,0 +1,14 @@
1
+ class AustinsTopYogaStudios::Scraper
2
+
3
+ def self.scraper
4
+ doc = Nokogiri::HTML(open("https://fitt.co/austin/incredible-studios-practice-yoga-austin/"))
5
+ s = doc.css("li.list-loop__item")
6
+ s.collect do |studios|
7
+ studio = {}
8
+ studio[:name] = studios.css("h2.h2.list-loop__title").text
9
+ studio[:paragraph] = studios.css("div.list-loop__description.t-content").text.strip
10
+ studio
11
+ end
12
+ end
13
+
14
+ end
@@ -1,23 +1,19 @@
1
1
  class AustinsTopYogaStudios::Studio
2
-
2
+
3
3
  attr_accessor :name, :paragraph
4
4
 
5
-
6
- def self.scrape_and_create_from_page
7
- yogas = []
8
- doc = Nokogiri::HTML(open("https://fitt.co/austin/incredible-studios-practice-yoga-austin/"))
9
- s = doc.css("li.list-loop__item")
10
- s.each do |studios|
11
- studio = self.new
12
- studio.name = studios.css("h2.h2.list-loop__title").text
13
- studio.paragraph = studios.css("div.list-loop__description.t-content").text.strip
14
- yogas << studio
15
- end
16
- yogas
5
+ def initialize(name:, paragraph:)
6
+ @name = name
7
+ @paragraph = paragraph
17
8
  end
18
-
19
-
9
+
20
10
  def self.all
21
- self.scrape_and_create_from_page
11
+ @@all ||= self.load_from_scraper
12
+ end
13
+
14
+ def self.load_from_scraper
15
+ AustinsTopYogaStudios::Scraper.scraper.map do |studio_hash|
16
+ self.new(studio_hash)
17
+ end
22
18
  end
23
- end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module AustinsTopYogaStudios
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Austins_Top_Yoga_Studios
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "'grant smith'"
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-21 00:00:00.000000000 Z
11
+ date: 2019-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -89,6 +89,7 @@ files:
89
89
  - bin/setup
90
90
  - lib/Austins_Top_Yoga_Studios.rb
91
91
  - lib/Austins_Top_Yoga_Studios/cli.rb
92
+ - lib/Austins_Top_Yoga_Studios/scraper.rb
92
93
  - lib/Austins_Top_Yoga_Studios/studio.rb
93
94
  - lib/Austins_Top_Yoga_Studios/version.rb
94
95
  homepage: https://github.com/gsmith77/Austins_Top_Yoga_Studios
@@ -110,8 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
111
  - !ruby/object:Gem::Version
111
112
  version: '0'
112
113
  requirements: []
113
- rubyforge_project:
114
- rubygems_version: 2.7.8
114
+ rubygems_version: 3.0.2
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: '"Top Yoga Stuidos to Visit in Austin"'