Permalink
Browse files

Pulls down description and page list

  • Loading branch information...
1 parent c143103 commit 35aa003fd229e3662441b48b4478d9f859ae7fa4 @nkpart committed Aug 26, 2009
Showing with 52 additions and 17 deletions.
  1. +2 −10 Rakefile
  2. +7 −2 features/development.feature
  3. +36 −2 lib/gh-wiki.rb
  4. +7 −3 lib/gh-wiki/cli.rb
View
12 Rakefile
@@ -5,22 +5,14 @@ require 'fileutils'
require './lib/gh-wiki'
Hoe.plugin :newgem
-# Hoe.plugin :website
Hoe.plugin :cucumberfeatures
-# Generate all the Rake tasks
-# Run 'rake -T' to see list of generated tasks (from gem root directory)
$hoe = Hoe.spec 'gh-wiki' do
- self.developer 'FIXME full name', 'FIXME email'
- self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
+ self.developer 'Nick Partridge', 'nkpart@gmail.com'
self.rubyforge_name = self.name # TODO this is default value
- # self.extra_deps = [['activesupport','>= 2.0.2']]
+ self.extra_deps = [['nokogiri','>= 0.0']] #TODO pick a version
end
require 'newgem/tasks'
Dir['tasks/**/*.rake'].each { |t| load t }
-
-# TODO - want other tests/tasks run by default? Add them to the list
-# remove_task :default
-# task :default => [:spec, :features]
View
9 features/development.feature
@@ -16,9 +16,14 @@ Feature: github wiki cloning
When I run project executable "bin/gh-wiki" with arguments "dpp liftweb"
Then I should see
"""
- dpp / liftweb
- Description: The Lift web framework for Scala
+ dpp / liftweb
+ Description: The Lift web framework for Scala
"""
+ And I should see
+ """
+ Pages: "About: Lift Tags"
+ """
+
Scenario: Help
Given this project is active project folder
When I run project executable "bin/gh-wiki" with arguments "--help"
View
38 lib/gh-wiki.rb
@@ -1,6 +1,40 @@
$:.unshift(File.dirname(__FILE__)) unless
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
+require 'open-uri'
+require 'nokogiri'
+
module GhWiki
- VERSION = '0.0.1'
-end
+ VERSION = '0.0.1' unless defined? VERSION
+
+ def N url
+ Nokogiri::HTML(open(url))
+ end
+
+ class Project
+ include GhWiki
+
+ attr_reader :user, :name
+ def initialize user, name
+ @user = user
+ @name = name
+ end
+
+ def home_doc
+ @home_doc ||= N("http://wiki.github.com/#{user}/#{name}")
+ end
+
+ def description
+ home_doc.css("#repository_description").each do |h|
+ @desc = h.content
+ end
+ @desc
+ end
+
+ def pages
+ home_doc.css(".sidebar ul li b a").map do |item|
+ item.content
+ end
+ end
+ end
+end
View
10 lib/gh-wiki/cli.rb
@@ -1,4 +1,5 @@
require 'optparse'
+require 'gh-wiki'
module GhWiki
class CLI
@@ -30,13 +31,16 @@ def self.execute(stdout, arguments=[])
end
user = ARGV[0]
- project = ARGV[1]
- if !user || !project then
+ project_name = ARGV[1]
+ if !user || !project_name then
puts banner
else
path = options[:path]
- # do it!
+ project = Project.new(user,project_name)
+ puts "#{user} / #{project.name}"
+ puts "Description: #{project.description}"
+ puts "Pages: #{project.pages.map{ |x| x.inspect }.join(", ")}"
end
end

0 comments on commit 35aa003

Please sign in to comment.