[ditz-talk] [PATCH] small fixes for ruby1.9
Alexander Neumann
alexander at bumpern.de
Wed Dec 2 08:22:03 EST 2009
Hi,
I made some small (but rather ugly) modifications to make ditz work with
ruby1.9, you can also pull this patch from my repository at
git://github.com/fd0/ditz.git, from the branch 'ruby1.9'.
Cheers,
- Alex
[Please CC me, as I'm not subscribed to the mailing list]
---
lib/ditz.rb | 2 +-
lib/ditz/model.rb | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/ditz.rb b/lib/ditz.rb
index 5a5b88a..49e9a5a 100644
--- a/lib/ditz.rb
+++ b/lib/ditz.rb
@@ -68,7 +68,7 @@ end
# Call run_pager from any opperator needing pagination.
# Yoinked from http://nex-3.com/posts/73-git-style-automatic-paging-in-ruby#comments
def run_pager config
- return if PLATFORM =~ /win32/
+ return if RUBY_PLATFORM =~ /win32/
return unless STDOUT.tty?
return if config.paginate == 'never'
diff --git a/lib/ditz/model.rb b/lib/ditz/model.rb
index 763f75c..1d272ed 100644
--- a/lib/ditz/model.rb
+++ b/lib/ditz/model.rb
@@ -1,5 +1,5 @@
require 'yaml'
-require 'sha1'
+require 'digest/sha1'
require "ditz/lowline"; include Lowline
require "ditz/util"
@@ -248,8 +248,8 @@ class ModelObject
@fields.each do |name, field_opts|
val = if opts[:with] && opts[:with][name]
opts[:with][name]
- elsif(found, v = generate_field_value(o, field_opts, generator_args, :interactive => true)) && found
- v
+ elsif(ret = generate_field_value(o, field_opts, generator_args, :interactive => true)) && ret.shift
+ ret.shift
else
q = field_opts[:prompt] || name.to_s.capitalize
if field_opts[:multiline]
@@ -278,8 +278,8 @@ class ModelObject
@fields.each do |fname, fopts|
val = if(x = vals[fname] || vals[fname.to_s])
x
- elsif(found, x = generate_field_value(o, fopts, generator_args, :interactive => false)) && found
- x
+ elsif(ret = generate_field_value(o, fopts, generator_args, :interactive => false)) && ret.shift
+ ret.shift
elsif !fopts[:nil_ok]
raise ModelError, "missing required field #{fname.inspect} on #{self.name} object (got #{vals.keys.inspect})"
end
--
1.6.3.3
More information about the ditz-talk
mailing list