From acd915ec810d2fbe08192be7a202dd81e2376065 Mon Sep 17 00:00:00 2001 From: Thibaut Date: Sat, 29 Nov 2014 17:48:42 -0500 Subject: [PATCH] DRY up Angular version --- lib/docs/filters/angular/clean_urls.rb | 4 ++-- lib/docs/scrapers/angular.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/docs/filters/angular/clean_urls.rb b/lib/docs/filters/angular/clean_urls.rb index 2925a6b3..4b187882 100644 --- a/lib/docs/filters/angular/clean_urls.rb +++ b/lib/docs/filters/angular/clean_urls.rb @@ -2,8 +2,8 @@ module Docs class Angular class CleanUrlsFilter < Filter def call - html.gsub! 'angularjs.org/1.3.4/docs/partials/api/', 'angularjs.org/1.3.4/docs/api/' - html.gsub! %r{angularjs.org/1.3.4/docs/api/(.+?)\.html}, 'angularjs.org/1.3.4/docs/api/\1' + html.gsub! "angularjs.org/#{Angular.version}/docs/partials/api/", "angularjs.org/#{Angular.version}/docs/api/" + html.gsub! %r{angularjs.org/#{Angular.version}/docs/api/(.+?)\.html}, "angularjs.org/#{Angular.version}/docs/api/\1" html end end diff --git a/lib/docs/scrapers/angular.rb b/lib/docs/scrapers/angular.rb index f390ca45..75628fd6 100644 --- a/lib/docs/scrapers/angular.rb +++ b/lib/docs/scrapers/angular.rb @@ -4,7 +4,7 @@ module Docs self.slug = 'angular' self.type = 'angular' self.version = '1.3.4' - self.base_url = 'https://code.angularjs.org/1.3.4/docs/partials/api/' + self.base_url = "https://code.angularjs.org/#{version}/docs/partials/api/" html_filters.push 'angular/clean_html', 'angular/entries', 'title' text_filters.push 'angular/clean_urls' @@ -52,7 +52,7 @@ module Docs def get_root_page_body require 'capybara' Capybara.current_driver = :selenium - Capybara.visit('https://code.angularjs.org/1.3.4/docs/api') + Capybara.visit("https://code.angularjs.org/#{self.class.version}/docs/api") Capybara.find('.side-navigation')['innerHTML'] end end