-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ea2b38c
Showing
13 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
*.gem | |||
.bundle | |||
Gemfile.lock | |||
pkg/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
rvm use ruby-1.9.2-p136@workon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
source "http://rubygems.org" | |||
|
|||
# Specify your gem's dependencies in workon.gemspec | |||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
require 'bundler' | |||
Bundler::GemHelper.install_tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,23 @@ | |||
$:.push File.expand_path("../", __FILE__) | |||
require 'workon/actor' | |||
|
|||
module Workon | |||
WORK_DIRS = '/Users/mike/Work/*/*' | |||
|
|||
def self.all_directories | |||
@_all_directories ||= Dir[WORK_DIRS] | |||
end | |||
|
|||
def self.find(str) | |||
candidate = all_directories.find { |d| d.end_with? "/#{str}" } | |||
commit candidate unless candidate.nil? | |||
end | |||
|
|||
def self.commit(path) | |||
Workon::Actor.all.each do |klass| | |||
klass.new(path).commit | |||
end | |||
end | |||
end | |||
|
|||
Workon.find "workon" if __FILE__ == $0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
require 'workon/actor/base' | |||
require 'workon/actor/text_mate' | |||
require 'workon/actor/web_browser' | |||
require 'workon/actor/finder' | |||
require 'workon/actor/git' | |||
|
|||
module Workon | |||
module Actor | |||
def self.all | |||
Workon::Actor::Base.subclasses | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
module Workon | |||
module Actor | |||
class Base | |||
attr_reader :path | |||
attr_reader :project | |||
|
|||
def self.subclasses | |||
@_subclasses | |||
end | |||
|
|||
def self.inherited(base) | |||
@_subclasses ||= [] | |||
@_subclasses << base | |||
end | |||
|
|||
def initialize(path) | |||
@path = path | |||
end | |||
|
|||
def project | |||
@project ||= @path.split('/').last | |||
end | |||
|
|||
def commit | |||
run command | |||
end | |||
|
|||
def run(command) | |||
puts "Running #{command}" | |||
%x(#{command}) | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
module Workon | |||
module Actor | |||
class Finder < Base | |||
def command | |||
"open #{path}" | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
module Workon | |||
module Actor | |||
class Git < Base | |||
def project_uses_git? | |||
Dir.exists? %{#{path}/.git} | |||
end | |||
|
|||
def commit | |||
run "git log" if project_uses_git? | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
module Workon | |||
module Actor | |||
class TextMate < Base | |||
def command | |||
"mate #{path}" | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,10 @@ | |||
module Workon | |||
module Actor | |||
class WebBrowser < Base | |||
def command | |||
host_name = %{#{project}.local} | |||
%{ping -q -c 1 -t 1 #{host_name} && open http://#{host_name}} | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
module Workon | |||
VERSION = "0.0.1" | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,24 @@ | |||
# -*- encoding: utf-8 -*- | |||
$:.push File.expand_path("../lib", __FILE__) | |||
require "workon/version" | |||
|
|||
Gem::Specification.new do |s| | |||
s.name = "workon" | |||
s.version = Workon::VERSION | |||
s.platform = Gem::Platform::RUBY | |||
s.authors = ["Mike Wyatt"] | |||
s.email = ["wyatt.mike@gmail.com"] | |||
s.homepage = "" | |||
s.summary = %q{TODO: Write a gem summary} | |||
s.description = %q{TODO: Write a gem description} | |||
|
|||
s.add_dependency "activesupport" | |||
s.add_development_dependency "rspec" | |||
|
|||
s.rubyforge_project = "workon" | |||
|
|||
s.files = `git ls-files`.split("\n") | |||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | |||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | |||
s.require_paths = ["lib"] | |||
end |