utsup 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data.tar.gz.sig CHANGED
Binary file
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ $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'],['daemons']]
17
+ self.extra_deps = [['schacon-git'],['daemons'],['terminal_markup']]
18
18
  # self.spec_extras[:extensions] = "extconf.rb"
19
19
  self.spec_extras[:rdoc_options] = ""
20
20
  self.spec_extras[:homepage] = %q{http://github.com/yickster/utsup_gem}
data/lib/sup.rb CHANGED
@@ -8,14 +8,17 @@ require 'rubygems'
8
8
  require 'active_resource'
9
9
  require 'git'
10
10
 
11
+ require 'terminal_markup'
12
+
11
13
  require 'sup/yamlize'
12
14
 
13
15
  require 'sup/differ/differ'
14
16
  require 'sup/api'
15
17
  require 'sup/command'
18
+ require 'sup/help'
16
19
 
17
20
  module Sup
18
- VERSION = '0.1.1'
21
+ VERSION = '0.1.2'
19
22
  GIT_HOOKS = %w(post-commit post-receive post-merge post-checkout) #TODO: post-rebase?
20
23
 
21
24
  GLOBAL_CONFIG_PATH = '~/.utsup/config.yml'
@@ -32,12 +35,14 @@ module Sup
32
35
  # ===========================
33
36
 
34
37
  def sign_in
35
- puts "Enter your UtSup.com credentials. Don't have an account yet? Create one at #{SIGNUP_URL}"
38
+ render "Please enter your "+"UtSup?".in_magenta+" credentials. " +
39
+ "Don't have an account yet? ".in_red +
40
+ "Create one at ".in_green + "#{SIGNUP_URL}".in_blue.as_underline
36
41
 
37
42
  loop do
38
- print "Email: "
43
+ print "Email: ".in_yellow.escape
39
44
  email = gets.chomp
40
- print "Password: "
45
+ print "Password: ".in_yellow.escape
41
46
  system "stty -echo"
42
47
  password = gets.chomp
43
48
  system "stty echo"
@@ -46,7 +51,7 @@ module Sup
46
51
  if api_key = Api::User.get_api_key(email, password)
47
52
  return api_key
48
53
  else
49
- puts "Couldn't find that email/password combo..."
54
+ render "Couldn't find that email/password combo...".in_red
50
55
  end
51
56
  end
52
57
  end
@@ -71,9 +76,11 @@ module Sup
71
76
  unless global_config['api_key']
72
77
  global_config.api_key = api_key || sign_in
73
78
  global_config.save
74
- puts "Success! Added API Key to #{GLOBAL_CONFIG_PATH}\n - Lemur Heavy Industries (http://lemurheavy.com)"
79
+ render "Success!".in_green+" Added API Key to #{GLOBAL_CONFIG_PATH}\n" +
80
+ " - Lemur Heavy Industries ".in_yellow +
81
+ "http://lemurheavy.com".in_blue.as_underline
75
82
  else
76
- puts "You're good to go."
83
+ render "You're good to go.".in_green
77
84
  end
78
85
  end
79
86
 
@@ -129,7 +136,7 @@ module Sup
129
136
  global_project_config = Yamlize.new GLOBAL_PROJECT_CONFIG_PATH
130
137
 
131
138
  unless global_config['api_key']
132
- puts "You need to run 'sup setup <api_key>' first, thanks!"
139
+ render "You need to run 'sup setup <api_key>' first, thanks!".in_red
133
140
  exit 0
134
141
  end
135
142
 
@@ -231,12 +238,18 @@ module Sup
231
238
  :today => opts[:today]
232
239
  }
233
240
 
234
- puts "----------------------------------------------------------------------------------"
235
- puts "This is UtSup#{" with #{name}" if name}:\n"
241
+ width = statuses.map{|s| s.to_command_line.gsub(/\\e\[.*?m/,'').size}.max + 2
242
+ line = (" "*width).as_underline.in_white
243
+
244
+ render "\nThis is ".in_green+"UtSup?".in_magenta+"#{" with #{name.in_yellow}".in_green if name}:"
245
+ render line
246
+ puts "\n"
236
247
  statuses.each do |status|
237
- puts "=> #{status.to_command_line.escape}"
248
+ render " "+status.to_command_line
238
249
  end
239
- puts "----------------------------------------------------------------------------------"
250
+ render line
251
+
252
+ puts "\n"
240
253
  end
241
254
 
242
255
  def get_users
@@ -249,15 +262,14 @@ module Sup
249
262
  end
250
263
 
251
264
  def socket_error
252
- puts "UtSup? v.#{VERSION} Offline."
265
+ render "UtSup? v.#{VERSION} Offline.".in_black.on_red
253
266
  end
254
267
 
255
268
  end
256
269
  end
257
270
 
258
-
259
- class String
260
- def escape
261
- eval '"'+ gsub(/\"/,'\"') + '"'
271
+ module Kernel
272
+ def render(string)
273
+ puts string.escape
262
274
  end
263
275
  end
data/lib/sup/command.rb CHANGED
@@ -27,12 +27,12 @@ module Sup
27
27
  when "init":
28
28
  Sup::init args.first
29
29
  Differ::restart! # to reload projects.yml
30
- puts "Supified!"
30
+ render "Supified!".in_white.on_green
31
31
 
32
32
  when "in":
33
33
  Sup::check_in args.last
34
34
  Differ::start!
35
- puts "Checked in."
35
+ render "Sup'd in.".in_green
36
36
 
37
37
  when "out":
38
38
  Sup::check_out args.last
@@ -47,7 +47,7 @@ module Sup
47
47
 
48
48
  when "nm":
49
49
  Sup::undo
50
- puts "Undid last Supdate."
50
+ render "Undid last Supdate.".in_red
51
51
 
52
52
  when "remove":
53
53
  File.unlink File.join(Dir.pwd, PROJECT_CONFIG_PATH)
@@ -75,22 +75,22 @@ module Sup
75
75
  # TODO: combine user_name check and supdate into one ActiveResource call -- do name-check & return or supdate on server
76
76
  if Api::User.check_name(command)
77
77
  Sup::get_statuses :name => command, :today => true
78
- return
78
+ else
79
+ # implicit text update: sup "chillin"
80
+ Sup::update command
81
+ render "Supdated!".in_green
79
82
  end
80
-
81
- # implicit text update: sup "chillin"
82
- Sup::update command
83
- puts "Supdated."
84
-
85
83
  else
86
84
  # full status check
87
85
  Sup::get_statuses
88
86
  end
89
87
 
90
88
  # TODO: config file option to set verbosity
91
- puts "UtSup? v.#{VERSION} (#{Time.now - bench}s)"
89
+ render "UtSup?".in_magenta +
90
+ " v.#{VERSION}".in_green+
91
+ " (#{Time.now - bench}s)".in_white
92
92
 
93
- rescue SocketError
93
+ rescue SocketError, Errno::ECONNREFUSED
94
94
  Sup::socket_error
95
95
  end
96
96
  end
data/lib/sup/yamlize.rb CHANGED
@@ -52,8 +52,12 @@ class Yamlize
52
52
  end
53
53
  end
54
54
 
55
- class Object
55
+ module YamlizeMethods
56
56
  def yamlize(path, &block)
57
57
  Yamlize.new path, self.class, &block
58
58
  end
59
+ end
60
+
61
+ class Object
62
+ include YamlizeMethods
59
63
  end
data/test/test_sup.rb CHANGED
@@ -5,7 +5,7 @@ class TestSup < Test::Unit::TestCase
5
5
  def setup
6
6
  end
7
7
 
8
- def test_truth
9
- assert true
8
+ def test_commands
9
+
10
10
  end
11
11
  end
data/test/test_yamler.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  require File.dirname(__FILE__) + '/test_helper.rb'
2
2
 
3
- class TestYamler < Test::Unit::TestCase
3
+ class TestYamlize < Test::Unit::TestCase
4
4
 
5
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")
6
+ @test_path = File.join(File.dirname(__FILE__),"yamlize_test.yml")
7
+ @test_path2 = File.join(File.dirname(__FILE__),"yamlize_test2.yml")
8
8
  end
9
9
 
10
10
  def teardown
@@ -13,12 +13,12 @@ class TestYamler < Test::Unit::TestCase
13
13
  end
14
14
 
15
15
  def test_init
16
- Yamler.new @test_path
16
+ Yamlize.new @test_path
17
17
  assert File.exists?(@test_path)
18
18
  end
19
19
 
20
20
  def test_setter
21
- @obj = Yamler.new @test_path
21
+ @obj = Yamlize.new @test_path
22
22
  @obj.name = "nick merwin"
23
23
  @obj.title = "programmer"
24
24
 
@@ -36,29 +36,29 @@ class TestYamler < Test::Unit::TestCase
36
36
  end
37
37
 
38
38
  def test_save
39
- @obj = Yamler.new @test_path
39
+ @obj = Yamlize.new @test_path
40
40
  @obj.name = "nick merwin"
41
41
 
42
42
  @obj.save
43
43
 
44
- @obj2 = Yamler.new @test_path
44
+ @obj2 = Yamlize.new @test_path
45
45
  assert_equal "nick merwin", @obj2.name
46
46
  end
47
47
 
48
48
  def test_block
49
- Yamler.new @test_path do |obj|
49
+ Yamlize.new @test_path do |obj|
50
50
  obj.name = "nick merwin"
51
51
  end
52
52
 
53
- @obj = Yamler.new @test_path
53
+ @obj = Yamlize.new @test_path
54
54
  assert_equal "nick merwin", @obj.name
55
55
  end
56
56
 
57
57
  def test_type
58
- @obj = Yamler.new @test_path
58
+ @obj = Yamlize.new @test_path
59
59
  assert_equal Hash, @obj.attributes.class
60
60
 
61
- @obj2 = Yamler.new @test_path2, Array
61
+ @obj2 = Yamlize.new @test_path2, Array
62
62
  assert_equal Array, @obj2.attributes.class
63
63
 
64
64
  @obj2 << 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utsup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Merwin
@@ -30,7 +30,7 @@ cert_chain:
30
30
  DrswbWvrKlA=
31
31
  -----END CERTIFICATE-----
32
32
 
33
- date: 2009-11-12 00:00:00 -08:00
33
+ date: 2009-11-13 00:00:00 -08:00
34
34
  default_executable:
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
@@ -53,6 +53,16 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: "0"
55
55
  version:
56
+ - !ruby/object:Gem::Dependency
57
+ name: terminal_markup
58
+ type: :runtime
59
+ version_requirement:
60
+ version_requirements: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ version:
56
66
  - !ruby/object:Gem::Dependency
57
67
  name: hoe
58
68
  type: :development
metadata.gz.sig CHANGED
Binary file