{"id":13463514,"url":"https://github.com/wardrop/Scorched","last_synced_at":"2025-03-25T06:32:32.114Z","repository":{"id":4239736,"uuid":"5364066","full_name":"Wardrop/Scorched","owner":"Wardrop","description":"Light-weight, DRY as a desert, web framework for Ruby.","archived":false,"fork":false,"pushed_at":"2023-02-23T00:22:51.000Z","size":310,"stargazers_count":275,"open_issues_count":6,"forks_count":13,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-10-03T03:50:42.098Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://scorchedrb.com","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Wardrop.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2012-08-10T02:28:41.000Z","updated_at":"2024-06-28T09:32:10.000Z","dependencies_parsed_at":"2022-08-06T15:16:20.756Z","dependency_job_id":"ff897a47-eb56-424c-8453-87d63e2cfcc4","html_url":"https://github.com/Wardrop/Scorched","commit_stats":{"total_commits":147,"total_committers":10,"mean_commits":14.7,"dds":"0.23129251700680276","last_synced_commit":"4657a97fe5c81e69e7b2b846c6006a2ee2ef1285"},"previous_names":[],"tags_count":61,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wardrop%2FScorched","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wardrop%2FScorched/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wardrop%2FScorched/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wardrop%2FScorched/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Wardrop","download_url":"https://codeload.github.com/Wardrop/Scorched/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222045617,"owners_count":16921984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T13:00:54.649Z","updated_at":"2024-10-29T12:31:31.830Z","avatar_url":"https://github.com/Wardrop.png","language":"Ruby","readme":"[Simple, Powerful, Scorched](https://scorchedrb.com)\n==========================\n\nScorched is a generic, unopinionated, DRY, light-weight web framework for Ruby. It provides a generic yet powerful set of constructs for processing HTTP requests, with which websites and applications of almost any scale can be built.\n\nIf you've used a light-weight DSL-based Ruby web framework before, such as Sinatra, Scorched should look quite familiar. Scorched is a true evolutionary enhancement of Sinatra, with more power, focus, and less clutter.\n\nGetting Started\n---------------\n\nInstall the canister...\n\n```console\n$ gem install scorched\n```\n\nOpen the valve...\n\n```ruby\n# hello_world.ru\nrequire 'scorched'\nclass App \u003c Scorched::Controller\n  get '/' do\n    'hello world'\n  end\nend\nrun App\n```\n\nAnd light the flame...\n\n```console\n$ rackup hello_world.ru\n```\n\n#### A Note on Requirements\n\nScorched requires Ruby 2.0 or above. If you've got Ruby 2.0.0-p195 and newer, you're good. Otherwise, you need to ensure that your version of Ruby 2.0 includes [changeset 39919](http://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/39919) in order to avoid suffering from [random segmentation faults](http://bugs.ruby-lang.org/issues/8100).\n\n\nThe Errors of Our Past (and Present!)\n----------------------\nOne of the mistakes made by a lot of other Ruby frameworks is to not leverage the power of the class. Consequently, this makes for some awkwardness. Helpers for example, are a classic reinvention of what classes and modules are already made to solve. Scorched implements Controllers as classes, which in addition to having their own DSL, allow you to define and call whatever you need as standard instance methods. The decision to allow developers to implement helpers and other common functionality as standard instance methods not only makes Controllers somewhat more predictable and familiar, but also allows for such helpers to be inheritable via plain old class inheritance.\n\nAnother design oversight of other frameworks is the lack of consideration for the hierarchical nature of websites and the fact that it's often desireable for sub-directories to inherit attributes of their parents. Scorched supports sub-controllers to any arbitrary depth, with each controller's configuration, filters, route conditions, etc. applied along the way. This can help in many areas of web development, including security, restful interfaces, and interchangeable content types.\n\n\nDesign Philosophy\n-----------------\nScorched has a relatively simple design philosophy. The main objective is to keep Scorched lean and generic. Scorched refrains from expressing any opinion about how you should design and structure your application. The general idea is to give developers the constructs to quickly put together small, medium and even large websites and applications.\n\nThere is little need for a framework to be opinionated if the opinions of the developer can be quickly and easily built into it on a per-application basis. To do this effectively, developers will really need to understand Scorched, and the best way to facilitate that is to lower the learning curve, by keeping the core design logical, predictable and concise.\n\n\nMagicians Not Welcome\n---------------------\nScorched aims to be raw and transparent. Magic has no place. A thoughtful and simple design means there's no requirement for magic. Because of that, most developers should be able to master Scorched in an evening.\n\nPart of what keeps Scorched lightweight is that unlike other lightweight web frameworks that attempt to hide Rack in the background, Scorched makes no such attempt, very rarely providing functionality that overlaps with what's already provided by Rack. In fact, familiarity with Rack is somewhat of a pre-requisite to mastering Scorched.\n\n\nFirst Impressions\n-----------------\n\n```ruby\nclass MyApp \u003c Scorched::Controller\n\n  # From the most simple route possible...\n  get '/' do\n    \"Hello World\"\n  end\n\n  # To something that gets the muscle's flexing\n  route '/articles/:title/::opts', 2, method: ['GET', 'POST'], content_type: :json do\n    # Do what you want in here. Note, the second argument is the optional route priority.\n  end\n\n  # Anonymous controllers allow for convenient route grouping to which filters and conditions can be applied\n  controller conditions: {media_type: 'application/json'} do\n    get '/articles/*' do |page|\n      {title: 'Scorched Rocks', body: '...', created_at: '27/08/2012', created_by: 'Bob'}\n    end\n\n    after do\n      response.body = response.body.to_json\n    end\n  end\n\n  # The things you get for free by using Classes for Controllers (...that's directed at you Padrino)\n  def my_little_helper\n    # Do some crazy awesome stuff that no route can resist using.\n  end\n\n  # You can always avoid the routing helpers and add mappings manually. Anything that responds to #call is a valid\n  # target, with the only minor exception being that proc's are instance_exec'd, not call'd.\n  self \u003c\u003c {pattern: '/admin', priority: 10, target: My3rdPartyAdminApp}\n  self \u003c\u003c {pattern: '**', conditions: {maintenance_mode: true}, target: proc { |env|\n    @request.body \u003c\u003c 'Maintenance underway, please be patient.'\n  }}\nend\n```\n\nThis API shouldn't look too foreign to anyone familiar with frameworks like Sinatra, and the potential power at hand should be obvious. The `route` method demonstrates a few minor features of Scorched:\n\n* Multi-method routes - Because sometimes the difference between a GET and POST can be a single line of code. If no methods are provided, the route receives all HTTP methods.\n* Named Wildcards - Not an original idea, but you may note the named wildcard with the double colon. This maps to the '**' glob directive, which will span forward-slashes while matching. The single asterisk (or colon) behaves like the single asterisk glob directive, and will not match forward-slashes.\n* Route priorities - Routes (referred to as mappings internally) can be assigned priorities. A priority can be any arbitrary number by which the routes are ordered. The higher the number, the higher the priority.\n* Conditions - Conditions are merely procs defined on the controller which are inherited (and can be overriden) by child controllers. When a request comes in, mappings that match the requested URL, first have their conditions evaluated in the context of the controller instance, before control is handed off to the target associated with that mapping. It's a very simple implementation that comes with a lot of flexibility.\n\nComparisons with other frameworks\n---------------------------------\nRefer to the [comparisons](https://github.com/Wardrop/Scorched/tree/master/comparison) directory in the repo to compare a simple example app written in frameworks similar to Scorched.\n\nLinks\n-----\n* [Website](https://scorchedrb.com)\n* [Online API Reference](https://rubydoc.info/gems/scorched)\n* [GitHub Project](https://github.com/wardrop/Scorched)\n* [Issue Tracker](https://github.com/wardrop/Scorched/issues)\n* [Discussion/Mailing List](https://groups.google.com/d/forum/scorched)\n","funding_links":[],"categories":["Web Apps, Services \u0026 Interaction","Service Toolkits","Tools per Language"],"sub_categories":["Web App Frameworks","Ruby"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwardrop%2FScorched","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwardrop%2FScorched","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwardrop%2FScorched/lists"}