From cb366cdc30fdab3d5cb06d4ed493afa3d45a8efa Mon Sep 17 00:00:00 2001 From: Pistos Date: Mon, 29 Dec 2008 22:56:36 -0500 Subject: [PATCH 01/11] Some English adjustments in README. --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 65eda9f6..8da60ac5 100644 --- a/README.md +++ b/README.md @@ -123,17 +123,18 @@ Innate follows a different approach than most frameworks, making the controller subclassing obsolete. To make an object accessible from the outside simply include Innate::Node and map it to the location you would like. -## Differences to Ramaze +## Differences from Ramaze -Innate throws a lot over board that makes Ramaze a very good option for large -apps and doesn't provide all the bells and whistles that you may be used to. +Innate throws a lot overboard; it doesn't provide all the bells and whistles +that you may be used to. This makes Ramaze a very good option for larger +applications. -This is the reason why Innate won't only be a standalone framework but also the +This is the reason why Innate won't be a standalone framework, but rather the new core for Ramaze. Ramaze started out without any of the benefits that Rack gives us these days, -especially regarding the server handlers, request/response, and the various -middlewares. +especially regarding the server handlers, request/response, and middleware. + Still it tried to provide everything one might need with the least effort, leading to a lot of inlining of dependencies (we have things like bacon, simple_http, gettext, mime types, ...) @@ -406,7 +407,7 @@ all. Some things are better suited as middleware, I will move them to rack-contrib ASAP: * gzip_filter -* profiling +* profiling Then there's things that don't see much use, they should stay in the future ramaze contrib or face removal: From 6af3a12570c5931f71da5d9c972640231421f3cf Mon Sep 17 00:00:00 2001 From: Pistos Date: Mon, 29 Dec 2008 22:58:32 -0500 Subject: [PATCH 02/11] One small change in choice of words. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8da60ac5..13968940 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ Ramaze started out without any of the benefits that Rack gives us these days, especially regarding the server handlers, request/response, and middleware. Still it tried to provide everything one might need with the least effort, -leading to a lot of inlining of dependencies (we have things like bacon, +leading to a lot of incorporation of dependencies (we have things like bacon, simple_http, gettext, mime types, ...) ### Configuration From 1ff544c51b5457511ec93f0dac0322dc1358b31b Mon Sep 17 00:00:00 2001 From: Pistos Date: Mon, 29 Dec 2008 23:02:41 -0500 Subject: [PATCH 03/11] Corrected wrong statement about Innate. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 13968940..f9b6c50c 100644 --- a/README.md +++ b/README.md @@ -129,8 +129,8 @@ Innate throws a lot overboard; it doesn't provide all the bells and whistles that you may be used to. This makes Ramaze a very good option for larger applications. -This is the reason why Innate won't be a standalone framework, but rather the -new core for Ramaze. +For this reason, Innate won't just be a standalone framework, but will also +become the new core for Ramaze. Ramaze started out without any of the benefits that Rack gives us these days, especially regarding the server handlers, request/response, and middleware. From 3f30ea1bb25c1726c792d7dcfe34fcd8aea1d011 Mon Sep 17 00:00:00 2001 From: Pistos Date: Tue, 30 Dec 2008 09:20:10 -0500 Subject: [PATCH 04/11] A few minor English adjustments in README. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f9b6c50c..07374971 100644 --- a/README.md +++ b/README.md @@ -153,8 +153,8 @@ difficult. With Innate I hope to tackle this problem, it's currently not as fast as Ramaze::Global, but offers namespaces and inheritance. -Where Ramaze::Global still excels, CLI arguments, documentation and annotation -for options, will soon be integrated as well. +The areas wherein Ramaze::Global excels (CLI arguments, documentation and +annotation for options) will soon be integrated as well. Configuration namespaces will offer a nice way to merge different applications and reconcile their options in a unified manner, opening the way for slice-like @@ -228,7 +228,7 @@ Innate/Ramaze. It won't have all the capabilities one might be used to out of the box, but extending them is easy. -What provides means is that every Action has different ways of being rendered, +Having "provides" means that every Action has different ways of being rendered, depending on so-called wishes. A wish may be anything related to the request object, and by default it will From 43719e0564438af54cc5e3b96d61f9ff2ffae8ba Mon Sep 17 00:00:00 2001 From: Pistos Date: Tue, 30 Dec 2008 20:21:19 -0500 Subject: [PATCH 05/11] Numerous minor English corrections and adjustments. --- README.md | 104 +++++++++++++++++++++++++++--------------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 07374971..faf605d1 100644 --- a/README.md +++ b/README.md @@ -270,23 +270,21 @@ are not included in Innate itself in terms of globs: * dispatcher.rb * dispatcher/*.rb -There might be a couple of things i've forgotten, but that's what a quick +There might be a couple of things I've forgotten, but that's what a quick glance tells me. -Let's go through them one by one and decide what's gonna happen to them: +Let's go through them one by one and consider what's gonna happen to them: ### Cache Caching is a very important concern and one of the most difficult things to get -right for any web application. -Ramaze tried to get caching done right and I consider it fairly successful when -it comes to that. -There are a myriad of options available for caching, different caching -mechanisms such as marshal to filesystem, memcached, in-memory, yaml to -filesystem, etc. -The granularity can be chosen depending on the usecase, distributed caching of -sessions, actions, single key/value pairs, and so on, fine-tuning each of those -to use a different mechanism is done as painless as possible. +right for any web application. Ramaze tried to get caching done right and I +consider it fairly successful when it comes to that. There are a myriad of +options available for caching, different caching mechanisms such as marshal to +filesystem, memcached, in-memory, yaml to filesystem, etc. The granularity can +be chosen depending on the use case, distributed caching of sessions, actions, +single key/value pairs, and so on. Fine-tuning each of those to use a different +mechanism will be made as painless as possible. We have gone through a lot of difficulties, memory-leaks, disputes, and challenges to get this done, but most users won't realize this until they @@ -332,18 +330,17 @@ This will be removed from both Ramaze and Innate. ##### Ramaze::Record Well, this might be the most obvious candidate for removal, maybe it can be -revived as a middleware. -The functionality itself is in the adapter and even that's only a few lines. -But so far I have never seen any usage for it. +revived as middleware. The functionality itself is in the adapter and even +that's only a few lines. But so far I have never seen any usage for it. ##### Tool::Localize I and a lot of other people have used this over time and it has proven itself to be a very easy and straight-forward way of doing localization. -It think it is better suited as a middleware which can be included into -rack-contrib -and doesn't rely on the normal session but a simple unobfuscated cookie. +It think it is better suited as middleware which can be included into +rack-contrib and doesn't rely on the normal session but a simple unobfuscated +cookie. ##### Tool::MIME @@ -354,17 +351,18 @@ This one will be removed, Rack::Mime is a viable alternative. Over the years, Ramaze has collected a wide variety of spec helpers that are not really compatible to each other and rely on real request/response with a running server. + Innate provides a better alternative via Innate::Mock for its own specs, applications will need the power of a real scraping library and we will provide a canonical way of running a server in the background before running the specs. There will not be any other helpers in Innate, but Ramaze might provide a few standard ones to get up and running (hpricot, rexml). -Regarding the spec output parsers, that's a different issue. -Providing readable output while running specs is a major feature that must be -included in order to keep frustration low. -We will provide a suitable logger replacement so one can simply extend Bacon -with that in order to get nice summaries and good error output. +Regarding the spec output parsers, that's a different issue. Providing +readable output while running specs is a major feature that must be included in +order to keep frustration low. We will provide a suitable logger replacement +so one can simply extend Bacon with that in order to get nice summaries and +good error output. ### Snippets @@ -373,9 +371,11 @@ provide those. Over the years there have been lots of libraries that all provide their own core extensions and interference is a major issue. Innate will keep everything as clean as possible, doing subclasses inside the Innate namespace where it needs to change things. + Two things that we need are (currently) String#each, because Rack relies on it, and BasicObject as superclass for the Option class. They are only applied on demand. + These are in the directory called core_extensions, to make it very, very clear what we are doing and how we are doing it. @@ -385,10 +385,9 @@ constantly strive to reduce them slowly. ### Gestalt Gestalt has been the first "templating_engine" for Ramaze and is still used in -some fractions of the code and various applications. There are a lot of other +some fractions of the code and various applications. There are a lot of other html/xml builders out there these days so I think this is no good choice for -inclusion into Innate. -I will keep it inside Ramaze. +inclusion into Innate. I will keep it inside Ramaze. ### Ramaze::Store::Default @@ -396,21 +395,22 @@ I will remove this class from both Innate and Ramaze. It started out as a simple wrapper for YAML::Store to make the tutorial easier, but I think it gives a wrong impression of being anything else. -It's very slow, might raise under heavy load and a plain YAML::Store or PStore -or any other persistence mechanism is generally a better choice, no need to -keep this around. +It's very slow, might raise exceptions under heavy load and a plain YAML::Store +or PStore or any other persistence mechanism is generally a better choice, so +there is no need to keep this around. ### Contrib There's a lot in there, and some of these things are used widely, others not at -all. -Some things are better suited as middleware, I will move them to rack-contrib -ASAP: +all. Some things are better suited as middleware, I will move them to +rack-contrib ASAP: + * gzip_filter * profiling -Then there's things that don't see much use, they should stay in the future -ramaze contrib or face removal: +Then there's things that don't see much use. They should stay in the future +Ramaze contrib or face removal: + * facebook * gettext * maruku_uv @@ -418,17 +418,18 @@ ramaze contrib or face removal: * rest And other things that should be moved into Ramaze proper: + * email * file_cache (done) * gems -Neither of them will be added to Innate +None of these will be included in Innate. ### Adapters These are entirely the responsibility of Rack/Innate now, Ramaze doesn't need -to worry about that. -WEBrick will stay default adapter since it is in stdlib. +to worry about that. WEBrick will remain the default adapter since it is in +the Ruby stdlib. ### Templating @@ -436,32 +437,31 @@ Templating will also be handled by Innate for the most part. #### Ezamar -I have plans to make Ezamar a separate project. -It's been stable since over a year and I think it's time to make it available -for other projects. -ERB will be the new default engine since it also is in stdlib. +I have plans to make Ezamar a separate project. It's been stable since over a +year and I think it's time to make it available for other projects. ERB will +be the new default engine since it also is in the stdlib. ### Bacon -Bacon will be a dependency for ramaze and innate specs, but we will not ship it +Bacon will be a dependency for Ramaze and Innate specs, but we will not ship it anymore, it's stable and has all features we need included in the release. ### Dispatcher -Innate uses a stripped down version of the Ramaze dispatcher. -The Ramaze dispatcher was strongly influenced by Nitro, but proved to be a -difficult part. We are now using Racks URLMap directly, and have a minimal -dispatching mechanism directly in Node (like we used to have one in -Controller). +Innate uses a stripped down version of the Ramaze dispatcher. The Ramaze +dispatcher was strongly influenced by Nitro, but proved to be a difficult +part. We are now using Rack's URLMap directly, and have a minimal dispatching +mechanism directly in Node (like we used to have one in Controller). A lot of the functionality that used to be in the different dispatchers is now -provided by rack middleware. +provided by Rack middleware. -The Dispatcher itself isn't needed anymore, it used to setup +The Dispatcher itself isn't needed anymore. It used to setup Request/Response/Session, which was superseded by Current, this again is now superseded by STATE::wrap. + We are going to remove all the other dispatchers as well, providing default -ways and middleware to use. +ways to provide the same functionality, and various middleware to use. #### Dispatcher::Action @@ -470,13 +470,13 @@ not needed anymore. #### Dispatcher::Directory -Will also be removed, there is a directory listing middleware already +This will also be removed. There is a directory listing middleware already. #### Dispatcher::Error There's middleware for this as well, and a canonical way of routing errors to -other actions, this used to be one of the most difficut parts of Ramaze and it -will be removed to make things simpler. +other actions. This used to be one of the most difficult parts of Ramaze and +it will be removed to make things simpler. #### Dispatcher::File From 2fa56f1d85d32c1b3ea3be10a91cff068275c6aa Mon Sep 17 00:00:00 2001 From: Pistos Date: Tue, 5 May 2009 09:43:51 -0400 Subject: [PATCH 06/11] Adjusted Innate::Options#pretty_print spec to work across more systems and conditions, yet still test something non-trivial. --- spec/innate/options.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spec/innate/options.rb b/spec/innate/options.rb index e08b0150..cf6d07f4 100644 --- a/spec/innate/options.rb +++ b/spec/innate/options.rb @@ -102,7 +102,16 @@ require 'pp' p = PP.new @options.pretty_print(p) - p.output.should =~ /:value=>:mom/ + lines = p.output.split(/\n/) + lines.find{|l| + /:doc/ === l && + /:value/ === l && + /:cli/ === l + }.should.not.be.nil + lines.find_all{|l| + /:doc/ === l && + /:value/ === l + }.size.should.equal 4 end should 'trigger block when option is changed' do From d82d68606fdf08d55a8234826f4897040e8256d5 Mon Sep 17 00:00:00 2001 From: Pistos Date: Wed, 6 May 2009 11:42:03 -0400 Subject: [PATCH 07/11] Adjusted pretty_print spec again. Made it looser, since we don't really care much about it because it doesn't significantly affect Ramaze functionality. --- spec/innate/options.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/spec/innate/options.rb b/spec/innate/options.rb index 3c250524..1990e579 100644 --- a/spec/innate/options.rb +++ b/spec/innate/options.rb @@ -107,15 +107,10 @@ p = PP.new @options.pretty_print(p) lines = p.output.split(/\n/) - lines.find{|l| - /:doc/ === l && - /:value/ === l && - /:cli/ === l - }.should.not.be.nil lines.find_all{|l| /:doc/ === l && /:value/ === l - }.size.should.equal 4 + }.size.should > 3 end should 'trigger block when option is changed' do From 484f133d02073ff6e64fc07390236bae8e56f690 Mon Sep 17 00:00:00 2001 From: Pistos Date: Thu, 13 Mar 2025 19:01:24 -0500 Subject: [PATCH 08/11] Fix some compatibility with Ruby 3 and newer gem versions --- example/app/retro_games.rb | 2 +- innate.gemspec | 11 +++++++---- lib/innate/action.rb | 8 +++++++- lib/innate/cache/file_based.rb | 5 ++++- lib/innate/cache/yaml.rb | 4 ++-- lib/innate/helper/aspect.rb | 2 ++ lib/innate/node.rb | 2 ++ lib/innate/request.rb | 4 ++-- spec/example/app/retro_games.rb | 2 +- spec/innate/helper.rb | 2 +- spec/innate/options.rb | 4 ++-- spec/innate/route.rb | 6 +++--- 12 files changed, 34 insertions(+), 18 deletions(-) diff --git a/example/app/retro_games.rb b/example/app/retro_games.rb index ef01883a..b0d9f5da 100644 --- a/example/app/retro_games.rb +++ b/example/app/retro_games.rb @@ -19,7 +19,7 @@ def index end def create - STORE[request[:name]] ||= 0 if request.post? + STORE[request['name']] ||= 0 if request.post? redirect_referrer end diff --git a/innate.gemspec b/innate.gemspec index 665b46dd..2edf57ab 100644 --- a/innate.gemspec +++ b/innate.gemspec @@ -1,14 +1,14 @@ # -*- encoding: utf-8 -*- -# stub: innate 2023.01.06 ruby lib +# stub: innate 2025.03.13 ruby lib Gem::Specification.new do |s| s.name = "innate".freeze - s.version = "2023.01.06" + s.version = "2025.03.13" s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= s.require_paths = ["lib".freeze] s.authors = ["Michael 'manveru' Fellinger".freeze] - s.date = "2023-01-06" + s.date = "2025-03-13" s.description = "Simple, straight-forward base for web-frameworks.".freeze s.email = "m.fellinger@gmail.com".freeze s.files = [".gems".freeze, ".gitignore".freeze, ".load_gemset".freeze, ".rvmrc".freeze, ".travis.yml".freeze, "AUTHORS".freeze, "CHANGELOG".freeze, "COPYING".freeze, "MANIFEST".freeze, "README.md".freeze, "Rakefile".freeze, "example/app/retro_games.rb".freeze, "example/app/todo/layout/default.xhtml".freeze, "example/app/todo/spec/todo.rb".freeze, "example/app/todo/start.rb".freeze, "example/app/todo/view/index.xhtml".freeze, "example/app/whywiki_erb/layout/wiki.html.erb".freeze, "example/app/whywiki_erb/spec/wiki.rb".freeze, "example/app/whywiki_erb/start.rb".freeze, "example/app/whywiki_erb/view/edit.erb".freeze, "example/app/whywiki_erb/view/index.erb".freeze, "example/custom_middleware.rb".freeze, "example/hello.rb".freeze, "example/howto_spec.rb".freeze, "example/link.rb".freeze, "example/provides.rb".freeze, "example/session.rb".freeze, "innate.gemspec".freeze, "lib/innate.rb".freeze, "lib/innate/action.rb".freeze, "lib/innate/adapter.rb".freeze, "lib/innate/cache.rb".freeze, "lib/innate/cache/api.rb".freeze, "lib/innate/cache/drb.rb".freeze, "lib/innate/cache/file_based.rb".freeze, "lib/innate/cache/marshal.rb".freeze, "lib/innate/cache/memory.rb".freeze, "lib/innate/cache/yaml.rb".freeze, "lib/innate/current.rb".freeze, "lib/innate/default_middleware.rb".freeze, "lib/innate/dynamap.rb".freeze, "lib/innate/helper.rb".freeze, "lib/innate/helper/aspect.rb".freeze, "lib/innate/helper/cgi.rb".freeze, "lib/innate/helper/flash.rb".freeze, "lib/innate/helper/link.rb".freeze, "lib/innate/helper/redirect.rb".freeze, "lib/innate/helper/render.rb".freeze, "lib/innate/log.rb".freeze, "lib/innate/log/color_formatter.rb".freeze, "lib/innate/log/hub.rb".freeze, "lib/innate/lru_hash.rb".freeze, "lib/innate/mock.rb".freeze, "lib/innate/node.rb".freeze, "lib/innate/options.rb".freeze, "lib/innate/options/dsl.rb".freeze, "lib/innate/options/stub.rb".freeze, "lib/innate/request.rb".freeze, "lib/innate/response.rb".freeze, "lib/innate/route.rb".freeze, "lib/innate/session.rb".freeze, "lib/innate/session/flash.rb".freeze, "lib/innate/spec.rb".freeze, "lib/innate/spec/bacon.rb".freeze, "lib/innate/state.rb".freeze, "lib/innate/state/accessor.rb".freeze, "lib/innate/traited.rb".freeze, "lib/innate/trinity.rb".freeze, "lib/innate/version.rb".freeze, "lib/innate/view.rb".freeze, "lib/innate/view/erb.rb".freeze, "lib/innate/view/etanni.rb".freeze, "lib/innate/view/none.rb".freeze, "spec/example/app/retro_games.rb".freeze, "spec/example/hello.rb".freeze, "spec/example/link.rb".freeze, "spec/example/provides.rb".freeze, "spec/example/session.rb".freeze, "spec/helper.rb".freeze, "spec/innate/action/layout.rb".freeze, "spec/innate/action/layout/file_layout.xhtml".freeze, "spec/innate/cache/common.rb".freeze, "spec/innate/cache/marshal.rb".freeze, "spec/innate/cache/memory.rb".freeze, "spec/innate/cache/yaml.rb".freeze, "spec/innate/dynamap.rb".freeze, "spec/innate/etanni.rb".freeze, "spec/innate/helper.rb".freeze, "spec/innate/helper/aspect.rb".freeze, "spec/innate/helper/cgi.rb".freeze, "spec/innate/helper/flash.rb".freeze, "spec/innate/helper/link.rb".freeze, "spec/innate/helper/redirect.rb".freeze, "spec/innate/helper/render.rb".freeze, "spec/innate/helper/view/aspect_hello.xhtml".freeze, "spec/innate/helper/view/locals.xhtml".freeze, "spec/innate/helper/view/loop.xhtml".freeze, "spec/innate/helper/view/num.xhtml".freeze, "spec/innate/helper/view/partial.xhtml".freeze, "spec/innate/helper/view/recursive.xhtml".freeze, "spec/innate/mock.rb".freeze, "spec/innate/modes.rb".freeze, "spec/innate/node/mapping.rb".freeze, "spec/innate/node/node.rb".freeze, "spec/innate/node/resolve.rb".freeze, "spec/innate/node/view/another_layout/another_layout.xhtml".freeze, "spec/innate/node/view/bar.xhtml".freeze, "spec/innate/node/view/cat2/cat22.xhtml".freeze, "spec/innate/node/view/cat3/cat33.xhtml".freeze, "spec/innate/node/view/foo.html.xhtml".freeze, "spec/innate/node/view/only_view.xhtml".freeze, "spec/innate/node/view/sub/baz.xhtml".freeze, "spec/innate/node/view/sub/foo/baz.xhtml".freeze, "spec/innate/node/view/with_layout.xhtml".freeze, "spec/innate/node/wrap_action_call.rb".freeze, "spec/innate/options.rb".freeze, "spec/innate/parameter.rb".freeze, "spec/innate/provides.rb".freeze, "spec/innate/provides/list.html.xhtml".freeze, "spec/innate/provides/list.txt.xhtml".freeze, "spec/innate/request.rb".freeze, "spec/innate/response.rb".freeze, "spec/innate/route.rb".freeze, "spec/innate/session.rb".freeze, "spec/innate/traited.rb".freeze, "tasks/authors.rake".freeze, "tasks/bacon.rake".freeze, "tasks/changelog.rake".freeze, "tasks/gem.rake".freeze, "tasks/gem_setup.rake".freeze, "tasks/grancher.rake".freeze, "tasks/manifest.rake".freeze, "tasks/rcov.rake".freeze, "tasks/release.rake".freeze, "tasks/reversion.rake".freeze, "tasks/setup.rake".freeze, "tasks/ycov.rake".freeze] @@ -25,8 +25,11 @@ Gem::Specification.new do |s| s.add_development_dependency(%q.freeze, ["~> 1.2.0"]) s.add_development_dependency(%q.freeze, ["~> 0.6.3"]) else - s.add_dependency(%q.freeze, ["~> 3.0"]) s.add_dependency(%q.freeze, ["~> 1.2.0"]) + s.add_dependency(%q.freeze, ["~> 3.0"]) s.add_dependency(%q.freeze, ["~> 0.6.3"]) + s.add_dependency(%q.freeze, ["~> 2.2.1"]) + s.add_dependency(%q.freeze, ["~> 1.0.0"]) + s.add_dependency(%q.freeze, ["~> 1.0.0"]) end end diff --git a/lib/innate/action.rb b/lib/innate/action.rb index 75a2797a..085cdb98 100644 --- a/lib/innate/action.rb +++ b/lib/innate/action.rb @@ -92,7 +92,13 @@ def render end def wrap_in_layout - layout ? dup.render_in_layout(&Proc.new) : yield + if layout + dup.render_in_layout( + &Proc.new { yield } + ) + else + yield + end end def render_in_layout diff --git a/lib/innate/cache/file_based.rb b/lib/innate/cache/file_based.rb index 1604bc39..d272cc16 100644 --- a/lib/innate/cache/file_based.rb +++ b/lib/innate/cache/file_based.rb @@ -15,7 +15,10 @@ def cache_setup(*args) FileUtils.mkdir_p(@dir) @filename = File.join(@dir, @prefix + self.class::EXT) - @store = self.class::STORE.new(@filename) + @store = self.class::STORE.new( + @filename, + other_permitted_classes: [Time] + ) end def cache_clear diff --git a/lib/innate/cache/yaml.rb b/lib/innate/cache/yaml.rb index d74ff5e2..0f6ba4e5 100644 --- a/lib/innate/cache/yaml.rb +++ b/lib/innate/cache/yaml.rb @@ -1,4 +1,4 @@ -require 'yaml/store' +require 'innate/yaml/store' module Innate class Cache @@ -12,7 +12,7 @@ class YAML include Cache::API include Cache::FileBased - STORE = ::YAML::Store + STORE = Innate::YAML::Store DIR = 'innate-cache-yaml' EXT = '.yaml' end diff --git a/lib/innate/helper/aspect.rb b/lib/innate/helper/aspect.rb index 41f03abc..92d40187 100644 --- a/lib/innate/helper/aspect.rb +++ b/lib/innate/helper/aspect.rb @@ -1,3 +1,5 @@ +require 'sorted_set' + module Innate module Helper ## diff --git a/lib/innate/node.rb b/lib/innate/node.rb index 185797f1..062febe4 100644 --- a/lib/innate/node.rb +++ b/lib/innate/node.rb @@ -1,3 +1,5 @@ +require 'sorted_set' + module Innate # The nervous system of {Innate}, so you can relax. diff --git a/lib/innate/request.rb b/lib/innate/request.rb index eac89fa1..fa127a37 100644 --- a/lib/innate/request.rb +++ b/lib/innate/request.rb @@ -70,8 +70,8 @@ def self.current # # Both +value+ and the elements of +keys+ will be turned into String by #to_s. def [](value, *keys) - return super(value) if keys.empty? - [value, *keys].map{|key| super(key) } + return params[value] if keys.empty? + [value, *keys].map{|key| params[key] } end # the full request URI provided by Rack::Request diff --git a/spec/example/app/retro_games.rb b/spec/example/app/retro_games.rb index 4499e0e5..90546494 100644 --- a/spec/example/app/retro_games.rb +++ b/spec/example/app/retro_games.rb @@ -15,7 +15,7 @@ end it 'allows you to add another game' do - response = post('/create', :name => 'Street Fighter II') + response = post('/create', 'name' => 'Street Fighter II') response.status.should == 302 follow_redirect! diff --git a/spec/innate/helper.rb b/spec/innate/helper.rb index f26ff2fc..f11a9196 100644 --- a/spec/innate/helper.rb +++ b/spec/innate/helper.rb @@ -66,7 +66,7 @@ class FooNodeLink should 'construct link from ::a' do FNL.a(:index).should == 'index' FNL.a('index', :index, :x => :y).should == 'index' - FNL.a('duh/bar', 'duh/bar', :x => :y).should == "duh/bar" + FNL.a('duh/bar', 'duh/bar', :x => :y).should == "duh/bar" FNL.a('foo', :/, :x => :y).should == 'foo' end diff --git a/spec/innate/options.rb b/spec/innate/options.rb index 9bc5b425..f1db30fa 100644 --- a/spec/innate/options.rb +++ b/spec/innate/options.rb @@ -106,8 +106,8 @@ require 'pp' lines = @options.pretty_inspect.split(/\n/) lines.find_all{|l| - /:doc/ === l && - /:value/ === l + /doc:/ === l && + /value:/ === l }.size.should > 3 end diff --git a/spec/innate/route.rb b/spec/innate/route.rb index b625cc85..d86ced98 100644 --- a/spec/innate/route.rb +++ b/spec/innate/route.rb @@ -40,15 +40,15 @@ def check(uri, status, body = nil) Route['string'].class.should == Proc Route['calc sum'] = lambda{|path, req| - if req[:do_calc] - lval, rval = req[:a, :b] + if req['do_calc'] + lval, rval = req['a', 'b'] rval = rval.to_i * 10 "/sum/#{lval}/#{rval}" end } Innate::Route('foo') do |path, req| - '/bar' if req[:bar] + '/bar' if req['bar'] end end From d1d179bb12bb8ee66598f2b1007653d6baeafc53 Mon Sep 17 00:00:00 2001 From: Pistos Date: Thu, 13 Mar 2025 19:28:03 -0500 Subject: [PATCH 09/11] Add Innate::YAML::Store needed by previous commit (oops) --- lib/innate/yaml/store.rb | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 lib/innate/yaml/store.rb diff --git a/lib/innate/yaml/store.rb b/lib/innate/yaml/store.rb new file mode 100644 index 00000000..9054621c --- /dev/null +++ b/lib/innate/yaml/store.rb @@ -0,0 +1,41 @@ +require 'yaml/store' + +module Innate + module YAML + # Just to allow some permitted_classes, because this list of classes + # is hard-coded in stdlib ::YAML::Store + class Store < ::YAML::Store + def initialize(*o) + @permitted_classes = [Symbol] # Default in stdlib + + if o.last.is_a? Hash + @permitted_classes += Array(o.last[:other_permitted_classes]) + end + + super(*o) + end + + # Based on Ruby 3.4.2 lib/ruby/3.4.0/yaml/store.rb + def load(content) + table = if ::YAML.respond_to?(:safe_load) + if Psych::VERSION >= "3.1" + ::YAML.safe_load(content, permitted_classes: @permitted_classes) + else + ::YAML.safe_load(content, @permitted_classes) + end + else + if other_permitted_classes.empty? + ::YAML.load(content) + else + raise ArgumentError.new("::YAML module does not support permitted_classes") + end + end + if table == false || table == nil + {} + else + table + end + end + end + end +end From c70fc89f3770bd13465fb2d25668dc8d60c1eddb Mon Sep 17 00:00:00 2001 From: Pistos Date: Thu, 13 Mar 2025 19:35:34 -0500 Subject: [PATCH 10/11] Fix some logic problems --- lib/innate/yaml/store.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/innate/yaml/store.rb b/lib/innate/yaml/store.rb index 9054621c..2f09eabd 100644 --- a/lib/innate/yaml/store.rb +++ b/lib/innate/yaml/store.rb @@ -7,9 +7,16 @@ module YAML class Store < ::YAML::Store def initialize(*o) @permitted_classes = [Symbol] # Default in stdlib + @use_permitted_classes = ::YAML.respond_to?(:safe_load) if o.last.is_a? Hash - @permitted_classes += Array(o.last[:other_permitted_classes]) + other_permitted_classes = Array(o.last[:other_permitted_classes]) + + if ! @use_permitted_classes && other_permitted_classes.any? + raise ArgumentError.new("::YAML module does not support permitted_classes") + else + @permitted_classes += other_permitted_classes + end end super(*o) @@ -17,19 +24,16 @@ def initialize(*o) # Based on Ruby 3.4.2 lib/ruby/3.4.0/yaml/store.rb def load(content) - table = if ::YAML.respond_to?(:safe_load) + table = if @use_permitted_classes if Psych::VERSION >= "3.1" ::YAML.safe_load(content, permitted_classes: @permitted_classes) else ::YAML.safe_load(content, @permitted_classes) end else - if other_permitted_classes.empty? - ::YAML.load(content) - else - raise ArgumentError.new("::YAML module does not support permitted_classes") - end + ::YAML.load(content) end + if table == false || table == nil {} else From e1a482132f5cccde18c0e468073e2feaffd36be4 Mon Sep 17 00:00:00 2001 From: Pistos Date: Thu, 13 Mar 2025 19:55:14 -0500 Subject: [PATCH 11/11] Set gem dependencies properly --- innate.gemspec | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/innate.gemspec b/innate.gemspec index 2edf57ab..113824fe 100644 --- a/innate.gemspec +++ b/innate.gemspec @@ -13,6 +13,8 @@ Gem::Specification.new do |s| s.email = "m.fellinger@gmail.com".freeze s.files = [".gems".freeze, ".gitignore".freeze, ".load_gemset".freeze, ".rvmrc".freeze, ".travis.yml".freeze, "AUTHORS".freeze, "CHANGELOG".freeze, "COPYING".freeze, "MANIFEST".freeze, "README.md".freeze, "Rakefile".freeze, "example/app/retro_games.rb".freeze, "example/app/todo/layout/default.xhtml".freeze, "example/app/todo/spec/todo.rb".freeze, "example/app/todo/start.rb".freeze, "example/app/todo/view/index.xhtml".freeze, "example/app/whywiki_erb/layout/wiki.html.erb".freeze, "example/app/whywiki_erb/spec/wiki.rb".freeze, "example/app/whywiki_erb/start.rb".freeze, "example/app/whywiki_erb/view/edit.erb".freeze, "example/app/whywiki_erb/view/index.erb".freeze, "example/custom_middleware.rb".freeze, "example/hello.rb".freeze, "example/howto_spec.rb".freeze, "example/link.rb".freeze, "example/provides.rb".freeze, "example/session.rb".freeze, "innate.gemspec".freeze, "lib/innate.rb".freeze, "lib/innate/action.rb".freeze, "lib/innate/adapter.rb".freeze, "lib/innate/cache.rb".freeze, "lib/innate/cache/api.rb".freeze, "lib/innate/cache/drb.rb".freeze, "lib/innate/cache/file_based.rb".freeze, "lib/innate/cache/marshal.rb".freeze, "lib/innate/cache/memory.rb".freeze, "lib/innate/cache/yaml.rb".freeze, "lib/innate/current.rb".freeze, "lib/innate/default_middleware.rb".freeze, "lib/innate/dynamap.rb".freeze, "lib/innate/helper.rb".freeze, "lib/innate/helper/aspect.rb".freeze, "lib/innate/helper/cgi.rb".freeze, "lib/innate/helper/flash.rb".freeze, "lib/innate/helper/link.rb".freeze, "lib/innate/helper/redirect.rb".freeze, "lib/innate/helper/render.rb".freeze, "lib/innate/log.rb".freeze, "lib/innate/log/color_formatter.rb".freeze, "lib/innate/log/hub.rb".freeze, "lib/innate/lru_hash.rb".freeze, "lib/innate/mock.rb".freeze, "lib/innate/node.rb".freeze, "lib/innate/options.rb".freeze, "lib/innate/options/dsl.rb".freeze, "lib/innate/options/stub.rb".freeze, "lib/innate/request.rb".freeze, "lib/innate/response.rb".freeze, "lib/innate/route.rb".freeze, "lib/innate/session.rb".freeze, "lib/innate/session/flash.rb".freeze, "lib/innate/spec.rb".freeze, "lib/innate/spec/bacon.rb".freeze, "lib/innate/state.rb".freeze, "lib/innate/state/accessor.rb".freeze, "lib/innate/traited.rb".freeze, "lib/innate/trinity.rb".freeze, "lib/innate/version.rb".freeze, "lib/innate/view.rb".freeze, "lib/innate/view/erb.rb".freeze, "lib/innate/view/etanni.rb".freeze, "lib/innate/view/none.rb".freeze, "spec/example/app/retro_games.rb".freeze, "spec/example/hello.rb".freeze, "spec/example/link.rb".freeze, "spec/example/provides.rb".freeze, "spec/example/session.rb".freeze, "spec/helper.rb".freeze, "spec/innate/action/layout.rb".freeze, "spec/innate/action/layout/file_layout.xhtml".freeze, "spec/innate/cache/common.rb".freeze, "spec/innate/cache/marshal.rb".freeze, "spec/innate/cache/memory.rb".freeze, "spec/innate/cache/yaml.rb".freeze, "spec/innate/dynamap.rb".freeze, "spec/innate/etanni.rb".freeze, "spec/innate/helper.rb".freeze, "spec/innate/helper/aspect.rb".freeze, "spec/innate/helper/cgi.rb".freeze, "spec/innate/helper/flash.rb".freeze, "spec/innate/helper/link.rb".freeze, "spec/innate/helper/redirect.rb".freeze, "spec/innate/helper/render.rb".freeze, "spec/innate/helper/view/aspect_hello.xhtml".freeze, "spec/innate/helper/view/locals.xhtml".freeze, "spec/innate/helper/view/loop.xhtml".freeze, "spec/innate/helper/view/num.xhtml".freeze, "spec/innate/helper/view/partial.xhtml".freeze, "spec/innate/helper/view/recursive.xhtml".freeze, "spec/innate/mock.rb".freeze, "spec/innate/modes.rb".freeze, "spec/innate/node/mapping.rb".freeze, "spec/innate/node/node.rb".freeze, "spec/innate/node/resolve.rb".freeze, "spec/innate/node/view/another_layout/another_layout.xhtml".freeze, "spec/innate/node/view/bar.xhtml".freeze, "spec/innate/node/view/cat2/cat22.xhtml".freeze, "spec/innate/node/view/cat3/cat33.xhtml".freeze, "spec/innate/node/view/foo.html.xhtml".freeze, "spec/innate/node/view/only_view.xhtml".freeze, "spec/innate/node/view/sub/baz.xhtml".freeze, "spec/innate/node/view/sub/foo/baz.xhtml".freeze, "spec/innate/node/view/with_layout.xhtml".freeze, "spec/innate/node/wrap_action_call.rb".freeze, "spec/innate/options.rb".freeze, "spec/innate/parameter.rb".freeze, "spec/innate/provides.rb".freeze, "spec/innate/provides/list.html.xhtml".freeze, "spec/innate/provides/list.txt.xhtml".freeze, "spec/innate/request.rb".freeze, "spec/innate/response.rb".freeze, "spec/innate/route.rb".freeze, "spec/innate/session.rb".freeze, "spec/innate/traited.rb".freeze, "tasks/authors.rake".freeze, "tasks/bacon.rake".freeze, "tasks/changelog.rake".freeze, "tasks/gem.rake".freeze, "tasks/gem_setup.rake".freeze, "tasks/grancher.rake".freeze, "tasks/manifest.rake".freeze, "tasks/rcov.rake".freeze, "tasks/release.rake".freeze, "tasks/reversion.rake".freeze, "tasks/setup.rake".freeze, "tasks/ycov.rake".freeze] s.homepage = "http://github.com/manveru/innate".freeze + s.licenses = ['MIT'] + s.required_ruby_version = ">= 3.0" s.rubygems_version = "3.3.20".freeze s.summary = "Powerful web-framework wrapper for Rack.".freeze @@ -20,16 +22,11 @@ Gem::Specification.new do |s| s.specification_version = 4 end - if s.respond_to? :add_runtime_dependency then - s.add_runtime_dependency(%q.freeze, ["~> 3.0"]) - s.add_development_dependency(%q.freeze, ["~> 1.2.0"]) - s.add_development_dependency(%q.freeze, ["~> 0.6.3"]) - else - s.add_dependency(%q.freeze, ["~> 1.2.0"]) - s.add_dependency(%q.freeze, ["~> 3.0"]) - s.add_dependency(%q.freeze, ["~> 0.6.3"]) - s.add_dependency(%q.freeze, ["~> 2.2.1"]) - s.add_dependency(%q.freeze, ["~> 1.0.0"]) - s.add_dependency(%q.freeze, ["~> 1.0.0"]) - end + s.add_runtime_dependency(%q.freeze, ["~> 3.0"]) + s.add_runtime_dependency(%q.freeze, ["~> 2.2.1"]) + s.add_runtime_dependency(%q.freeze, ["~> 1.0.0"]) + s.add_runtime_dependency(%q.freeze, ["~> 1.0.0"]) + + s.add_development_dependency(%q.freeze, ["~> 1.2.0"]) + s.add_development_dependency(%q.freeze, ["~> 0.6.3"]) end