loquacious 1.4.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ == 1.5.0 / 2010-03-11
2
+
3
+ * 2 minor enhancements
4
+ * Adding support for evaluation of Proc objects
5
+ * Upgrading to the latest Mr Bones
6
+
7
+
1
8
  == 1.4.2 / 2010-02-01
2
9
 
3
10
  * 1 bug fix
data/README.rdoc CHANGED
@@ -212,7 +212,7 @@ they can appear above the attribute and value on their own line.
212
212
 
213
213
  (The MIT License)
214
214
 
215
- Copyright (c) 2009
215
+ Copyright (c) 2009-2010
216
216
 
217
217
  Permission is hereby granted, free of charge, to any person obtaining
218
218
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -5,9 +5,6 @@ rescue LoadError
5
5
  abort '### please install the "bones" gem ###'
6
6
  end
7
7
 
8
- ensure_in_path 'lib'
9
- require 'loquacious'
10
-
11
8
  task :default => 'spec:specdoc'
12
9
  task 'gem:release' => 'spec:run'
13
10
 
@@ -16,7 +13,6 @@ Bones {
16
13
  authors 'Tim Pease'
17
14
  email 'tim.pease@gmail.com'
18
15
  url 'http://gemcutter.org/gems/loquacious'
19
- version Loquacious::VERSION
20
16
  readme_file 'README.rdoc'
21
17
  ignore_file '.gitignore'
22
18
  spec.opts << '--color'
@@ -31,6 +27,6 @@ task 'ann:prereqs' do
31
27
  end
32
28
 
33
29
  # depending on bones (even as a development dependency) creates a circular
34
- # reference that prevents the auto install of little-plugger when instsalling
30
+ # reference that prevents the auto install of loquacious when instsalling
35
31
  # bones
36
32
  ::Bones.config.gem._spec.dependencies.delete_if {|d| d.name == 'bones'}
data/lib/loquacious.rb CHANGED
@@ -2,7 +2,6 @@
2
2
  module Loquacious
3
3
 
4
4
  # :stopdoc:
5
- VERSION = '1.4.2'
6
5
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
7
6
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
8
7
  # :startdoc:
@@ -35,36 +34,40 @@ module Loquacious
35
34
  # Returns the version string for the library.
36
35
  #
37
36
  def version
38
- VERSION
37
+ @version ||= File.read(path('version.txt')).strip
39
38
  end
40
39
 
41
40
  # Returns the library path for the module. If any arguments are given,
42
41
  # they will be joined to the end of the libray path using
43
42
  # <tt>File.join</tt>.
44
43
  #
45
- def libpath( *args )
46
- args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
44
+ def libpath( *args, &block )
45
+ rv = args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
46
+ if block
47
+ begin
48
+ $LOAD_PATH.unshift LIBPATH
49
+ rv = block.call
50
+ ensure
51
+ $LOAD_PATH.shift
52
+ end
53
+ end
54
+ return rv
47
55
  end
48
56
 
49
57
  # Returns the lpath for the module. If any arguments are given, they
50
58
  # will be joined to the end of the path using <tt>File.join</tt>.
51
59
  #
52
- def path( *args )
53
- args.empty? ? PATH : ::File.join(PATH, args.flatten)
54
- end
55
-
56
- # Utility method used to require all files ending in .rb that lie in the
57
- # directory below this file that has the same name as the filename
58
- # passed in. Optionally, a specific _directory_ name can be passed in
59
- # such that the _filename_ does not have to be equivalent to the
60
- # directory.
61
- #
62
- def require_all_libs_relative_to( fname, dir = nil )
63
- dir ||= ::File.basename(fname, '.*')
64
- search_me = ::File.expand_path(
65
- ::File.join(::File.dirname(fname), dir, '**', '*.rb'))
66
-
67
- Dir.glob(search_me).sort.each {|rb| require rb}
60
+ def path( *args, &block )
61
+ rv = args.empty? ? PATH : ::File.join(PATH, args.flatten)
62
+ if block
63
+ begin
64
+ $LOAD_PATH.unshift PATH
65
+ rv = block.call
66
+ ensure
67
+ $LOAD_PATH.shift
68
+ end
69
+ end
70
+ return rv
68
71
  end
69
72
 
70
73
  # This is merely a convenience method to remove methods from the
@@ -91,6 +94,11 @@ module Loquacious
91
94
  end # class << self
92
95
  end # module Loquacious
93
96
 
94
- Loquacious.require_all_libs_relative_to(__FILE__)
97
+ Loquacious.libpath {
98
+ require 'loquacious/core_ext/string'
99
+ require 'loquacious/configuration'
100
+ require 'loquacious/configuration/iterator'
101
+ require 'loquacious/configuration/help'
102
+ }
95
103
 
96
104
  # EOF
@@ -86,18 +86,22 @@ module Loquacious
86
86
  __eigenclass_eval "attr_writer :#{m}"
87
87
  __eigenclass_eval <<-CODE
88
88
  def #{m}( *args, &block )
89
+ if args.empty? and !block
90
+ return @#{m} if @#{m}.kind_of?(Configuration)
91
+ return @#{m}.respond_to?(:call) ? @#{m}.call : @#{m}
92
+ end
93
+
89
94
  v = (1 == args.length ? args.first : args)
90
- v = nil if args.empty?
91
95
  v = DSL.evaluate(&block) if block
92
96
 
93
- return @#{m} unless v or v == false
94
-
95
97
  if @#{m}.kind_of?(Configuration)
96
98
  @#{m}.merge! v
97
99
  else
98
100
  @#{m} = v
99
101
  end
100
- return @#{m}
102
+
103
+ return @#{m} if @#{m}.kind_of?(Configuration)
104
+ return @#{m}.respond_to?(:call) ? @#{m}.call : @#{m}
101
105
  end
102
106
  CODE
103
107
 
@@ -88,6 +88,28 @@ describe Loquacious::Configuration do
88
88
  cfg[:split].should == 'join'
89
89
  cfg[:raise].should == 'double down'
90
90
  cfg[:puts].should == 'not what you think'
91
+
92
+ cfg.fork.should == 'spoon knife spork'
93
+ cfg.split.should == 'join'
94
+ cfg.raise.should == 'double down'
95
+ cfg.puts.should == 'not what you think'
96
+ end
97
+
98
+ it 'should evaluate Proc objects when fetching values' do
99
+ obj = Loquacious::Configuration.new {
100
+ first 'foo'
101
+ second 'bar'
102
+ }
103
+
104
+ obj.third = Proc.new { obj.first + obj.second }
105
+ obj.third.should == 'foobar'
106
+
107
+ obj.second = 'baz'
108
+ obj.third.should == 'foobaz'
109
+
110
+ obj.first = 'Hello '
111
+ obj.second = 'World!'
112
+ obj.third.should == 'Hello World!'
91
113
  end
92
114
 
93
115
  # -----------------------------------------------------------------------
@@ -12,11 +12,11 @@ describe Loquacious do
12
12
 
13
13
  it "finds things releative to 'lib'" do
14
14
  Loquacious.libpath(%w[loquacious config.rb]).should == File.join(@root_dir, %w[lib loquacious config.rb])
15
- end
16
-
15
+ end
16
+
17
17
  it "finds things releative to 'root'" do
18
18
  Loquacious.path('Rakefile').should == File.join(@root_dir, 'Rakefile')
19
- end
19
+ end
20
20
  end
21
21
 
22
22
  # EOF
data/version.txt ADDED
@@ -0,0 +1 @@
1
+ 1.5.0
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loquacious
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 5
8
+ - 0
9
+ version: 1.5.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Tim Pease
@@ -9,19 +14,23 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-01 00:00:00 -07:00
17
+ date: 2010-03-11 00:00:00 -07:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: rspec
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
23
- version: 1.2.9
24
- version:
27
+ segments:
28
+ - 1
29
+ - 3
30
+ - 0
31
+ version: 1.3.0
32
+ type: :development
33
+ version_requirements: *id001
25
34
  description: |-
26
35
  Descriptive configuration files for Ruby written in Ruby.
27
36
 
@@ -74,8 +83,8 @@ extensions: []
74
83
  extra_rdoc_files:
75
84
  - History.txt
76
85
  - README.rdoc
86
+ - version.txt
77
87
  files:
78
- - .gitignore
79
88
  - History.txt
80
89
  - README.rdoc
81
90
  - Rakefile
@@ -94,6 +103,7 @@ files:
94
103
  - spec/spec.opts
95
104
  - spec/spec_helper.rb
96
105
  - spec/string_spec.rb
106
+ - version.txt
97
107
  has_rdoc: true
98
108
  homepage: http://gemcutter.org/gems/loquacious
99
109
  licenses: []
@@ -108,18 +118,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
118
  requirements:
109
119
  - - ">="
110
120
  - !ruby/object:Gem::Version
121
+ segments:
122
+ - 0
111
123
  version: "0"
112
- version:
113
124
  required_rubygems_version: !ruby/object:Gem::Requirement
114
125
  requirements:
115
126
  - - ">="
116
127
  - !ruby/object:Gem::Version
128
+ segments:
129
+ - 0
117
130
  version: "0"
118
- version:
119
131
  requirements: []
120
132
 
121
133
  rubyforge_project: codeforpeople
122
- rubygems_version: 1.3.5
134
+ rubygems_version: 1.3.6
123
135
  signing_key:
124
136
  specification_version: 3
125
137
  summary: Descriptive configuration files for Ruby written in Ruby
data/.gitignore DELETED
@@ -1,16 +0,0 @@
1
- # The list of files that should be ignored by Mr Bones.
2
- # Lines that start with '#' are comments.
3
- #
4
- # A .gitignore file can be used instead by setting it as the ignore
5
- # file in your Rakefile:
6
- #
7
- # PROJ.ignore_file = '.gitignore'
8
- #
9
- # For a project with a C extension, the following would be a good set of
10
- # exclude patterns (uncomment them if you want to use them):
11
- # *.[oa]
12
- # *~
13
- announcement.txt
14
- coverage
15
- doc
16
- pkg