patir 0.6.4 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -1,6 +1,12 @@
1
- ==0.6.4 / 2009-09-4
2
- * context parameter added to Command#run
1
+ ==0.7.0 / 2011-08-11
2
+ * Ruby 1.9 compatibility
3
+ * updated systemu dependency
4
+ * Unit tests extended
5
+ * added context parameter to RubyCommand instances
6
+ * ShellCommand now sets the error output consistently (at times it was nil)
3
7
 
8
+ ==0.6.4 / 2009-09-04
9
+ * context parameter added to Command#run
4
10
  ==0.6.3
5
11
  * Repository restructured (git is used internally so the svn repository matches now the master branch)
6
12
  * Cleanup. Some obsolete code was removed
@@ -1,3 +1,4 @@
1
+ COPYING.txt
1
2
  History.txt
2
3
  Manifest.txt
3
4
  README.txt
@@ -6,29 +7,7 @@ Rakefile
6
7
  lib/patir/base.rb
7
8
  lib/patir/command.rb
8
9
  lib/patir/configuration.rb
10
+ test/samples/empty.cfg
9
11
  test/test_patir_base.rb
10
12
  test/test_patir_command.rb
11
13
  test/test_patir_configuration.rb
12
- test/samples/empty.cfg
13
- docu/style.css
14
- docu/tie_logo.gif
15
- docu/welcome.html
16
- docu/bg_menu.gif
17
- docu/bg_submenu.gif
18
- docu/contact.html
19
- docu/index.html
20
- docu/patir02.html
21
- docu/patir03.html
22
- docu/patir04.html
23
- docu/patir05.html
24
- docu/rutema01.html
25
- docu/rutema02.html
26
- docu/rutema03.html
27
- docu/rutema04.html
28
- docu/rw-intro.png
29
- docu/rw-run.png
30
- docu/rw-scenario.png
31
- docu/screenshots.html
32
- docu/style.css
33
- docu/tie_logo.gif
34
- docu/welcome.html
data/README.txt CHANGED
@@ -1,32 +1,22 @@
1
- patir - http://patir.rubyforge.org
2
-
1
+ patir http://patir.rubyforge.org
3
2
  == DESCRIPTION:
4
3
 
5
- patir provides the libraries common to all the project automation tools included in the Patir project.
6
-
7
- == FEATURES/PROBLEMS:
8
-
9
- * Configuration library for creating Ruby configuration files
10
- * Command library abstracting the execution of commands
11
-
12
- == SYNOPSIS:
13
-
14
- patir is the library of common functionality used in the patir projects.
15
- This includes a class that allows you to build configuration files in Ruby and a library for command abstraction.
16
-
17
- == REQUIREMENTS:
4
+ patir provides code to enable project automation tasks:
18
5
 
19
- * systemu
6
+ * A default logging format for ruby's built-in Logger
7
+ * A command abstraction (Patir::Command) with a platform independent implementation for running shell commands (Patir::ShellCommand) and ruby code (Patir::RubyCommand)
8
+ * Command sequences using the same command abstraction as single commands.
9
+ * Code that allows the use of configuration files written in ruby.
20
10
 
21
11
  == INSTALL:
22
12
 
23
- * gem install patir
13
+ gem install patir
24
14
 
25
15
  == LICENSE:
26
16
 
27
17
  (The Ruby License)
28
18
 
29
- patir is copyright (c) 2007 Vassilis Rizopoulos
19
+ patir is copyright (c) 2007-2011 Vassilis Rizopoulos
30
20
 
31
21
  You can redistribute it and/or modify it under either the terms of the GPL
32
22
  (see COPYING.txt file), or the conditions below:
data/Rakefile CHANGED
@@ -4,16 +4,18 @@ require 'rubygems'
4
4
  require 'hoe'
5
5
  require 'patir/base'
6
6
 
7
- Hoe.spec('patir') do |p|
8
- p.version = Patir::Version::STRING
9
- p.author = "Vassilis Rizopoulos"
10
- p.email = "riva@braveworld.net"
11
- p.summary = 'patir (Project Automation Tools in Ruby) provides libraries for use in automation tools'
12
- p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
13
- p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
14
- p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
15
- p.rubyforge_name="patir"
16
- p.extra_deps<<['systemu']
7
+ Hoe.plugins.delete :compiler
8
+
9
+ Hoe.spec('patir') do
10
+ self.version = Patir::Version::STRING
11
+ self.rubyforge_name = 'patir'
12
+ self.author = "Vassilis Rizopoulos"
13
+ self.email = "vassilisrizopoulos@gmail.com"
14
+ self.summary = 'patir (Project Automation Tools in Ruby) provides libraries for use in project automation tools'
15
+ self.description = paragraphs_of('README.md', 1..4).join("\n\n")
16
+ self.url = "http://patir.rubyforge.org"
17
+ self.changes = paragraphs_of('History.txt', 0..1).join("\n\n")
18
+ extra_deps<<['systemu',"~>2.2.0"]
17
19
  end
18
20
 
19
21
  # vim: syntax=Ruby
@@ -1,12 +1,12 @@
1
- # Copyright (c) 2007 Vassilis Rizopoulos. All rights reserved.
1
+ # Copyright (c) 2007-2010 Vassilis Rizopoulos. All rights reserved.
2
2
  require 'logger'
3
3
  #This is the base module of the Patir system. It contains some usefull helper methods used by all child projects.
4
4
  module Patir
5
5
  #The Patir version used
6
6
  module Version
7
7
  MAJOR=0
8
- MINOR=6
9
- TINY=4
8
+ MINOR=7
9
+ TINY=0
10
10
  STRING=[ MAJOR, MINOR, TINY ].join( "." )
11
11
  end
12
12
  #Error thrown usually in initialize methods when missing required parameters
@@ -32,13 +32,9 @@ module Patir
32
32
  #It creates a logger just as we want it.
33
33
  #
34
34
  #mode can be
35
- #
36
- #:mute to set the level to FATAL
37
- #
38
- #:silent to set the level to WARN
39
- #
40
- #:debug to set the level to DEBUG. Debug is set also if $DEBUG is true.
41
- #
35
+ # :mute to set the level to FATAL
36
+ # :silent to set the level to WARN
37
+ # :debug to set the level to DEBUG. Debug is set also if $DEBUG is true.
42
38
  #The default logger level is INFO
43
39
  def self.setup_logger(filename=nil,mode=nil)
44
40
  if filename
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007 Vassilis Rizopoulos. All rights reserved.
1
+ # Copyright (c) 2007-2010 Vassilis Rizopoulos. All rights reserved.
2
2
  require 'observer'
3
3
  require 'fileutils'
4
4
  require 'rubygems'
@@ -83,14 +83,10 @@ module Patir
83
83
  #returns the command status.
84
84
  #
85
85
  #valid stati are
86
- #
87
- #:not_executed when the command was not run
88
- #
89
- #:success when the command has finished succesfully
90
- #
91
- #:error when the command has an error
92
- #
93
- #:warning when the command finished without errors, but there where warnings
86
+ # :not_executed when the command was not run
87
+ # :success when the command has finished succesfully
88
+ # :error when the command has an error
89
+ # :warning when the command finished without errors, but there where warnings
94
90
  def status
95
91
  #initialize nil values to something meaningful
96
92
  @status||=:not_executed
@@ -98,16 +94,14 @@ module Patir
98
94
  end
99
95
  end
100
96
 
101
- #This class wraps the http://codeforpeople.com/lib/ruby/systemu/ as a Command duck.
97
+ #This class wraps the Command interface around https://github.com/ahoward/systemu
102
98
  #
103
- #It allows for execution of any shell command.
99
+ #It allows for execution of any shell command on any platform.
104
100
  #
105
101
  #Accepted keys are
106
- #
107
- #:cmd should be the shell command to execute (required - ParameterException will be raised).
108
- #
109
- #:working_directory for specifying the working directory (default is '.') and :name for assigning a name to the command (default is "").
110
- #
102
+ # :cmd - the shell command to execute (required - ParameterException will be raised).
103
+ # :working_directory - specify the working directory (default is '.')
104
+ # :name - assign a name to the command (default is "").
111
105
  class ShellCommand
112
106
  include Command
113
107
  #The constructor will throw CommandError if :cmd is missing.
@@ -127,7 +121,6 @@ module Patir
127
121
  #Executes the shell command and returns the status
128
122
  def run context=nil
129
123
  start_time=Time.now
130
- super
131
124
  begin
132
125
  #create the working directory if it does not exist
133
126
  FileUtils::mkdir_p(@working_directory,:verbose=>false)
@@ -150,6 +143,8 @@ module Patir
150
143
  @status=:warning
151
144
  end
152
145
  rescue
146
+ #if it blows in systemu it will be nil
147
+ @error||=""
153
148
  @error<<"\n#{$!.message}"
154
149
  @error<<"\n#{$!.backtrace}" if $DEBUG
155
150
  @status=:error
@@ -320,18 +315,12 @@ module Patir
320
315
  #In order to extract the status from steps, classes should quack to the rythm of Command. CommandSequenceStatus does this, so you can nest Stati
321
316
  #
322
317
  #The status of an action sequence is :not_executed, :running, :success, :warning or :error and represents the overall status
323
- #
324
- #:not_executed is set when all steps are :not_executed
325
- #
326
- #:running is set while the sequence is running.
327
- #
318
+ # :not_executed is set when all steps are :not_executed
319
+ # :running is set while the sequence is running.
328
320
  #Upon completion or interruption one of :success, :error or :warning will be set.
329
- #
330
- #:success is set when all steps are succesfull.
331
- #
332
- #:warning is set when at least one step generates warnings and there are no failures.
333
- #
334
- #:error is set when after execution at least one step has the :error status
321
+ # :success is set when all steps are succesfull.
322
+ # :warning is set when at least one step generates warnings and there are no failures.
323
+ # :error is set when after execution at least one step has the :error status
335
324
  class CommandSequenceStatus
336
325
  attr_accessor :start_time,:stop_time,:sequence_runner,:sequence_name,:status,:step_states,:sequence_id,:strategy
337
326
  #You can pass an array of Commands to initialize CommandSequenceStatus
@@ -466,16 +455,16 @@ module Patir
466
455
  #== Examples
467
456
  #An example (using the excellent HighLine lib) of a CLI prompt as a RubyCommand
468
457
  # RubyCommand.new("prompt") do |cmd|
469
- # cmd.output=""
470
- # cmd.error=""
471
- # unless HighLine.agree("#{step.text}?")
472
- # cmd.error="Why not?"
473
- # raise "You did not agree"
474
- # end
458
+ # cmd.output=""
459
+ # cmd.error=""
460
+ # unless HighLine.agree("#{step.text}?")
461
+ # cmd.error="Why not?"
462
+ # raise "You did not agree"
475
463
  # end
464
+ # end
476
465
  class RubyCommand
477
466
  include Patir::Command
478
- attr_reader :cmd,:working_directory
467
+ attr_reader :cmd,:working_directory,:context
479
468
  def initialize name,working_directory=nil,&block
480
469
  @name=name
481
470
  @working_directory=working_directory||"."
@@ -488,6 +477,7 @@ module Patir
488
477
  #Runs the associated block
489
478
  def run context=nil
490
479
  @run=true
480
+ @context=context
491
481
  begin
492
482
  t1=Time.now
493
483
  Dir.chdir(@working_directory) do
@@ -501,6 +491,7 @@ module Patir
501
491
  ensure
502
492
  @exec_time=Time.now-t1
503
493
  end
494
+ @context=nil
504
495
  return @status
505
496
  end
506
497
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007 Vassilis Rizopoulos. All rights reserved.
1
+ # Copyright (c) 2007-2010 Vassilis Rizopoulos. All rights reserved.
2
2
 
3
3
  require 'patir/base'
4
4
  module Patir
@@ -73,7 +73,7 @@ class TestShellCommand<Test::Unit::TestCase
73
73
  #when passed a wroking directory, the command should change into that directory
74
74
  def test_cwd
75
75
  cmd=nil
76
- assert_nothing_raised(){cmd=ShellCommand.new(:cmd=>"echo", :working_directory=>"samples/")}
76
+ assert_nothing_raised(){cmd=ShellCommand.new(:cmd=>"echo", :working_directory=>"missing/")}
77
77
  assert_nothing_raised(){cmd.run}
78
78
  assert(cmd.success?)
79
79
  end
@@ -222,6 +222,16 @@ class TestRubyCommand<Test::Unit::TestCase
222
222
  assert(!cmd.success?, "Successful?!")
223
223
  assert_equal(:error, cmd.status)
224
224
  end
225
+ def test_context
226
+ context="complex"
227
+ cmd=RubyCommand.new("test"){|c| c.output=c.context}
228
+ assert_nothing_raised() { cmd.run(context)}
229
+ assert(cmd.success?, "Not successful.")
230
+ assert_equal(context, cmd.output)
231
+ assert_nothing_raised() { cmd.run("other")}
232
+ assert_equal("other", cmd.output)
233
+ assert_equal(:success, cmd.status)
234
+ end
225
235
  end
226
236
 
227
237
  class TestCommandSequenceStatus<Test::Unit::TestCase
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ hash: 3
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 7
9
+ - 0
10
+ version: 0.7.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Vassilis Rizopoulos
@@ -9,85 +15,77 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-09-04 00:00:00 +02:00
13
- default_executable:
18
+ date: 2011-08-12 00:00:00 Z
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: systemu
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
20
25
  requirements:
21
- - - ">="
26
+ - - ~>
22
27
  - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
28
+ hash: 7
29
+ segments:
30
+ - 2
31
+ - 2
32
+ - 0
33
+ version: 2.2.0
34
+ type: :runtime
35
+ version_requirements: *id001
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: hoe
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
30
41
  requirements:
31
- - - ">="
42
+ - - ~>
32
43
  - !ruby/object:Gem::Version
33
- version: 2.3.3
34
- version:
44
+ hash: 21
45
+ segments:
46
+ - 2
47
+ - 11
48
+ version: "2.11"
49
+ type: :development
50
+ version_requirements: *id002
35
51
  description: |-
36
- == FEATURES/PROBLEMS:
52
+ ##DESCRIPTION:
37
53
 
38
- * Configuration library for creating Ruby configuration files
39
- * Command library abstracting the execution of commands
54
+ patir provides code to enable project automation tasks:
40
55
 
41
- == SYNOPSIS:
56
+ * A default logging format for ruby's built-in Logger
57
+ * A command abstraction with a platform independent implementation for running shell commands and ruby code
58
+ * Command sequences using the same command abstraction as single commands.
59
+ * Code that allows the use of configuration files written in ruby.
42
60
 
43
- patir is the library of common functionality used in the patir projects.
44
- This includes a class that allows you to build configuration files in Ruby and a library for command abstraction.
61
+ ##INSTALL:
45
62
 
46
- == REQUIREMENTS:
47
- email: riva@braveworld.net
63
+ gem install patir
64
+ email: vassilisrizopoulos@gmail.com
48
65
  executables: []
49
66
 
50
67
  extensions: []
51
68
 
52
69
  extra_rdoc_files:
70
+ - COPYING.txt
53
71
  - History.txt
54
72
  - Manifest.txt
55
73
  - README.txt
56
- - COPYING.txt
57
74
  files:
75
+ - COPYING.txt
58
76
  - History.txt
59
77
  - Manifest.txt
60
78
  - README.txt
61
- - COPYING.txt
62
79
  - Rakefile
63
80
  - lib/patir/base.rb
64
81
  - lib/patir/command.rb
65
82
  - lib/patir/configuration.rb
83
+ - test/samples/empty.cfg
66
84
  - test/test_patir_base.rb
67
85
  - test/test_patir_command.rb
68
86
  - test/test_patir_configuration.rb
69
- - test/samples/empty.cfg
70
- - docu/style.css
71
- - docu/tie_logo.gif
72
- - docu/welcome.html
73
- - docu/bg_menu.gif
74
- - docu/bg_submenu.gif
75
- - docu/contact.html
76
- - docu/index.html
77
- - docu/patir02.html
78
- - docu/patir03.html
79
- - docu/patir04.html
80
- - docu/patir05.html
81
- - docu/rutema01.html
82
- - docu/rutema02.html
83
- - docu/rutema03.html
84
- - docu/rutema04.html
85
- - docu/rw-intro.png
86
- - docu/rw-run.png
87
- - docu/rw-scenario.png
88
- - docu/screenshots.html
89
- has_rdoc: true
90
- homepage:
87
+ - .gemtest
88
+ homepage: http://patir.rubyforge.org
91
89
  licenses: []
92
90
 
93
91
  post_install_message:
@@ -97,24 +95,30 @@ rdoc_options:
97
95
  require_paths:
98
96
  - lib
99
97
  required_ruby_version: !ruby/object:Gem::Requirement
98
+ none: false
100
99
  requirements:
101
100
  - - ">="
102
101
  - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
103
105
  version: "0"
104
- version:
105
106
  required_rubygems_version: !ruby/object:Gem::Requirement
107
+ none: false
106
108
  requirements:
107
109
  - - ">="
108
110
  - !ruby/object:Gem::Version
111
+ hash: 3
112
+ segments:
113
+ - 0
109
114
  version: "0"
110
- version:
111
115
  requirements: []
112
116
 
113
117
  rubyforge_project: patir
114
- rubygems_version: 1.3.5
118
+ rubygems_version: 1.8.6
115
119
  signing_key:
116
120
  specification_version: 3
117
- summary: patir (Project Automation Tools in Ruby) provides libraries for use in automation tools
121
+ summary: patir (Project Automation Tools in Ruby) provides libraries for use in project automation tools
118
122
  test_files:
119
123
  - test/test_patir_base.rb
120
124
  - test/test_patir_command.rb