yourinal 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.rdoc +16 -0
- data/Rakefile +1 -0
- data/lib/yourinal.rb +12 -0
- data/lib/yourinal/progress.rb +68 -0
- data/lib/yourinal/version.rb +3 -0
- data/yourinal.gemspec +20 -0
- metadata +54 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
= Yourinal; Your Terminal
|
2
|
+
|
3
|
+
A collection tools and utilities for your Ruby terminal needs.
|
4
|
+
|
5
|
+
== Future
|
6
|
+
|
7
|
+
Currenty only a progress indicator, more coming to Yourinal.
|
8
|
+
|
9
|
+
== Credit
|
10
|
+
|
11
|
+
Name credit goes to Jim Albano (@JimDAlbano).
|
12
|
+
I was going to call it Coctane; Console Octane or Rubinal.
|
13
|
+
Yourinal; Your Terminal - is far better ;)
|
14
|
+
|
15
|
+
Backup name via Flip Sasser (@flipsasser): PimpMyConsole
|
16
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/lib/yourinal.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Yourinal; Your Terminal
|
2
|
+
#
|
3
|
+
# A collection tools and utilities for your terminal needs
|
4
|
+
#
|
5
|
+
# Name credit goes to Jim Albano (@JimDAlbano).
|
6
|
+
# I was going to call it Coctane; Console Octane.
|
7
|
+
# Yourinal; Your Terminal - is far better.
|
8
|
+
#
|
9
|
+
# Backup name via Flip Sasser (@flipsasser): PimpMyConsole
|
10
|
+
#
|
11
|
+
require "yourinal/version"
|
12
|
+
require "yourinal/progress"
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Yourinal
|
2
|
+
# Terminal Progress Indicator
|
3
|
+
#
|
4
|
+
# Displays a starting message and an indicator each interval until the
|
5
|
+
# passed block resolves. Good for showing that something takes a while
|
6
|
+
# and is expected. Essentially a progress bar for unknown total/finish.
|
7
|
+
#
|
8
|
+
# message - The string to be displayed at start
|
9
|
+
# interval - The time in between each indicator mark
|
10
|
+
# indicator - The string displayed on each interval
|
11
|
+
#
|
12
|
+
# Examples:
|
13
|
+
#
|
14
|
+
# connection_progress = Yourinal::Progress.new("Connecting to service, please wait")
|
15
|
+
# response = connection_progress.start {
|
16
|
+
# # Code that takes a while...
|
17
|
+
# # That you want to wait for...
|
18
|
+
# }
|
19
|
+
#
|
20
|
+
# Returns "Connecting to service, please wait" with "." for each second that passes
|
21
|
+
# Then connection_progress.start returns the result of the block.
|
22
|
+
#
|
23
|
+
# Output "Connecting to service, please wait...........done (10.69 seconds)"
|
24
|
+
class Progress
|
25
|
+
attr_accessor :results
|
26
|
+
|
27
|
+
def initialize(message='Starting', interval=1.0)
|
28
|
+
@message = message
|
29
|
+
@interval = interval
|
30
|
+
end
|
31
|
+
|
32
|
+
def start
|
33
|
+
setup
|
34
|
+
@results = yield
|
35
|
+
teardown
|
36
|
+
rescue => e
|
37
|
+
raise "Failed: #{e.message}"
|
38
|
+
ensure
|
39
|
+
kill_indicator
|
40
|
+
end
|
41
|
+
|
42
|
+
def kill_indicator
|
43
|
+
return unless @indicator
|
44
|
+
Process.kill 'TERM', @indicator
|
45
|
+
end
|
46
|
+
|
47
|
+
def start_indicator
|
48
|
+
@indicator = fork { loop {print '.'; sleep @interval}}
|
49
|
+
end
|
50
|
+
|
51
|
+
def setup
|
52
|
+
print @message
|
53
|
+
@start_time = Time.now
|
54
|
+
start_indicator
|
55
|
+
end
|
56
|
+
|
57
|
+
def teardown
|
58
|
+
@end_time = Time.now
|
59
|
+
kill_indicator
|
60
|
+
print "done (#{sprintf('%.2f', total_time)} seconds)\n"
|
61
|
+
@results
|
62
|
+
end
|
63
|
+
|
64
|
+
def total_time
|
65
|
+
@end_time - @start_time
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/yourinal.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "yourinal/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "yourinal"
|
7
|
+
s.version = Yourinal::VERSION
|
8
|
+
s.authors = ["Adam Bair"]
|
9
|
+
s.email = ["adambair@gmail.com"]
|
10
|
+
s.homepage = "http://github.com/adambair/yourinal"
|
11
|
+
s.summary = %q{Yourinal; Your Terminal - A collection tools and utilities for your terminal needs.}
|
12
|
+
s.description = %q{Currenty only a progress indicator, more coming to your teriminal}
|
13
|
+
|
14
|
+
s.rubyforge_project = "yourinal"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yourinal
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Adam Bair
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-10-25 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: Currenty only a progress indicator, more coming to your teriminal
|
15
|
+
email:
|
16
|
+
- adambair@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- README.rdoc
|
24
|
+
- Rakefile
|
25
|
+
- lib/yourinal.rb
|
26
|
+
- lib/yourinal/progress.rb
|
27
|
+
- lib/yourinal/version.rb
|
28
|
+
- yourinal.gemspec
|
29
|
+
homepage: http://github.com/adambair/yourinal
|
30
|
+
licenses: []
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubyforge_project: yourinal
|
49
|
+
rubygems_version: 1.8.8
|
50
|
+
signing_key:
|
51
|
+
specification_version: 3
|
52
|
+
summary: Yourinal; Your Terminal - A collection tools and utilities for your terminal
|
53
|
+
needs.
|
54
|
+
test_files: []
|