From ertai at lrde.epita.fr Sun Jan 1 11:22:30 2006 From: ertai at lrde.epita.fr (Nicolas Pouillard) Date: Sun, 1 Jan 2006 17:22:30 +0100 (CET) Subject: [Uttk-Patches] [core_ex] 446: Extend Inflector::Inflections. Message-ID: <20060101162230.F22966E4C2@smtp1-g19.free.fr> svn://svn.feydakins.org/ruby_ex/trunk/core_ex Index: ChangeLog from Nicolas Pouillard Extend Inflector::Inflections. * lib/core_ex.rb: Extend Inflector::Inflections to deal with custom inflections (e.g. URI -> uri not u_r_i). * lib/core_ex/string.rb: Rename import to import! to match with the others. core_ex.rb | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++- core_ex/string.rb | 4 +-- 2 files changed, 73 insertions(+), 3 deletions(-) Index: lib/core_ex/string.rb --- lib/core_ex/string.rb (revision 445) +++ lib/core_ex/string.rb (working copy) @@ -26,8 +26,8 @@ self end - def import - to_path.import + def import! + to_path.import! end def to_path Index: lib/core_ex.rb --- lib/core_ex.rb (revision 445) +++ lib/core_ex.rb (working copy) @@ -83,8 +83,78 @@ # <<< little active_support patch silence_warnings do module Inflector + class Inflections + # <<< + attr_reader :underscore_rules, :camelize_rules + # >>> + def initialize + # <<< + clear_all + # >>> + end + # <<< + def clear_all + @plurals, @singulars, @uncountables, @underscore_rules, @camelize_rules = [], [], [], [], [] + end + # >>> + def clear ( scope=:all ) + case scope + when :all + # <<< + clear_all + # >>> + else + instance_variable_set "@#{scope}", [] + end + end + def underscore(rule, replacement) + @underscore_rules.unshift [rule, replacement] + end + def camelize(rule, replacement) + @camelize_rules.unshift [rule, replacement] + end + def fixed_case ( camel_cased_word, + lower_case_and_underscored_word=camel_cased_word.downcase ) + camelize(lower_case_and_underscored_word, camel_cased_word) + underscore(camel_cased_word, lower_case_and_underscored_word) + end + def fixed_cases ( *words ) + for word in words + if word.is_a? Array + fixed_case(*word) + else + fixed_case word + end + end + end + end + # Since Inflections is already loaded and is a Singleton we need to initialize + # our variables by hand: + Inflections.instance.instance_eval { @underscore_rules, @camelize_rules = [], [] } + def underscore(camel_cased_word) - camel_cased_word.to_s.gsub(/::/, '/').gsub(/([A-Z])/,'_\1').gsub(/(^|\/)_/, '\1').downcase + # <<< + result = camel_cased_word.to_s.split '::' + result.map! do |word| + inflections.underscore_rules.each { |(rule, replacement)| break if word.gsub!(rule, replacement) } + word.gsub!(/([A-Z])/, '_\1') + word.gsub!(/^_/, '') + word.downcase! + word + end + result.join '/' + # >>> + end + def camelize(lower_case_and_underscored_word) + # <<< + result = lower_case_and_underscored_word.to_s.split '/' + result.map! do |word| + inflections.camelize_rules.each { |(rule, replacement)| break if word.gsub!(rule, replacement) } + word.gsub!(/(^|_)(.)/) { $2.upcase } + word + end + result.join '::' + # >>> end end # module Inflector end -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 186 bytes Desc: OpenPGP digital signature Url : http://rubyforge.org/pipermail/ttk-patches/attachments/20060101/9af04e82/signature.bin -------------- next part -------------- _______________________________________________ Uttk-Patches mailing list Uttk-Patches at lists.feydakins.org http://mailman.feydakins.org/mailman/listinfo/uttk-patches From ertai at lrde.epita.fr Sun Jan 1 11:29:59 2006 From: ertai at lrde.epita.fr (Nicolas Pouillard) Date: Sun, 1 Jan 2006 17:29:59 +0100 (CET) Subject: [Uttk-Patches] [ruby_ex] 447: Fix the URI::* lazy loading. Message-ID: <20060101162959.E62ED4409D@smtp3-g19.free.fr> svn://svn.feydakins.org/ruby_ex/trunk Index: ChangeLog from Nicolas Pouillard Fix the URI::* lazy loading. * lib/uri_ex.rb: Setup some inflection exceptions and add some test. * lib/commands/command.rb: Extend the sleep time to 2 seconds. commands/command.rb | 5 +++-- uri_ex.rb | 38 +++++++++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 5 deletions(-) Index: lib/uri_ex.rb --- lib/uri_ex.rb (revision 446) +++ lib/uri_ex.rb (working copy) @@ -6,6 +6,12 @@ require 'uri' module UriEx + + # Setup exceptions about the camel_case of URI and its classes. + Inflector.inflections do |i| + i.fixed_cases 'URI', 'DRuby', 'FTP', 'HTTP', 'MySQL', 'PgSQL' + end + end # module UriEx module URI @@ -102,16 +108,42 @@ end end + def teardown + URI::Generic.remove_subclasses + end + def test_mk_custom_opts assert_equal([], @foo.mk_custom_opts) assert_equal(%w[-a b -c -d e -f --ghi --jkl mno], @cmplx.mk_custom_opts) end - end # class GenericTest + def test_lazy_loading_one + assert_nothing_raised do + assert_equal 'URI::DRuby', URI::DRuby.name + assert_equal URI::Generic, URI::DRuby.superclass + end + end + + def test_lazy_loading_one2 + assert_equal 'File', ::File.name + assert_nothing_raised do + assert_equal 'URI::File', 'URI::File'.constantize.name + assert_equal URI::Generic, 'URI::File'.constantize.superclass + end end - PathList[__FILE__.to_path.dirname + 'uri/**/*.rb'].each do |path| - require path.to_s + def test_lazy_loading_full + PathList[__FILE__.to_path.dirname + '(uri/**/*).rb'].each do |full, path| + assert_nothing_raised do + class_name = path.to_s.camelize.gsub(/Ex$/, '') + class_object = class_name.constantize + assert_equal class_name, class_object.name + assert_equal URI::Generic, class_object.superclass + end + end + end + + end # class GenericTest end end # module URI Index: lib/commands/command.rb --- lib/commands/command.rb (revision 446) +++ lib/commands/command.rb (working copy) @@ -416,12 +416,13 @@ end def test_fork - cmd = (@touch + @tmp) + (@sleep + 1) + sleep_arg = 2 + cmd = (@touch + @tmp) + (@sleep + sleep_arg) diff = DTime.diff { @data = cmd.fork } assert(@tmp.exist?) @data.waitpid assert(@tmp.exist?) - assert(diff.to_f < 1) + assert(diff.to_f < sleep_arg, "#{diff} should be < #{sleep_arg}") end def test_ruby -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 186 bytes Desc: OpenPGP digital signature Url : http://rubyforge.org/pipermail/ttk-patches/attachments/20060101/ae6123da/signature-0001.bin -------------- next part -------------- _______________________________________________ Uttk-Patches mailing list Uttk-Patches at lists.feydakins.org http://mailman.feydakins.org/mailman/listinfo/uttk-patches From nicolas.despres at gmail.com Mon Jan 2 15:14:10 2006 From: nicolas.despres at gmail.com (=?ISO-8859-1?Q?Nicolas_Despr=E8s?=) Date: Mon, 2 Jan 2006 21:14:10 +0100 Subject: [Uttk-Patches] (backend-refactoring) 771: Introduce Logger::Backend. In-Reply-To: <20051220145702.DEC35B0C05@smtp.feydakins.org> References: <20051220145702.DEC35B0C05@smtp.feydakins.org> Message-ID: <840b875c0601021214w62ec67fncea47fc577212ad5@mail.gmail.com> On 12/20/05, Nicolas Pouillard wrote: > svn://svn.feydakins.org/uttk/branches/without_the_up_notif > > You can also view this changeset here: > > http://http://dev.uttk.org/repository/changesets/771 > > Index: ChangeLog > from Nicolas Pouillard > > Introduce Logger::Backend. > > * lib/uttk/logger/backend.rb: New. A common base class for D::Dumper > and F::Filter. [...] > + # - or even better to avoid the leaf encoding (by ourself), > + # we send the path of the leaf and the leaf: So new_node is useless? I don't understand well this last option. [...] Ok. -- Nicolas Despr?s _______________________________________________ Uttk-Patches mailing list Uttk-Patches at lists.feydakins.org http://mailman.feydakins.org/mailman/listinfo/uttk-patches From nicolas.despres at gmail.com Tue Jan 3 08:07:27 2006 From: nicolas.despres at gmail.com (=?ISO-8859-1?Q?Nicolas_Despr=E8s?=) Date: Tue, 3 Jan 2006 14:07:27 +0100 Subject: [Uttk-Patches] (backend-refactoring) 771: Introduce Logger::Backend. In-Reply-To: References: <20051220145702.DEC35B0C05@smtp.feydakins.org> <840b875c0601021214w62ec67fncea47fc577212ad5@mail.gmail.com> Message-ID: <840b875c0601030507y3cdc998awe002d2c91e84aba8@mail.gmail.com> On 1/2/06, Nicolas Pouillard wrote: > On 1/2/06, Nicolas Despr?s wrote: > > On 12/20/05, Nicolas Pouillard wrote: > > > svn://svn.feydakins.org/uttk/branches/without_the_up_notif > > > > > > You can also view this changeset here: > > > > > > http://http://dev.uttk.org/repository/changesets/771 > > > > > > Index: ChangeLog > > > from Nicolas Pouillard > > > > > > Introduce Logger::Backend. > > > > > > * lib/uttk/logger/backend.rb: New. A common base class for D::Dumper > > > and F::Filter. > > > > [...] > > > > > + # - or even better to avoid the leaf encoding (by ourself), > > > + # we send the path of the leaf and the leaf: > > > > So new_node is useless? > > I don't understand well this last option. > > Yes it's useless if the path is send completly: That's what I thought. So new_node is useless in the implementation. -- Nicolas Despr?s _______________________________________________ Uttk-Patches mailing list Uttk-Patches at lists.feydakins.org http://mailman.feydakins.org/mailman/listinfo/uttk-patches From nicolas.despres at gmail.com Tue Jan 3 18:38:38 2006 From: nicolas.despres at gmail.com (=?ISO-8859-1?Q?Nicolas_Despr=E8s?=) Date: Wed, 4 Jan 2006 00:38:38 +0100 Subject: [Uttk-Patches] (backend-refactoring) 771: Introduce Logger::Backend. In-Reply-To: References: <20051220145702.DEC35B0C05@smtp.feydakins.org> <840b875c0601021214w62ec67fncea47fc577212ad5@mail.gmail.com> <840b875c0601030507y3cdc998awe002d2c91e84aba8@mail.gmail.com> Message-ID: <840b875c0601031538l11621b1ds8fb6c40af517bea1@mail.gmail.com> On 1/3/06, Nicolas Pouillard wrote: > On 1/3/06, Nicolas Despr?s wrote: > > On 1/2/06, Nicolas Pouillard wrote: > > > On 1/2/06, Nicolas Despr?s wrote: > > > > On 12/20/05, Nicolas Pouillard wrote: > > > > > svn://svn.feydakins.org/uttk/branches/without_the_up_notif > > > > > > > > > > You can also view this changeset here: > > > > > > > > > > http://http://dev.uttk.org/repository/changesets/771 > > > > > > > > > > Index: ChangeLog > > > > > from Nicolas Pouillard > > > > > > > > > > Introduce Logger::Backend. > > > > > > > > > > * lib/uttk/logger/backend.rb: New. A common base class for D::Dumper > > > > > and F::Filter. > > > > > > > > [...] > > > > > > > > > + # - or even better to avoid the leaf encoding (by ourself), > > > > > + # we send the path of the leaf and the leaf: > > > > > > > > So new_node is useless? > > > > I don't understand well this last option. > > > > > > Yes it's useless if the path is send completly: > > > > That's what I thought. So new_node is useless in the implementation. > > That depending on the point of view: > > 1/ It's useless to transmit it through the filters, dumpers, network.... > > 2/ In some filter/dumper implementation it's easier to do some task at > the node creation > so this service is still needed. > Which entity is supposed to call new_node? Logger? abstract filters? -- Nicolas Despr?s _______________________________________________ Uttk-Patches mailing list Uttk-Patches at lists.feydakins.org http://mailman.feydakins.org/mailman/listinfo/uttk-patches From nicolas.despres at gmail.com Tue Jan 3 19:47:04 2006 From: nicolas.despres at gmail.com (=?ISO-8859-1?Q?Nicolas_Despr=E8s?=) Date: Wed, 4 Jan 2006 01:47:04 +0100 Subject: [Uttk-Patches] [ruby_ex] 441: Export Concrete from Abstract. In-Reply-To: <20051231155530.BD5278FFB1@smtp.feydakins.org> References: <20051231155530.BD5278FFB1@smtp.feydakins.org> Message-ID: <840b875c0601031647qac7786fo19ad6595665d5ecb@mail.gmail.com> On 12/31/05, Nicolas Pouillard wrote: > svn://svn.feydakins.org/ruby_ex/trunk > > > Index: ChangeLog > from Nicolas Pouillard > > Export Concrete from Abstract. > > * lib/abstract.rb: Export Concrete to make it lazy loadable without > saying Abstract before. > * lib/concrete.rb: New. > Ok, why not. -- Nicolas Despr?s _______________________________________________ Uttk-Patches mailing list Uttk-Patches at lists.feydakins.org http://mailman.feydakins.org/mailman/listinfo/uttk-patches From ertai at lrde.epita.fr Mon Jan 9 03:55:42 2006 From: ertai at lrde.epita.fr (Nicolas Pouillard) Date: Mon, 9 Jan 2006 09:55:42 +0100 (CET) Subject: [Uttk-Patches] [core_ex] 448: Suppress some warnings. Message-ID: <20060109085542.6529D91526@smtp.feydakins.org> svn://svn.feydakins.org/ruby_ex/trunk/core_ex Index: ChangeLog from Nicolas Pouillard Suppress some warnings. * lib/core_ex/lazy_loading.rb: Add an alias. * lib/core_ex.rb: Use $VERBOSE directly since silence_warnings is not yet available. core_ex.rb | 4 ++++ core_ex/lazy_loading.rb | 1 + 2 files changed, 5 insertions(+) Index: lib/core_ex/lazy_loading.rb --- lib/core_ex/lazy_loading.rb (revision 447) +++ lib/core_ex/lazy_loading.rb (working copy) @@ -140,6 +140,7 @@ def name the_standard_name.sub(/^Controllers::/, '') end + alias_method :core_ex_const_missing, :const_missing def const_missing ( aConst ) Binding.of_caller do |binding| nesting = eval "::Module.nesting", binding Index: lib/core_ex.rb --- lib/core_ex.rb (revision 447) +++ lib/core_ex.rb (working copy) @@ -77,8 +77,12 @@ require name end + verbose = $VERBOSE + $VERBOSE = false + core_ex_require 'active_support', 'activesupport', 'activesupport', '~> 1.2.5' + $VERBOSE = verbose # <<< little active_support patch silence_warnings do -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 186 bytes Desc: OpenPGP digital signature Url : http://rubyforge.org/pipermail/ttk-patches/attachments/20060109/8cb54070/signature.bin -------------- next part -------------- _______________________________________________ Uttk-Patches mailing list Uttk-Patches at lists.feydakins.org http://mailman.feydakins.org/mailman/listinfo/uttk-patches From nicolas.despres at gmail.com Mon Jan 9 20:04:47 2006 From: nicolas.despres at gmail.com (=?ISO-8859-1?Q?Nicolas_Despr=E8s?=) Date: Tue, 10 Jan 2006 02:04:47 +0100 Subject: [Uttk-Patches] [ruby_ex] 439: Enforce the double load protection. In-Reply-To: <20051231155047.E79498FFB0@smtp.feydakins.org> References: <20051231155047.E79498FFB0@smtp.feydakins.org> Message-ID: <840b875c0601091704y577187d7g1ebdf2822d6c4985@mail.gmail.com> On 12/31/05, Nicolas Pouillard wrote: > svn://svn.feydakins.org/ruby_ex/trunk > > > Index: ChangeLog > from Nicolas Pouillard > > Enforce the double load protection. > > * lib/ruby_ex.rb: Enforce the double load protection. > * test/unit-suite.yml: Likewise but in a different way. > [...] > > test: > <>: !S::RUnit > - load_path: <>/../lib > - requires: ruby_ex > - input: !path <> > + load_path: [<>/../lib, <>/algorithms] > + requires: <>/../lib/ruby_ex # The full path is here to ensure we > + # load the good one. > + input: !path <> > uttk_unit_options: --uttk no > verbose: true > I don't kown that much about RubyOnRails import system but it seems strange to me to be oblige to "requires" a path which have been already loaded by the "load_path" tag. Am I wrong? -- Nicolas Despr?s _______________________________________________ Uttk-Patches mailing list Uttk-Patches at lists.feydakins.org http://mailman.feydakins.org/mailman/listinfo/uttk-patches