patir 0.7.0 → 0.7.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.
@@ -1,3 +1,7 @@
1
+ ==0.7.2 / 2011-11-29
2
+ * you can now use require in configuration files
3
+ * better handling of paths in configuration files. Relative paths in chained configuration files are now correct
4
+ * more unit tests
1
5
  ==0.7.0 / 2011-08-11
2
6
  * Ruby 1.9 compatibility
3
7
  * updated systemu dependency
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ Hoe.spec('patir') do
15
15
  self.description = paragraphs_of('README.md', 1..4).join("\n\n")
16
16
  self.url = "http://patir.rubyforge.org"
17
17
  self.changes = paragraphs_of('History.txt', 0..1).join("\n\n")
18
- extra_deps<<['systemu',"~>2.2.0"]
18
+ extra_deps<<['systemu',"~>2.3"]
19
19
  end
20
20
 
21
21
  # vim: syntax=Ruby
@@ -6,7 +6,7 @@ module Patir
6
6
  module Version
7
7
  MAJOR=0
8
8
  MINOR=7
9
- TINY=0
9
+ TINY=2
10
10
  STRING=[ MAJOR, MINOR, TINY ].join( "." )
11
11
  end
12
12
  #Error thrown usually in initialize methods when missing required parameters
@@ -37,7 +37,7 @@ module Patir
37
37
  #To use it you would do
38
38
  # cfg=SimpleConfigurator.new("config.cfg").configuration
39
39
  class Configurator
40
- attr_reader :logger,:config_file
40
+ attr_reader :logger,:config_file,:wd
41
41
  def initialize config_file,logger=nil
42
42
  @logger=logger
43
43
  @logger||=Patir.setup_logger
@@ -59,17 +59,19 @@ module Patir
59
59
  #You can 'include' the first.cfg file in the other configurations with
60
60
  # configuration.load_from_file("first.cfg")
61
61
  def load_from_file filename
62
- load_configuration(filename)
62
+ fnm = File.exists?(filename) ? filename : File.join(@wd,filename)
63
+ load_configuration(fnm)
63
64
  end
64
65
  private
65
66
  def load_configuration filename
66
67
  begin
67
- #change into the directory of the configuration file to make requiring easy
68
- prev_dir=Dir.pwd
69
- Dir.chdir(File.dirname(filename))
70
- cfg_txt=File.readlines(File.basename(filename))
68
+ cfg_txt=File.read(filename)
69
+ @wd=File.expand_path(File.dirname(filename))
71
70
  configuration=self
72
- eval(cfg_txt.join(),binding())
71
+ #add the path to the require lookup path to allow require statements in the configuration files
72
+ $:.unshift File.join(@wd)
73
+ #evaluate in the working directory to enable relative paths in configuration
74
+ Dir.chdir(@wd){eval(cfg_txt,binding())}
73
75
  @logger.info("Configuration loaded from #{filename}") if @logger
74
76
  rescue ConfigurationException
75
77
  #pass it on, do not wrap again
@@ -85,9 +87,6 @@ module Patir
85
87
  @logger.debug($!)
86
88
  #Just wrap the exception so we can differentiate
87
89
  raise ConfigurationException.new,"#{$!.message}"
88
- ensure
89
- #ensure we go back to our previous dir
90
- Dir.chdir(prev_dir)
91
90
  end
92
91
  end
93
92
  end
@@ -14,6 +14,15 @@ module Patir
14
14
  def test_configuration
15
15
  c=Patir::Configurator.new("samples/empty.cfg")
16
16
  assert_equal(c.configuration,c)
17
+
18
+ c=Patir::Configurator.new("samples/chain.cfg")
19
+ assert_equal(c.configuration,c)
20
+ end
21
+ def test_raise_configuration
22
+ assert_raise(Patir::ConfigurationException) { Patir::Configurator.new("samples/failed.cfg")}
23
+ assert_raise(Patir::ConfigurationException) { Patir::Configurator.new("samples/failed_unknown.cfg")}
24
+ assert_raise(Patir::ConfigurationException) { Patir::Configurator.new("samples/syntax.cfg")}
25
+ assert_raise(Patir::ConfigurationException) { Patir::Configurator.new("samples/config_fail.cfg")}
17
26
  end
18
27
  end
19
28
  end
metadata CHANGED
@@ -1,77 +1,64 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: patir
3
- version: !ruby/object:Gem::Version
4
- hash: 3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.2
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 7
9
- - 0
10
- version: 0.7.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Vassilis Rizopoulos
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-08-12 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2011-11-29 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: systemu
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2161475600 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
18
+ requirements:
26
19
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 7
29
- segments:
30
- - 2
31
- - 2
32
- - 0
33
- version: 2.2.0
20
+ - !ruby/object:Gem::Version
21
+ version: '2.3'
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
23
+ prerelease: false
24
+ version_requirements: *2161475600
25
+ - !ruby/object:Gem::Dependency
37
26
  name: hoe
27
+ requirement: &2161471140 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '2.12'
33
+ type: :development
38
34
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
35
+ version_requirements: *2161471140
36
+ - !ruby/object:Gem::Dependency
37
+ name: rdoc
38
+ requirement: &2161360540 !ruby/object:Gem::Requirement
40
39
  none: false
41
- requirements:
40
+ requirements:
42
41
  - - ~>
43
- - !ruby/object:Gem::Version
44
- hash: 21
45
- segments:
46
- - 2
47
- - 11
48
- version: "2.11"
42
+ - !ruby/object:Gem::Version
43
+ version: '3.10'
49
44
  type: :development
50
- version_requirements: *id002
51
- description: |-
52
- ##DESCRIPTION:
53
-
54
- patir provides code to enable project automation tasks:
55
-
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.
60
-
61
- ##INSTALL:
62
-
63
- gem install patir
45
+ prerelease: false
46
+ version_requirements: *2161360540
47
+ description: ! "##DESCRIPTION:\n \npatir provides code to enable project automation
48
+ tasks:\n\n * A default logging format for ruby's built-in Logger\n * A command abstraction
49
+ with a platform independent implementation for running shell commands and ruby code\n
50
+ * Command sequences using the same command abstraction as single commands.\n * Code
51
+ that allows the use of configuration files written in ruby.\n\n##INSTALL:\n\n gem
52
+ install patir"
64
53
  email: vassilisrizopoulos@gmail.com
65
54
  executables: []
66
-
67
55
  extensions: []
68
-
69
- extra_rdoc_files:
56
+ extra_rdoc_files:
70
57
  - COPYING.txt
71
58
  - History.txt
72
59
  - Manifest.txt
73
60
  - README.txt
74
- files:
61
+ files:
75
62
  - COPYING.txt
76
63
  - History.txt
77
64
  - Manifest.txt
@@ -87,39 +74,35 @@ files:
87
74
  - .gemtest
88
75
  homepage: http://patir.rubyforge.org
89
76
  licenses: []
90
-
91
77
  post_install_message:
92
- rdoc_options:
78
+ rdoc_options:
93
79
  - --main
94
80
  - README.txt
95
- require_paths:
81
+ require_paths:
96
82
  - lib
97
- required_ruby_version: !ruby/object:Gem::Requirement
83
+ required_ruby_version: !ruby/object:Gem::Requirement
98
84
  none: false
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- hash: 3
103
- segments:
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ segments:
104
90
  - 0
105
- version: "0"
106
- required_rubygems_version: !ruby/object:Gem::Requirement
91
+ hash: 813397894778583248
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
93
  none: false
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- hash: 3
112
- segments:
113
- - 0
114
- version: "0"
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
115
98
  requirements: []
116
-
117
99
  rubyforge_project: patir
118
- rubygems_version: 1.8.6
100
+ rubygems_version: 1.8.8
119
101
  signing_key:
120
102
  specification_version: 3
121
- summary: patir (Project Automation Tools in Ruby) provides libraries for use in project automation tools
122
- test_files:
103
+ summary: patir (Project Automation Tools in Ruby) provides libraries for use in project
104
+ automation tools
105
+ test_files:
123
106
  - test/test_patir_base.rb
124
107
  - test/test_patir_command.rb
125
108
  - test/test_patir_configuration.rb