utsup 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +8 -0
- data/PostInstall.txt +13 -1
- data/Rakefile +2 -1
- data/lib/sup/api.rb +42 -0
- data/lib/sup/command.rb +98 -0
- data/lib/sup/differ/differ.rb +84 -0
- data/lib/sup/differ/differ_control.rb +14 -0
- data/lib/sup/differ/differ_run.rb +2 -0
- data/lib/sup/help.rb +43 -0
- data/lib/sup/yamlize.rb +59 -0
- data/lib/sup.rb +69 -180
- data/test/test_helper.rb +2 -0
- data/test/test_yamler.rb +94 -0
- metadata +31 -28
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -10,8 +10,16 @@ lib/hooks/post-checkout
|
|
10
10
|
lib/hooks/post-merge
|
11
11
|
lib/hooks/post-receive
|
12
12
|
lib/sup.rb
|
13
|
+
lib/sup/differ/differ_control.rb
|
14
|
+
lib/sup/differ/differ_run.rb
|
15
|
+
lib/sup/differ/differ.rb
|
16
|
+
lib/sup/yamlize.rb
|
17
|
+
lib/sup/command.rb
|
18
|
+
lib/sup/help.rb
|
19
|
+
lib/sup/api.rb
|
13
20
|
script/console
|
14
21
|
script/destroy
|
15
22
|
script/generate
|
16
23
|
test/test_helper.rb
|
17
24
|
test/test_sup.rb
|
25
|
+
test/test_yamler.rb
|
data/PostInstall.txt
CHANGED
@@ -1 +1,13 @@
|
|
1
|
-
|
1
|
+
=======================================
|
2
|
+
UtSup Installed!
|
3
|
+
=======================================
|
4
|
+
|
5
|
+
Be sure to sign up for an account at http://utsup.com
|
6
|
+
|
7
|
+
Then, to begin using, first run:
|
8
|
+
|
9
|
+
sup setup <your-api-key>
|
10
|
+
|
11
|
+
Thanks for using UtSup!
|
12
|
+
- Lemur Heavy Industries (http://lemurheavy.com)
|
13
|
+
|
data/Rakefile
CHANGED
@@ -14,9 +14,10 @@ $hoe = Hoe.spec 'utsup' do
|
|
14
14
|
self.developer 'Nick Merwin', 'nick@lemurheavy.com'
|
15
15
|
self.post_install_message = File.read('PostInstall.txt')
|
16
16
|
self.rubyforge_name = self.name
|
17
|
-
self.extra_deps = [['schacon-git']]
|
17
|
+
self.extra_deps = [['schacon-git'],['daemons']]
|
18
18
|
# self.spec_extras[:extensions] = "extconf.rb"
|
19
19
|
self.spec_extras[:rdoc_options] = ""
|
20
|
+
self.spec_extras[:homepage] = %q{http://github.com/yickster/utsup_gem}
|
20
21
|
|
21
22
|
end
|
22
23
|
|
data/lib/sup/api.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Sup
|
2
|
+
# ==============================
|
3
|
+
# API's
|
4
|
+
# ==============================
|
5
|
+
|
6
|
+
module Api
|
7
|
+
class Base < ActiveResource::Base
|
8
|
+
cattr_accessor :project_id
|
9
|
+
self.user = "api"
|
10
|
+
end
|
11
|
+
|
12
|
+
class Status < Base
|
13
|
+
def self.add(attributes)
|
14
|
+
unless self.project_id
|
15
|
+
puts "You're not in a Sup project. Run 'sup init' to add this directory."
|
16
|
+
return
|
17
|
+
end
|
18
|
+
|
19
|
+
create attributes.merge({:project_id => @@project_id, :branch => Sup::current_branch_name, :version => VERSION})
|
20
|
+
|
21
|
+
rescue ActiveResource::ResourceNotFound
|
22
|
+
puts "Your project_id was invalid, check #{PROJECT_CONFIG_PATH}"
|
23
|
+
rescue SocketError
|
24
|
+
Sup::socket_error
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Project < Base
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
class User < Base
|
33
|
+
def self.check_name(name)
|
34
|
+
begin
|
35
|
+
get :check_name, :name => name
|
36
|
+
rescue ActiveResource::ResourceNotFound
|
37
|
+
false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/sup/command.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
module Sup
|
2
|
+
# ==============================
|
3
|
+
# Command Line Controller
|
4
|
+
# ==============================
|
5
|
+
|
6
|
+
module Command
|
7
|
+
class << self
|
8
|
+
def run(command, args)
|
9
|
+
bench = Time.now
|
10
|
+
|
11
|
+
# no configure
|
12
|
+
case command
|
13
|
+
when "setup":
|
14
|
+
return Sup::setup args.last
|
15
|
+
end
|
16
|
+
|
17
|
+
Sup::configure
|
18
|
+
|
19
|
+
case command
|
20
|
+
|
21
|
+
when "help":
|
22
|
+
puts HELP_TEXT
|
23
|
+
|
24
|
+
when "version":
|
25
|
+
puts VERSION
|
26
|
+
|
27
|
+
when "init":
|
28
|
+
Sup::init args.first
|
29
|
+
Differ::restart! # to reload projects.yml
|
30
|
+
puts "Supified!"
|
31
|
+
|
32
|
+
when "in":
|
33
|
+
Sup::check_in args.last
|
34
|
+
Differ::start!
|
35
|
+
puts "Checked in."
|
36
|
+
|
37
|
+
when "out":
|
38
|
+
Sup::check_out args.last
|
39
|
+
Differ::stop!
|
40
|
+
puts "Checked out."
|
41
|
+
|
42
|
+
# --- Git -----------------
|
43
|
+
when "git":
|
44
|
+
Sup::git_update args
|
45
|
+
when "push":
|
46
|
+
Sup::git_update "push"
|
47
|
+
|
48
|
+
when "nm":
|
49
|
+
Sup::undo
|
50
|
+
puts "Undid last Supdate."
|
51
|
+
|
52
|
+
when "remove":
|
53
|
+
File.unlink File.join(Dir.pwd, PROJECT_CONFIG_PATH)
|
54
|
+
# TODO: remove git hooks
|
55
|
+
puts "De-Supified."
|
56
|
+
|
57
|
+
when "users":
|
58
|
+
Sup::get_users
|
59
|
+
|
60
|
+
when "all":
|
61
|
+
Sup::get_statuses :today => true
|
62
|
+
|
63
|
+
when "search":
|
64
|
+
# TODO: search
|
65
|
+
|
66
|
+
when "start"
|
67
|
+
Differ::start!
|
68
|
+
puts "Started."
|
69
|
+
when "stop"
|
70
|
+
Differ::stop!
|
71
|
+
puts "Stopped."
|
72
|
+
|
73
|
+
when /.+/:
|
74
|
+
|
75
|
+
# TODO: combine user_name check and supdate into one ActiveResource call -- do name-check & return or supdate on server
|
76
|
+
if Api::User.check_name(command)
|
77
|
+
Sup::get_statuses :name => command, :today => true
|
78
|
+
return
|
79
|
+
end
|
80
|
+
|
81
|
+
# implicit text update: sup "chillin"
|
82
|
+
Sup::update command
|
83
|
+
puts "Supdated."
|
84
|
+
|
85
|
+
else
|
86
|
+
# full status check
|
87
|
+
Sup::get_statuses
|
88
|
+
end
|
89
|
+
|
90
|
+
# TODO: config file option to set verbosity
|
91
|
+
puts "UtSup? v.#{VERSION} (#{Time.now - bench}s)"
|
92
|
+
|
93
|
+
rescue SocketError
|
94
|
+
Sup::socket_error
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module Sup
|
2
|
+
module Differ
|
3
|
+
INTERVAL = 5
|
4
|
+
# TODO: pull interval out of config.yml?
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def run
|
8
|
+
@projects = Project.all
|
9
|
+
|
10
|
+
loop do
|
11
|
+
@projects.map &:diff!
|
12
|
+
sleep INTERVAL
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def start!
|
17
|
+
`ruby #{File.join(File.expand_path(File.dirname(__FILE__)),'differ_control.rb')} start`
|
18
|
+
end
|
19
|
+
|
20
|
+
def stop!
|
21
|
+
`ruby #{File.join(File.expand_path(File.dirname(__FILE__)),'differ_control.rb')} stop`
|
22
|
+
end
|
23
|
+
|
24
|
+
def restart!
|
25
|
+
stop! && start!
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# TODO: marshal dump these directly to yaml? or store in sqlite db
|
31
|
+
class Project
|
32
|
+
attr_accessor :current_diff
|
33
|
+
def initialize(id, path)
|
34
|
+
@id, @path = id, path
|
35
|
+
@current_diff = ""
|
36
|
+
@current_changed_files = {}
|
37
|
+
end
|
38
|
+
|
39
|
+
def diff!
|
40
|
+
# figure out which specific files have changed since the last diff
|
41
|
+
|
42
|
+
@changed_files = []
|
43
|
+
@current_diffs = []
|
44
|
+
|
45
|
+
Dir.chdir @path
|
46
|
+
diff = `git diff`
|
47
|
+
|
48
|
+
if diff != @current_diff
|
49
|
+
@current_diff = diff
|
50
|
+
|
51
|
+
# get array of changed files from git diff
|
52
|
+
`git diff --stat`.scan(/^ (.*?)\s{1,}\|/m).flatten.each do |file|
|
53
|
+
|
54
|
+
# get specific diff for file
|
55
|
+
file_diff = `git diff #{file}`
|
56
|
+
|
57
|
+
# if different from previous diff, store path and diff
|
58
|
+
if @current_changed_files[file] != file_diff
|
59
|
+
@current_changed_files[file] = file_diff
|
60
|
+
@changed_files << file
|
61
|
+
@current_diffs << file_diff
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
supdate! unless @changed_files.empty?
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def supdate!
|
70
|
+
Sup::configure
|
71
|
+
Sup::Api::Status.add :status_type => "StatusDiff", :message => @changed_files*', ',
|
72
|
+
:text => @current_diffs*'\n'
|
73
|
+
end
|
74
|
+
|
75
|
+
class << self
|
76
|
+
def all
|
77
|
+
[].yamlize(GLOBAL_PROJECT_CONFIG_PATH).map do |project_config|
|
78
|
+
new project_config['id'], project_config['path']
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'daemons'
|
3
|
+
|
4
|
+
options = {
|
5
|
+
:app_name => "utsup",
|
6
|
+
:backtrace => true,
|
7
|
+
:monitor => true,
|
8
|
+
:multiple => false,
|
9
|
+
:dir_mode => :normal,
|
10
|
+
:dir => File.join(File.expand_path('~'), '.utsup'),
|
11
|
+
:log_output => true
|
12
|
+
}
|
13
|
+
|
14
|
+
Daemons.run(File.join(File.dirname(__FILE__), 'differ_run.rb'), options)
|
data/lib/sup/help.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
module Sup
|
2
|
+
HELP_TEXT = <<-eos
|
3
|
+
=======================================
|
4
|
+
UtSup Client v.#{VERSION}
|
5
|
+
by Nick Merwin (Lemur Heavy Industries)
|
6
|
+
=======================================
|
7
|
+
|
8
|
+
=== Examples:
|
9
|
+
sup setup
|
10
|
+
|
11
|
+
cd /some-project/ && sup init
|
12
|
+
sup in "whatup"
|
13
|
+
sup
|
14
|
+
sup "just chillin"
|
15
|
+
sup out "later"
|
16
|
+
|
17
|
+
=== Commands:
|
18
|
+
|
19
|
+
help # show this message
|
20
|
+
version # show version
|
21
|
+
|
22
|
+
setup <api_key> # initializes global config file
|
23
|
+
|
24
|
+
init <project name> # initilize current directory
|
25
|
+
|
26
|
+
"<message>" # send status update for current project
|
27
|
+
nm # destroy your last supdate
|
28
|
+
|
29
|
+
(no command) # get all user's current status
|
30
|
+
all # get all user's statuses over the past day
|
31
|
+
|
32
|
+
in "<message>" # check in to project
|
33
|
+
out "<message>" # check out of project
|
34
|
+
|
35
|
+
users # get list of users in company
|
36
|
+
<user name> # get last day's worth of status updates from specified user
|
37
|
+
|
38
|
+
push # triggers a git push + update
|
39
|
+
|
40
|
+
start # starts differ
|
41
|
+
stop # stops differ
|
42
|
+
eos
|
43
|
+
end
|
data/lib/sup/yamlize.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
=begin
|
2
|
+
======
|
3
|
+
Yamlize
|
4
|
+
======
|
5
|
+
|
6
|
+
by Nick Merwin 10.31.09
|
7
|
+
|
8
|
+
Why? Bored with writing yaml loaders + dumpers.
|
9
|
+
=end
|
10
|
+
|
11
|
+
require 'yaml'
|
12
|
+
class Yamlize
|
13
|
+
attr_reader :path, :attributes
|
14
|
+
|
15
|
+
def initialize(path, type=Hash, &block)
|
16
|
+
@path = File.expand_path path
|
17
|
+
File.open(@path,'w'){} unless File.exists?(@path)
|
18
|
+
@attributes = YAML.load_file(@path) || type.new
|
19
|
+
|
20
|
+
if block_given?
|
21
|
+
yield self
|
22
|
+
save
|
23
|
+
end
|
24
|
+
rescue Errno::ENOTDIR
|
25
|
+
raise "Path invalid."
|
26
|
+
rescue Errno::ENOENT
|
27
|
+
raise "Path invalid."
|
28
|
+
end
|
29
|
+
|
30
|
+
def method_missing(name, *args, &block)
|
31
|
+
if attribute = name.to_s[/(.*?)=/,1]
|
32
|
+
@attributes[attribute] = args.first
|
33
|
+
return
|
34
|
+
end
|
35
|
+
|
36
|
+
begin
|
37
|
+
if !@attributes[name.to_s].nil?
|
38
|
+
return @attributes[name.to_s]
|
39
|
+
end
|
40
|
+
rescue TypeError
|
41
|
+
end
|
42
|
+
|
43
|
+
if @attributes.respond_to?(name)
|
44
|
+
return @attributes.send name, *args, &block
|
45
|
+
end
|
46
|
+
|
47
|
+
super name, *args
|
48
|
+
end
|
49
|
+
|
50
|
+
def save
|
51
|
+
File.open(@path,'w'){|f| YAML.dump @attributes, f}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class Object
|
56
|
+
def yamlize(path, &block)
|
57
|
+
Yamlize.new path, self.class, &block
|
58
|
+
end
|
59
|
+
end
|
data/lib/sup.rb
CHANGED
@@ -1,66 +1,56 @@
|
|
1
|
+
# TODO: testing suite
|
2
|
+
|
1
3
|
$:.unshift(File.dirname(__FILE__)) unless
|
2
4
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
5
|
|
6
|
+
require 'rubygems'
|
4
7
|
require 'active_resource'
|
5
|
-
require 'yaml'
|
6
8
|
require 'git'
|
7
9
|
|
8
|
-
|
9
|
-
VERSION = '0.0.9'
|
10
|
-
GIT_HOOKS = %w(post-commit post-receive post-merge post-checkout) #TODO: post-rebase?
|
11
|
-
|
12
|
-
GLOBAL_CONFIG_PATH = '~/.utsup'
|
13
|
-
PROJECT_CONFIG_PATH = '.git/utsup.yml'
|
14
|
-
|
15
|
-
HELP_TEXT = <<-eos
|
16
|
-
=======================================
|
17
|
-
UtSup Client v.0.0.1
|
18
|
-
by Nick Merwin (Lemur Heavy Industries)
|
19
|
-
=======================================
|
10
|
+
require 'sup/yamlize'
|
20
11
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
sup init
|
25
|
-
sup in "whatup"
|
26
|
-
sup
|
27
|
-
sup "just chillin"
|
28
|
-
sup out "later"
|
29
|
-
|
30
|
-
=== Commands:
|
31
|
-
|
32
|
-
help # show this message
|
33
|
-
version # show version
|
34
|
-
|
35
|
-
setup # initializes global config file
|
12
|
+
require 'sup/differ/differ'
|
13
|
+
require 'sup/api'
|
14
|
+
require 'sup/command'
|
36
15
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
nm # destroy your last supdate
|
41
|
-
|
42
|
-
(no command) # get all user's current status
|
43
|
-
all # get all user's statuses over the past day
|
44
|
-
|
45
|
-
in "<message>" # check in to project
|
46
|
-
out "<message>" # check out of project
|
47
|
-
|
48
|
-
users # get list of users in company
|
49
|
-
<user name> # get last day's worth of status updates from specified user
|
16
|
+
module Sup
|
17
|
+
VERSION = '0.1.0'
|
18
|
+
GIT_HOOKS = %w(post-commit post-receive post-merge post-checkout) #TODO: post-rebase?
|
50
19
|
|
51
|
-
|
52
|
-
|
20
|
+
GLOBAL_CONFIG_PATH = '~/.utsup/config.yml'
|
21
|
+
GLOBAL_PROJECT_CONFIG_PATH = '~/.utsup/projects.yml'
|
22
|
+
PROJECT_CONFIG_PATH = '.git/utsup.yml'
|
53
23
|
|
54
24
|
class << self
|
55
25
|
|
56
|
-
|
26
|
+
# ===========================
|
27
|
+
# Setup
|
28
|
+
# ===========================
|
29
|
+
|
30
|
+
def setup(api_key="your api key here")
|
31
|
+
require 'fileutils'
|
32
|
+
|
57
33
|
# --- global init
|
58
34
|
global_config_path = File.expand_path(GLOBAL_CONFIG_PATH)
|
59
35
|
|
36
|
+
# for back-compat with old config file
|
37
|
+
oldpath = File.dirname(global_config_path)
|
38
|
+
if File.exists?(oldpath) && !File.directory?(oldpath)
|
39
|
+
FileUtils.mv oldpath, oldpath+'.bak'
|
40
|
+
FileUtils.mkdir File.dirname(global_config_path)
|
41
|
+
FileUtils.mv oldpath+'.bak', global_config_path
|
42
|
+
end
|
43
|
+
|
60
44
|
unless File.exists?(global_config_path)
|
61
|
-
|
62
|
-
|
63
|
-
|
45
|
+
FileUtils.mkdir File.dirname(global_config_path)
|
46
|
+
FileUtils.copy File.join(File.dirname(__FILE__), 'config/utsup.sample'), global_config_path
|
47
|
+
|
48
|
+
Yamlize.new global_config_path do |global_config|
|
49
|
+
global_config.api_key = api_key
|
50
|
+
end
|
51
|
+
|
52
|
+
puts "Initialized ~/.utsup/config.yml"
|
53
|
+
|
64
54
|
else
|
65
55
|
puts "You're good to go."
|
66
56
|
end
|
@@ -76,18 +66,33 @@ eos
|
|
76
66
|
project_title = File.basename(Dir.pwd) if project_title.blank? || project_title == "."
|
77
67
|
project = Api::Project.create :title => project_title
|
78
68
|
|
79
|
-
|
69
|
+
# add project id to .git
|
70
|
+
Yamlize.new File.join(Dir.pwd, PROJECT_CONFIG_PATH) do |project_config|
|
71
|
+
project_config.project_id = project.id
|
72
|
+
end
|
80
73
|
|
81
|
-
|
82
|
-
|
83
|
-
|
74
|
+
# add project path and id to global project config (for differ)
|
75
|
+
Yamlize.new GLOBAL_PROJECT_CONFIG_PATH, Array do |global_project_config|
|
76
|
+
global_project_config << {'path'=>Dir.pwd, 'id'=>project.id}
|
77
|
+
global_project_config.uniq!
|
78
|
+
end
|
84
79
|
|
85
80
|
# --- write git hooks
|
81
|
+
#TODO: option to manually add hooks if they already have some...
|
86
82
|
GIT_HOOKS.each do |hook|
|
87
|
-
File.
|
88
|
-
|
83
|
+
path = File.join(Dir.pwd, '.git/hooks/', hook)
|
84
|
+
hook_cmd = File.read(File.join(File.dirname(__FILE__),'hooks',hook))
|
85
|
+
|
86
|
+
if File.exists?(path)
|
87
|
+
puts "You already have a git hook here: #{path}"
|
88
|
+
puts "Please make sure it's executable add this to it:"
|
89
|
+
puts hook_cmd + "\n"
|
90
|
+
next
|
91
|
+
end
|
92
|
+
|
93
|
+
File.open(path, 'w', 0775) do |f|
|
94
|
+
f.write hook_cmd
|
89
95
|
end
|
90
|
-
#TODO: make sure files are executable if already existed
|
91
96
|
end
|
92
97
|
|
93
98
|
end
|
@@ -97,17 +102,20 @@ eos
|
|
97
102
|
# ===========================
|
98
103
|
|
99
104
|
def configure
|
100
|
-
global_config_path = File.expand_path(GLOBAL_CONFIG_PATH)
|
101
|
-
global_config = YAML.load_file(global_config_path)
|
102
105
|
|
103
|
-
|
104
|
-
project_config =
|
106
|
+
global_config = Yamlize.new GLOBAL_CONFIG_PATH
|
107
|
+
project_config = Yamlize.new(File.join(Dir.pwd, PROJECT_CONFIG_PATH)) rescue {}
|
108
|
+
global_project_config = Yamlize.new GLOBAL_PROJECT_CONFIG_PATH
|
109
|
+
|
110
|
+
unless global_config['api_key']
|
111
|
+
puts "You need to run 'sup setup <api_key>' first, thanks!"
|
112
|
+
exit 0
|
113
|
+
end
|
105
114
|
|
106
115
|
# --- configure API
|
107
116
|
Api::Base.project_id = project_config['project_id']
|
108
117
|
Api::Base.password = project_config['api_key'] || global_config['api_key']
|
109
118
|
Api::Base.site = "http://#{project_config['domain'] || global_config['domain'] || 'utsup.com'}"
|
110
|
-
|
111
119
|
end
|
112
120
|
|
113
121
|
# ===========================
|
@@ -218,131 +226,12 @@ eos
|
|
218
226
|
puts user.to_command_line
|
219
227
|
end
|
220
228
|
end
|
221
|
-
|
222
|
-
end
|
223
|
-
|
224
|
-
# ==============================
|
225
|
-
# API's
|
226
|
-
# ==============================
|
227
|
-
|
228
|
-
module Api
|
229
|
-
class Base < ActiveResource::Base
|
230
|
-
cattr_accessor :project_id
|
231
|
-
self.user = "api"
|
232
|
-
end
|
233
|
-
|
234
|
-
class Status < Base
|
235
|
-
def self.add(attributes)
|
236
|
-
unless self.project_id
|
237
|
-
puts "You're not in a project."
|
238
|
-
return
|
239
|
-
end
|
240
|
-
|
241
|
-
create attributes.merge({:project_id => @@project_id, :branch => Sup::current_branch_name})
|
242
|
-
|
243
|
-
rescue ActiveResource::ResourceNotFound
|
244
|
-
puts "Your project_id was invalid, check #{PROJECT_CONFIG_PATH}"
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
class Project < Base
|
249
|
-
|
250
|
-
end
|
251
229
|
|
252
|
-
|
253
|
-
|
254
|
-
begin
|
255
|
-
get :check_name, :name => name
|
256
|
-
rescue ActiveResource::ResourceNotFound
|
257
|
-
false
|
258
|
-
end
|
259
|
-
end
|
230
|
+
def socket_error
|
231
|
+
puts "UtSup? v.#{VERSION} Offline."
|
260
232
|
end
|
261
|
-
end
|
262
|
-
|
263
|
-
# ==============================
|
264
|
-
# Command Line Controller
|
265
|
-
# ==============================
|
266
|
-
|
267
|
-
module Command
|
268
|
-
class << self
|
269
|
-
def run(command, args)
|
270
|
-
bench = Time.now
|
271
|
-
|
272
|
-
# no configure
|
273
|
-
case command
|
274
|
-
when "setup":
|
275
|
-
return Sup::setup
|
276
|
-
end
|
277
|
-
|
278
|
-
Sup::configure
|
279
|
-
|
280
|
-
case command
|
281
|
-
|
282
|
-
when "help":
|
283
|
-
puts HELP_TEXT
|
284
|
-
|
285
|
-
when "version":
|
286
|
-
puts VERSION
|
287
|
-
|
288
|
-
when "init":
|
289
|
-
Sup::init args.first
|
290
|
-
puts "Supified!"
|
291
233
|
|
292
|
-
when "in":
|
293
|
-
Sup::check_in args.last
|
294
|
-
puts "Checked in."
|
295
|
-
when "out":
|
296
|
-
Sup::check_out args.last
|
297
|
-
puts "Checked out."
|
298
|
-
|
299
|
-
# --- Git -----------------
|
300
|
-
when "git":
|
301
|
-
Sup::git_update args
|
302
|
-
when "push":
|
303
|
-
Sup::git_update "push"
|
304
|
-
|
305
|
-
when "nm":
|
306
|
-
Sup::undo
|
307
|
-
puts "Undid last Supdate."
|
308
|
-
|
309
|
-
when "remove":
|
310
|
-
File.unlink File.join(Dir.pwd, PROJECT_CONFIG_PATH)
|
311
|
-
# TODO: remove git hooks
|
312
|
-
puts "De-Supified."
|
313
|
-
|
314
|
-
when "users":
|
315
|
-
Sup::get_users
|
316
|
-
|
317
|
-
when "all":
|
318
|
-
Sup::get_statuses :today => true
|
319
|
-
|
320
|
-
when "search":
|
321
|
-
# TODO: search
|
322
|
-
|
323
|
-
when /.+/:
|
324
|
-
|
325
|
-
# TODO: combine user_name check and supdate into one ActiveResource call -- do name-check & return or supdate on server
|
326
|
-
if Api::User.check_name(command)
|
327
|
-
Sup::get_statuses :name => command, :today => true
|
328
|
-
return
|
329
|
-
end
|
330
|
-
|
331
|
-
# implicit text update: sup "chillin"
|
332
|
-
Sup::update command
|
333
|
-
puts "Supdated."
|
334
|
-
|
335
|
-
else
|
336
|
-
# full status check
|
337
|
-
Sup::get_statuses
|
338
|
-
end
|
339
|
-
|
340
|
-
# TODO: config file option to set verbosity
|
341
|
-
puts "UtSup? v.#{VERSION} (#{Time.now - bench}s)"
|
342
|
-
end
|
343
|
-
end
|
344
234
|
end
|
345
|
-
|
346
235
|
end
|
347
236
|
|
348
237
|
|
data/test/test_helper.rb
CHANGED
data/test/test_yamler.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestYamler < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@test_path = File.join(File.dirname(__FILE__),"yamler_test.yml")
|
7
|
+
@test_path2 = File.join(File.dirname(__FILE__),"yamler_test2.yml")
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
File.unlink @test_path if File.exists?(@test_path)
|
12
|
+
File.unlink @test_path2 if File.exists?(@test_path2)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_init
|
16
|
+
Yamler.new @test_path
|
17
|
+
assert File.exists?(@test_path)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_setter
|
21
|
+
@obj = Yamler.new @test_path
|
22
|
+
@obj.name = "nick merwin"
|
23
|
+
@obj.title = "programmer"
|
24
|
+
|
25
|
+
assert_equal "nick merwin", @obj.name
|
26
|
+
assert_equal "programmer", @obj.title
|
27
|
+
|
28
|
+
assert_equal "nick merwin", @obj['name']
|
29
|
+
assert_equal "programmer", @obj['title']
|
30
|
+
|
31
|
+
begin
|
32
|
+
@obj.blah
|
33
|
+
rescue
|
34
|
+
assert_equal NoMethodError, $!.class
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_save
|
39
|
+
@obj = Yamler.new @test_path
|
40
|
+
@obj.name = "nick merwin"
|
41
|
+
|
42
|
+
@obj.save
|
43
|
+
|
44
|
+
@obj2 = Yamler.new @test_path
|
45
|
+
assert_equal "nick merwin", @obj2.name
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_block
|
49
|
+
Yamler.new @test_path do |obj|
|
50
|
+
obj.name = "nick merwin"
|
51
|
+
end
|
52
|
+
|
53
|
+
@obj = Yamler.new @test_path
|
54
|
+
assert_equal "nick merwin", @obj.name
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_type
|
58
|
+
@obj = Yamler.new @test_path
|
59
|
+
assert_equal Hash, @obj.attributes.class
|
60
|
+
|
61
|
+
@obj2 = Yamler.new @test_path2, Array
|
62
|
+
assert_equal Array, @obj2.attributes.class
|
63
|
+
|
64
|
+
@obj2 << 1
|
65
|
+
assert_equal 1, @obj2.first
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_yamlize_array
|
69
|
+
a = [].yamlize @test_path
|
70
|
+
|
71
|
+
a << 1
|
72
|
+
a.save
|
73
|
+
|
74
|
+
# test some array functions
|
75
|
+
b = [].yamlize @test_path
|
76
|
+
assert_equal 1, b.first
|
77
|
+
assert_equal [2], b.map{|i| i+1}
|
78
|
+
|
79
|
+
b << 1
|
80
|
+
b.uniq!
|
81
|
+
assert_equal [1], b.attributes
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_yamlize_hash
|
85
|
+
a = {}.yamlize @test_path
|
86
|
+
|
87
|
+
a.first = 1
|
88
|
+
a.save
|
89
|
+
|
90
|
+
b = {}.yamlize @test_path
|
91
|
+
assert_equal 1, b.first
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
metadata
CHANGED
@@ -1,36 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utsup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Merwin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
- |
|
12
|
-
-----BEGIN CERTIFICATE-----
|
13
|
-
MIIDNDCCAhygAwIBAgIBADANBgkqhkiG9w0BAQUFADBAMQ0wCwYDVQQDDARuaWNr
|
14
|
-
MRowGAYKCZImiZPyLGQBGRYKbGVtdXJoZWF2eTETMBEGCgmSJomT8ixkARkWA2Nv
|
15
|
-
bTAeFw0wOTA5MjkyMzEzMDVaFw0xMDA5MjkyMzEzMDVaMEAxDTALBgNVBAMMBG5p
|
16
|
-
Y2sxGjAYBgoJkiaJk/IsZAEZFgpsZW11cmhlYXZ5MRMwEQYKCZImiZPyLGQBGRYD
|
17
|
-
Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3uflg3FiN5qVj79C
|
18
|
-
hL+IdQJI+t1bGLrcx38cgFk9wzsBWb4OuGJdfRfUputDQ1f0q+tmRO834YuiEzq9
|
19
|
-
Ekhv8GMQ4KepU6E6d1mbBVSovuDljxpprGDP1Aj/ahiG4vU26gE9IjNFxwlkRPov
|
20
|
-
jVgUNVU2iXtd7pAM3EeEIzSFXfoTOGl1sk6UXMlMRyD6rkuIHiM08+7Q6UMdkO49
|
21
|
-
fMqF49DeMrlJfY4HBbegAF4dpWNY3SPhFWtOcdtCRF0AplB7HtR5laBsAdHjz3gM
|
22
|
-
klk+KNM5vptxWJPIqvXWS4pPudBCwz40gXRGR+BpU0UQiTqp1FiKCgL7DI4/Tm62
|
23
|
-
CHNMvwIDAQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU
|
24
|
-
DtwNA5H16pAiznZOti8bEjba8tUwDQYJKoZIhvcNAQEFBQADggEBALYguz5G0/OJ
|
25
|
-
xT+pCJlgQuU5XbKPx9dibev3ixqDaXz6F3rofNyskUGuCz80pIxwuVjsf7SC/l6x
|
26
|
-
iSqV4RZvqrQvgMa2VIQrbIfVya59CyFl+nlENev58nSZHo/3+AOK/rCLrvyRbv+y
|
27
|
-
NZocOuJdRiSWjnnRga8ccYA/Hu5OQsqUi3zWcZJx9Pf1yik/TGQBB5fVCg3wc/tT
|
28
|
-
86mx1YMM5+6jp62bpABA/ztg5a1AwPjLztZO+kdsa5JPAe8kEORjgFUQd0bgoG1k
|
29
|
-
CGOLg0n36R4a1G+c6Meu9GeNGECbxY/1lzZOU9gfTqKd3DB+14BvAyvc5dTbR/RX
|
30
|
-
DrswbWvrKlA=
|
31
|
-
-----END CERTIFICATE-----
|
10
|
+
cert_chain: []
|
32
11
|
|
33
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-31 00:00:00 -07:00
|
34
13
|
default_executable:
|
35
14
|
dependencies:
|
36
15
|
- !ruby/object:Gem::Dependency
|
@@ -43,6 +22,16 @@ dependencies:
|
|
43
22
|
- !ruby/object:Gem::Version
|
44
23
|
version: "0"
|
45
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: daemons
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
46
35
|
- !ruby/object:Gem::Dependency
|
47
36
|
name: hoe
|
48
37
|
type: :development
|
@@ -51,7 +40,7 @@ dependencies:
|
|
51
40
|
requirements:
|
52
41
|
- - ">="
|
53
42
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.3.
|
43
|
+
version: 2.3.2
|
55
44
|
version:
|
56
45
|
description: utsup.com client
|
57
46
|
email:
|
@@ -77,16 +66,29 @@ files:
|
|
77
66
|
- lib/hooks/post-merge
|
78
67
|
- lib/hooks/post-receive
|
79
68
|
- lib/sup.rb
|
69
|
+
- lib/sup/differ/differ_control.rb
|
70
|
+
- lib/sup/differ/differ_run.rb
|
71
|
+
- lib/sup/differ/differ.rb
|
72
|
+
- lib/sup/yamlize.rb
|
73
|
+
- lib/sup/command.rb
|
74
|
+
- lib/sup/help.rb
|
75
|
+
- lib/sup/api.rb
|
80
76
|
- script/console
|
81
77
|
- script/destroy
|
82
78
|
- script/generate
|
83
79
|
- test/test_helper.rb
|
84
80
|
- test/test_sup.rb
|
81
|
+
- test/test_yamler.rb
|
85
82
|
has_rdoc: true
|
86
|
-
homepage: http://github.com/yickster/
|
83
|
+
homepage: http://github.com/yickster/utsup_gem
|
87
84
|
licenses: []
|
88
85
|
|
89
|
-
post_install_message:
|
86
|
+
post_install_message: "=======================================\n\
|
87
|
+
UtSup Installed!\n\
|
88
|
+
=======================================\n\n\
|
89
|
+
Be sure to sign up for an account at http://utsup.com\n\n\
|
90
|
+
Then, to begin using, first run:\n\n sup setup <your-api-key>\n\n\
|
91
|
+
Thanks for using UtSup!\n - Lemur Heavy Industries (http://lemurheavy.com)\n "
|
90
92
|
rdoc_options: []
|
91
93
|
|
92
94
|
require_paths:
|
@@ -106,10 +108,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
108
|
requirements: []
|
107
109
|
|
108
110
|
rubyforge_project: utsup
|
109
|
-
rubygems_version: 1.3.
|
111
|
+
rubygems_version: 1.3.5
|
110
112
|
signing_key:
|
111
113
|
specification_version: 3
|
112
114
|
summary: utsup.com client
|
113
115
|
test_files:
|
114
116
|
- test/test_helper.rb
|
115
117
|
- test/test_sup.rb
|
118
|
+
- test/test_yamler.rb
|
data.tar.gz.sig
DELETED
Binary file
|
metadata.gz.sig
DELETED
Binary file
|