shelltastic 0.2.5 → 0.3.0

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/lib/shelltastic.rb CHANGED
@@ -4,20 +4,20 @@ require_relative "shelltastic/command_io"
4
4
  require_relative "shelltastic/timer"
5
5
  require_relative "shelltastic/exceptions"
6
6
 
7
- # @! ShellTastic
7
+ # ShellTastic namespace
8
8
  module ShellTastic
9
- # Command is the namespace for the actual meat of the gem
10
9
  class Command
11
10
  class << self
12
- # encapsualtes the popen call
11
+ # run is the entry point to api
13
12
  # @param command [String] command or multiple commands to be executed
13
+ # @param command [Array] multiple commands to be executed
14
14
  # @param timer [Object] timer object, @see ShellTastic::Timer
15
15
  # @return [Array] Array of hashes for each command executed @see IO::popen
16
16
  # @example
17
- # ShellTastic::Command.run "whoami"
18
- # ShellTastic::Command.run "whoami", "date"
17
+ # ShellTastic::Command.run "whoami"
18
+ # ShellTastic::Command.run "whoami", "date"
19
19
  def run(*command)
20
- command.flatten.map { |cmd| ShellTastic::IO.popen(cmd, ShellTastic::Timer) }
20
+ command.flatten.map { |cmd| ShellTastic::IO.popen(cmd, ShellTastic::Timer.new) }
21
21
  end
22
22
  end
23
23
  end
@@ -8,11 +8,12 @@ module ShellTastic
8
8
  class << self
9
9
  # A wrapper around popen4
10
10
  #
11
- # @see #Command.run
12
- # @param command [String] command(s) to run
13
- # @return [Array, Hash] command_results the command results from shell
14
- # [{ :output, :pid, :error, :start, :stop, :total_time, :exitstatus }]
15
- def popen(command, timer=ShellTastic::Timer)
11
+ # @see #run
12
+ # @param command [String] command(s) to execute
13
+ # @param command [Array] command(s) to execute
14
+ # @param command [Time] time object for run time
15
+ # @return [Array] array of hash meta-data for the command(s) executed
16
+ def popen(command, timer)
16
17
  string_nil_or_blank?(command)
17
18
  command_results = {}
18
19
  begin
@@ -1,4 +1,4 @@
1
1
  module ShellTastic
2
- # @raise: Describes an Exception that a method may throw
2
+ # A command Exception
3
3
  class CommandException < RuntimeError; end
4
4
  end
@@ -1,18 +1,21 @@
1
1
  module ShellTastic
2
- module Timer
3
- class << self
2
+ class Timer
3
+ def initialize
4
+
5
+ end
6
+
4
7
  # Creates a start time object
5
8
  # @param [nil]
6
9
  # @return [Time] Time now object
7
10
  def start
8
- @start = Time.now
11
+ @start_time = Time.now
9
12
  end
10
13
 
11
14
  # Creates a stop time object
12
15
  # @param [nil]
13
16
  # @return [Time] Time now object
14
17
  def stop
15
- @stop = Time.now
18
+ @stop_time = Time.now
16
19
  end
17
20
 
18
21
  # Calculates the total time elapsed
@@ -22,11 +25,10 @@ module ShellTastic
22
25
  # @return [Time] Time elapsed between #start and #stop
23
26
  def total_time(milliseconds = false)
24
27
  if milliseconds
25
- (@stop - @start) * 1000.0
28
+ (@stop_time - @start_time) * 1000.0
26
29
  else
27
- @stop - @start
30
+ @stop_time - @start_time
28
31
  end
29
32
  end
30
33
  end
31
34
  end
32
- end
@@ -2,12 +2,12 @@ module ShellTastic
2
2
 
3
3
  module Utils
4
4
  # A dirty string check for nil empty or just whitespace
5
- # @param [String] str the string the needs to be checked
5
+ # @param str [String] a string that needs to be checked
6
6
  # @return [Boolean, nil] true if str is empty, nil, or just whitespace
7
7
  def string_nil_or_blank? str
8
8
  # raise if command is empty or nil
9
9
  if str !~ /[^[:space:]]/ || str.nil? || str.empty?
10
- raise ShellTastic::CommandException.new("Command is emtpy or nil")
10
+ raise ShellTastic::CommandException.new("The command is emtpy or nil")
11
11
  end
12
12
  end
13
13
 
@@ -1,3 +1,3 @@
1
- module Shelltastic
2
- VERSION = "0.2.5"
1
+ module ShellTastic
2
+ VERSION = "0.3.0"
3
3
  end
data/shelltastic.gemspec CHANGED
@@ -5,11 +5,11 @@ require 'shelltastic/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = "shelltastic"
8
- gem.version = Shelltastic::VERSION
9
- gem.authors = ["Brad Smith"]
8
+ gem.version = ShellTastic::VERSION
9
+ gem.authors = ["Bradley Smith"]
10
10
  gem.email = ["bradleydsmith@gmail.com"]
11
- gem.description = %q{Shelltastic is another *nix shell wrapper}
12
- gem.summary = %q{*nix shell wrapper}
11
+ gem.description = %q{Shelltastic is a simple *nix shell wrapper}
12
+ gem.summary = %q{Shelltastic is a simple *nix shell wrapper}
13
13
  gem.homepage = ""
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
@@ -26,7 +26,7 @@ describe ShellTastic do
26
26
  it "should alert if command is empty or nil" do
27
27
  expect {
28
28
  ShellTastic::Command.run("")
29
- }.to raise_error("Command is emtpy or nil")
29
+ }.to raise_error("The command is emtpy or nil")
30
30
  end
31
31
 
32
32
  end
data/spec/timer_spec.rb CHANGED
@@ -2,20 +2,21 @@ require 'spec_helper'
2
2
 
3
3
  describe ShellTastic::Timer do
4
4
  it "should report start time" do
5
- start = ShellTastic::Timer.start
5
+ start = ShellTastic::Timer.new.start
6
6
  start.class.should eq(Time)
7
7
  end
8
8
 
9
9
  it "should report stop time" do
10
- stop = ShellTastic::Timer.stop
10
+ stop = ShellTastic::Timer.new.stop
11
11
  stop.class.should eq(Time)
12
12
  end
13
13
 
14
14
  it "should report total time" do
15
- start = ShellTastic::Timer.start
15
+ timer = ShellTastic::Timer.new
16
+ start = timer.start
16
17
  sleep 2
17
- stop = ShellTastic::Timer.stop
18
- total = ShellTastic::Timer.total_time
18
+ stop = timer.stop
19
+ total = timer.total_time
19
20
  total.round.should eq(2)
20
21
  end
21
22
 
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shelltastic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - Brad Smith
8
+ - Bradley Smith
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
@@ -59,7 +59,7 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
- description: Shelltastic is another *nix shell wrapper
62
+ description: Shelltastic is a simple *nix shell wrapper
63
63
  email:
64
64
  - bradleydsmith@gmail.com
65
65
  executables: []
@@ -98,7 +98,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  segments:
100
100
  - 0
101
- hash: 3694164165919668282
101
+ hash: 375658513519469739
102
102
  required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  none: false
104
104
  requirements:
@@ -107,13 +107,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  segments:
109
109
  - 0
110
- hash: 3694164165919668282
110
+ hash: 375658513519469739
111
111
  requirements: []
112
112
  rubyforge_project:
113
113
  rubygems_version: 1.8.24
114
114
  signing_key:
115
115
  specification_version: 3
116
- summary: ! '*nix shell wrapper'
116
+ summary: Shelltastic is a simple *nix shell wrapper
117
117
  test_files:
118
118
  - spec/shelltastic_spec.rb
119
119
  - spec/spec_helper.rb