Permalink
Browse files

added page class

  • Loading branch information...
1 parent 35aa003 commit 901703706a4b1fd07432f6ffccae562c6b7a3d6b @nkpart committed Aug 26, 2009
Showing with 31 additions and 3 deletions.
  1. +1 −1 features/development.feature
  2. +26 −1 lib/gh-wiki.rb
  3. +4 −1 lib/gh-wiki/cli.rb
@@ -13,7 +13,7 @@ Feature: github wiki cloning
Scenario: Clone Wiki
Given this project is active project folder
- When I run project executable "bin/gh-wiki" with arguments "dpp liftweb"
+ When I run project executable "bin/gh-wiki" with arguments "dpp liftweb -p tmp/lw"
Then I should see
"""
dpp / liftweb
View
@@ -11,6 +11,22 @@ def N url
Nokogiri::HTML(open(url))
end
+ class Page
+ include GhWiki
+
+ attr_reader :title
+
+ def initialize title, link
+ @title = title
+ @link = link
+ end
+
+ def doc
+ N link
+ end
+ end
+
+
class Project
include GhWiki
@@ -33,7 +49,16 @@ def description
def pages
home_doc.css(".sidebar ul li b a").map do |item|
- item.content
+ Page.new(item.content, item['href'])
+ end
+ end
+
+
+ def save_pages_into path
+ FileUtils::mkdir_p path
+ projects.pages.each do |page|
+
+ # get page, clean it, replace sidebar, check for links, save it out
end
end
end
View
@@ -1,5 +1,6 @@
require 'optparse'
require 'gh-wiki'
+require 'fileutils'
module GhWiki
class CLI
@@ -40,7 +41,9 @@ def self.execute(stdout, arguments=[])
project = Project.new(user,project_name)
puts "#{user} / #{project.name}"
puts "Description: #{project.description}"
- puts "Pages: #{project.pages.map{ |x| x.inspect }.join(", ")}"
+ puts "Pages: #{project.pages.map{ |x| x.title.inspect }.join(", ")}"
+
+ project.save_pages_into path
end
end

0 comments on commit 9017037

Please sign in to comment.