-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
55 lines (45 loc) · 1.53 KB
/
Copy pathRakefile
File metadata and controls
55 lines (45 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require 'bundler/setup'
require 'psych'
require 'yaml'
require 'heroku_san'
namespace :assets do
task :precompile do
sh 'middleman build'
end
end
module HerokuSan::Deploy
class JRubyConf < Sinatra
def deploy
super
#@stage.rake('utils:update_sitemap')
#@stage.rake('utils:update_attendees')
end
end
end
config_file = File.join(File.expand_path(File.dirname(__FILE__)), 'config', 'heroku.yml')
HerokuSan.project = HerokuSan::Project.new(config_file, :deploy => HerokuSan::Deploy::JRubyConf)
load 'heroku_san/tasks.rb'
require 'nokogiri'
require 'open-uri'
require 'yaml'
namespace :utils do
desc "Update attendees list with data from Lanyrd.com"
task :update_attendees do
data = lanyrd_attendees.to_yaml
File.open('data/attendees.yml', 'w') {|f| f.write(data) }
end
# scrapes eurucamp page on lanyrd.com and returns
# array of Twitter names
def lanyrd_attendees
profile_selector = '.primary .mini-profile .name a'.freeze
pagination_selector = '.pagination li a'.freeze
base_url = 'http://lanyrd.com'.freeze
first_page_path = '/2013/jrubyconf/attendees/'.freeze
first_page = Nokogiri::HTML(open(base_url + first_page_path))
other_pages_paths = first_page.css(pagination_selector).map { |a| a[:href] }
(other_pages_paths << first_page_path).map do |relative_path|
page = Nokogiri::HTML(open(base_url + relative_path))
page.css(profile_selector).map {|a| a['href'].gsub(/^\/profile\/|\/$/,'') }
end.flatten.sort
end
end