soa_codeschool 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 +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +14 -0
- data/LICENSE +0 -0
- data/README.md +5 -0
- data/Rakefile +5 -0
- data/bin/codeschool +5 -0
- data/codeschool.gemspec +23 -0
- data/lib/code_school.rb +47 -0
- data/lib/scrape.rb +10 -0
- data/lib/version.rb +6 -0
- data/spec/code_school_spec.rb +25 -0
- data/spec/fixtures/output.json +1 -0
- data/spec/fixtures/vcr/cassettes/codeschool.yml +33044 -0
- metadata +138 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 291813dfc9df57eb94173e399b5da5c1a751539b
|
4
|
+
data.tar.gz: cffcad4abee4df6783d34553b8070095e48cd38f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: abfa2fbaa6919af2fe2b3115a705c9b95c62de3faafcbae1e541ea394abc5ec12b162e95e412187bca4207d74214061dcacf8d007002c16427681c202e1500c4
|
7
|
+
data.tar.gz: 3d3396b93e74ab969063ce461f9fef8cf2ff527207f541cfe2be66f765bbc76c8e7130fff6f41a9f0c806014f52cb5c171fde4c9c769ccfb2bf8bce68c0f45b0
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
File without changes
|
data/README.md
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
# Team-HW-1-Ideate-and-Scrape[](https://travis-ci.org/pengyuchen/Team-HW-1-Ideate-and-Scrape)
|
2
|
+
|
3
|
+
- @stozuka created [original scraper code](https://gist.github.com/stozuka/b5ad519866a46387e4f2)
|
4
|
+
- @stonegold546 and @huangjr pair-refactored this code
|
5
|
+
- @pengyuchen @stozuka created the specs (pair-programmed)
|
data/Rakefile
ADDED
data/bin/codeschool
ADDED
data/codeschool.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
2
|
+
require 'version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'soa_codeschool'
|
6
|
+
s.version = CodeSchool::VERSION
|
7
|
+
s.date = CodeSchool::DATE
|
8
|
+
s.executables << 'codeschool'
|
9
|
+
s.summary = 'Access teacher and course information on CodeSchool'
|
10
|
+
s.description = 'show course and teacher on codeschool'
|
11
|
+
s.authors = ['stozuka', 'stonegold546','huangjr','pengyuchen']
|
12
|
+
s.email = ['stozuka@gmail.com','stozuka@gmail.com','jr@nlplab.cc', 'pengyu@gmail.com']
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files spec/*`.split("\n")
|
15
|
+
s.homepage = 'https://github.com/SOAupstart2/Team-HW-1-Ideate-and-Scrape'
|
16
|
+
s.license = 'MIT'
|
17
|
+
|
18
|
+
s.add_development_dependency 'minitest'
|
19
|
+
s.add_development_dependency 'minitest-rg'
|
20
|
+
s.add_development_dependency 'vcr'
|
21
|
+
s.add_development_dependency 'webmock'
|
22
|
+
s.add_runtime_dependency 'nokogiri'
|
23
|
+
end
|
data/lib/code_school.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
# Scraper for CodeSchool website
|
6
|
+
module CodeSchool
|
7
|
+
COURSES = 'https://www.codeschool.com/courses'
|
8
|
+
|
9
|
+
# Gets array of courses
|
10
|
+
def courses
|
11
|
+
Nokogiri::HTML(open(COURSES))
|
12
|
+
end
|
13
|
+
|
14
|
+
# Gets names of teacher(s) for one course
|
15
|
+
def teacher(name)
|
16
|
+
Nokogiri::HTML(open("#{COURSES}/#{name}"))
|
17
|
+
end
|
18
|
+
|
19
|
+
# Get an array of course names
|
20
|
+
def course_names
|
21
|
+
courses.xpath('//h2/a').map(&:text)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Change course names to urls
|
25
|
+
def course_urls
|
26
|
+
# Turn ' ', '.' to '-'
|
27
|
+
# Delete ':'
|
28
|
+
course_names.map do |name|
|
29
|
+
name.downcase.split(' ').join('-').tr('.', '-').delete(':')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Get teachar's name by visiting each course page
|
34
|
+
def teacher_names
|
35
|
+
course_urls.map do |course_url|
|
36
|
+
teacher(course_url).xpath('//h3/a').map(&:text)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# JSON array of course names (string) and teacher(s) (array)
|
41
|
+
def code_school_data
|
42
|
+
course_names.zip(teacher_names).map do |c_t|
|
43
|
+
# { course: c_t[0], teacher: c_t[1] }
|
44
|
+
{ c_t[0] => c_t[1] }
|
45
|
+
end.to_json
|
46
|
+
end
|
47
|
+
end
|
data/lib/scrape.rb
ADDED
data/lib/version.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'minitest/rg'
|
3
|
+
require 'vcr'
|
4
|
+
require 'webmock/minitest'
|
5
|
+
require_relative '../lib/scrape'
|
6
|
+
|
7
|
+
VCR.configure do |config|
|
8
|
+
config.cassette_library_dir = './spec/fixtures/vcr/cassettes'
|
9
|
+
config.hook_into :webmock
|
10
|
+
end
|
11
|
+
|
12
|
+
VCR.use_cassette('codeschool') do
|
13
|
+
|
14
|
+
codeschool = SiteScraper.new.code_school_data
|
15
|
+
golden = File.read('./spec/fixtures/output.json')
|
16
|
+
|
17
|
+
describe 'test for code school' do
|
18
|
+
it 'has same length' do
|
19
|
+
codeschool.size.must_equal golden.chomp.length
|
20
|
+
end
|
21
|
+
it 'should be same' do
|
22
|
+
JSON.parse(codeschool).must_equal JSON.parse(golden)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
[{"Adventures in Web Animations":["Alyssa Nicoll"]},{"Breaking the Ice With Regular Expressions":["Dan Bickford"]},{"The Sequel to SQL":["Gregg Pollack"]},{"Unmasking HTML Emails":["Dan Denney"]},{"Try SQL":["Chari Clark"]},{"Staying Sharp with Angular.js":["Alyssa Nicoll"]},{"Blasting Off with Bootstrap":["Adam Fortuna"]},{"Building Blocks of Express.js":["Carlos Souza"]},{"Front-end Foundations":["Jon Friskics"]},{"Mastering GitHub":["Peter Bell"]},{"JavaScript Best Practices":["Jason Millhouse"]},{"Shaping up with Angular.js":["Gregg Pollack"]},{"Exploring Google Maps for iOS":["Jon Friskics"]},{"Surviving APIs with Rails":["Carlos Souza"]},{"Discover Drive":["Gregg Pollack"]},{"Warming Up With Ember.js":["Adam Fortuna"]},{"JavaScript Road Trip Part 3":["Jason Millhouse"]},{"Front-end Formations":["Drew Barontini"]},{"Core iOS 7":["Jon Friskics","Eric Allam"]},{"JavaScript Road Trip Part 1":["Jason Millhouse"]},{"JavaScript Road Trip Part 2":["Jason Millhouse"]},{"Rails 4 Patterns":["Gregg Pollack","Carlos Souza"]},{"Fundamentals of Design":["Tim Dikun"]},{"jQuery: The Return Flight":["Gregg Pollack"]},{"iOS Operation: MapKit":["Jon Friskics"]},{"Try Objective-C":["Eric Allam"]},{"iOS Operation: Models":["Jon Friskics"]},{"Git Real 2":["Gregg Pollack"]},{"Rails 4: Zombie Outlaws":["Gregg Pollack","Carlos Souza"]},{"Discover DevTools":["Gregg Pollack"]},{"Try jQuery":["Gregg Pollack"]},{"Anatomy of Backbone.js Part 2":["Gregg Pollack"]},{"Assembling Sass Part 2":["Nick Walsh"]},{"Try iOS":["Gregg Pollack"]},{"Try R":["Jay McGavren"]},{"Ruby Bits Part 2":["Carlos Souza","Mark Kendall"]},{"Assembling Sass":["Nick Walsh"]},{"Ruby Bits":["Gregg Pollack"]},{"Git Real":["Gregg Pollack","Olivier Lacan"]},{"Try Git":["Gregg Pollack","Olivier Lacan"]},{"Testing with RSpec":["Gregg Pollack","Olivier Lacan"]},{"Real-time Web with Node.js":["Gregg Pollack","Carlos Souza"]},{"Anatomy of Backbone.js":["Eric Allam","Gregg Pollack"]},{"Journey Into Mobile":["Jason VanLue"]},{"Rails Testing for Zombies":["Nathaniel Bibler"]},{"CSS Cross-Country":["Nick Walsh","Aimee Simone"]},{"CoffeeScript":["Gregg Pollack","Carlos Souza"]},{"Rails for Zombies 2":["Gregg Pollack"]},{"Try Ruby":["Why The Lucky Stiff"]},{"Rails for Zombies Redux":["Gregg Pollack"]}]
|