Permalink
Browse files

Added catalog theme management functions

  • Loading branch information...
1 parent 1c7c6c2 commit 7b649836333004b205be5ca354b31c94cd684985 Jeroen van Schagen committed Nov 18, 2009
View
@@ -10,7 +10,8 @@ begin
gem.email = "michel@re-invention.nl"
gem.homepage = "http://github.com/michel/interfacelift"
gem.authors = ["Michel de Graaf","Jeroen van Schagen"]
- gem.add_development_dependency "thoughtbot-shoulda"
+ gem.add_dependency ["commander", "git"]
+ gem.add_development_dependency "thoughtbot-shoulda"
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
end
Jeweler::GemcutterTasks.new
View
@@ -1,9 +1,14 @@
+require 'rubygems'
+require 'git'
+
module InterfaceLift
class Catalog
+ DEFAULT_CATELOG_PATH = "~/.interfacelift"
attr_reader :catalog_path
def initialize(catalog_path = nil)
@catalog_path = catalog_path.nil? ? DEFAULT_CATELOG_PATH : catalog_path
+ create_catalog_path!
end
# Retrieve themes from specified catalog path
@@ -14,5 +19,51 @@ def themes
end
themes.map { |path| path.split("/").last }
end
+
+ # Does the given theme exist in the working path
+ def theme_exists?(theme)
+ themes.include?(theme)
+ end
+
+ # Is the argumented theme a git repository?
+ def git_repo?(theme)
+ begin
+ g = Git.open("#{catalog_path}/#{theme}")
+ rescue ArgumentError => e
+ # If the path does not exist it will return an ArgumentError
+ return false
+ end
+ !g.repo.path.nil?
+ end
+
+ # Retrieve the latest version of argumented theme from git repository
+ def update_theme(theme)
+ return false unless git_repo?(theme)
+ g = Git.open("#{catalog_path}/#{theme}")
+ !g.pull.match(/^Updating/).nil?
+ end
+
+ # Remove theme from catalog
+ def remove_theme(theme)
+ return false unless theme_exists?(theme)
+ FileUtils.rm_rf("#{@catalog_path}/#{theme}")
+ end
+
+ # Download a theme from git repository
+ # returns true when sucessfull
+ # raises exception when it fails
+ def add_theme(theme, repo)
+ remove_theme(theme) if theme_exists?(theme)
+ !Git.clone(repo, "#{@catalog_path}/#{theme}").repo.path.nil?
+ end
+
+ def create_catalog_path!
+ FileUtils.mkdir_p(@catalog_path) unless File.exists?(@catalog_path)
+ end
+
end
-end
+end
+
+
+# test = InterfaceLift::Catalog.new
+# test.add_theme "bright_admin", "git://github.com/michel/bright_admin.git"
View
@@ -0,0 +1,5 @@
+module InterfaceLift
+ class Fetcher
+ # Lololol moet nog
+ end
+end
View
@@ -1,8 +1,8 @@
module InterfaceLift
VERSION = "0.0.1"
- DEFAULT_CATELOG_PATH = "~/.interfacelift"
end
$LOAD_PATH << File.expand_path(File.dirname(__FILE__))
require "catalog"
+require "fetcher"
require "installer"
require "theme_manager"
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Module: InterfaceLift</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
+ <script type="text/javascript">
+ // <![CDATA[
+
+ function popupCode( url ) {
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
+ }
+
+ function toggleCode( id ) {
+ if ( document.getElementById )
+ elem = document.getElementById( id );
+ else if ( document.all )
+ elem = eval( "document.all." + id );
+ else
+ return false;
+
+ elemStyle = elem.style;
+
+ if ( elemStyle.display != "block" ) {
+ elemStyle.display = "block"
+ } else {
+ elemStyle.display = "none"
+ }
+
+ return true;
+ }
+
+ // Make codeblocks hidden by default
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
+
+ // ]]>
+ </script>
+
+</head>
+<body>
+
+
+
+ <div id="classHeader">
+ <table class="header-table">
+ <tr class="top-aligned-row">
+ <td><strong>Module</strong></td>
+ <td class="class-name-in-header">InterfaceLift</td>
+ </tr>
+ <tr class="top-aligned-row">
+ <td><strong>In:</strong></td>
+ <td>
+ <a href="../files/lib/catalog_rb.html">
+ lib/catalog.rb
+ </a>
+ <br />
+ <a href="../files/lib/fetcher_rb.html">
+ lib/fetcher.rb
+ </a>
+ <br />
+ <a href="../files/lib/installer_rb.html">
+ lib/installer.rb
+ </a>
+ <br />
+ <a href="../files/lib/interfacelift_rb.html">
+ lib/interfacelift.rb
+ </a>
+ <br />
+ <a href="../files/lib/theme_manager_rb.html">
+ lib/theme_manager.rb
+ </a>
+ <br />
+ </td>
+ </tr>
+
+ </table>
+ </div>
+ <!-- banner header -->
+
+ <div id="bodyContent">
+
+
+
+ <div id="contextContent">
+
+
+
+ </div>
+
+
+ </div>
+
+
+ <!-- if includes -->
+
+ <div id="section">
+
+ <div id="class-list">
+ <h3 class="section-bar">Classes and Modules</h3>
+
+ Class <a href="InterfaceLift/Catalog.html" class="link">InterfaceLift::Catalog</a><br />
+Class <a href="InterfaceLift/Fetcher.html" class="link">InterfaceLift::Fetcher</a><br />
+Class <a href="InterfaceLift/Installer.html" class="link">InterfaceLift::Installer</a><br />
+Class <a href="InterfaceLift/ThemeManager.html" class="link">InterfaceLift::ThemeManager</a><br />
+
+ </div>
+
+ <div id="constants-list">
+ <h3 class="section-bar">Constants</h3>
+
+ <div class="name-list">
+ <table summary="Constants">
+ <tr class="top-aligned-row context-row">
+ <td class="context-item-name">VERSION</td>
+ <td>=</td>
+ <td class="context-item-value">&quot;0.0.1&quot;</td>
+ </tr>
+ <tr class="top-aligned-row context-row">
+ <td class="context-item-name">DEFAULT_CATELOG_PATH</td>
+ <td>=</td>
+ <td class="context-item-value">&quot;~/.interfacelift&quot;</td>
+ </tr>
+ </table>
+ </div>
+ </div>
+
+
+
+
+
+
+ <!-- if method_list -->
+
+
+ </div>
+
+
+<div id="validator-badges">
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
+</div>
+
+</body>
+</html>
Oops, something went wrong.

0 comments on commit 7b64983

Please sign in to comment.