Permalink
Browse files

inital commit

  • Loading branch information...
0 parents commit 912c940b3776dcc5c85c2fe8c90d7ee765ee3553 Cedric Sohrauer committed Feb 2, 2010
Showing with 59 additions and 0 deletions.
  1. +52 −0 lib/github.rb
  2. +7 −0 plugin.rb
@@ -0,0 +1,52 @@
+module Redcar
+ class Github
+ def self.menus
+ Menu::Builder.build do
+ sub_menu "Project" do
+ item "Project from Github", OpenGithubProjectCommand
+ end
+ end
+ end
+
+ def self.loaded
+ # This should happen when Redcar is closed
+ FileUtils.remove_entry_secure "#{Redcar.user_dir}/github/clone"
+ end
+ end
+
+ class OpenGithubProjectCommand < Command
+ key :osx => "Cmd+Shift+G",
+ :linux => "Ctrl+Shift+G",
+ :windows => "Ctrl+Shift+G"
+
+ attr_accessor :rep_path, :user_name, :rep_name, :url
+
+ def execute
+ result = Application::Dialog.input(win,"Github Clone URL","Input the Clone URL")
+ @url = result[:value]
+
+ matched_result = @url.match("github.com\/(.*)\/(.*).git")
+ unless matched_result == nil
+ @user_name = matched_result[1]
+ @rep_name = matched_result[2]
+ @rep_path = "#{Redcar.user_dir}/github/clone/#{@user_name}/#{@rep_name}"
+
+ Thread.new(self, window) do |command, window|
+ system "git clone #{@url} #{@rep_path}"
+
+ ApplicationSWT.sync_exec do
+ new_window = Redcar.app.new_window
+ tree = Tree.new(Project::DirMirror.new(@rep_path),Project::DirController.new)
+
+ Project.open_tree(new_window, tree)
+ end
+ end
+ else
+ Application::Dialog.message_box(
+ win,
+ "Wrong format for the url: #{@url} . Use the clone url from github.",
+ :type => :error )
+ end
+ end
+ end
+end
@@ -0,0 +1,7 @@
+Plugin.define do
+ name "github"
+ version "0.1"
+ file "lib", "github"
+ object "Redcar::Github"
+ dependencies "project", ">0"
+end

0 comments on commit 912c940

Please sign in to comment.