utopia 2.15.0 → 2.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (263) hide show
  1. checksums.yaml +4 -4
  2. data/bake/utopia/{yarn.rb → node.rb} +7 -7
  3. data/lib/utopia/command.rb +2 -2
  4. data/lib/utopia/command/server.rb +2 -1
  5. data/lib/utopia/command/site.rb +11 -1
  6. data/lib/utopia/content.rb +7 -5
  7. data/lib/utopia/content/markup.rb +1 -1
  8. data/lib/utopia/content/node.rb +2 -2
  9. data/lib/utopia/content/response.rb +3 -3
  10. data/lib/utopia/controller.rb +0 -17
  11. data/lib/utopia/controller/base.rb +27 -3
  12. data/lib/utopia/controller/respond.rb +50 -107
  13. data/lib/utopia/extensions/array_split.rb +2 -2
  14. data/lib/utopia/http.rb +3 -3
  15. data/lib/utopia/middleware.rb +2 -2
  16. data/lib/utopia/path.rb +24 -22
  17. data/lib/utopia/redirection.rb +0 -2
  18. data/lib/utopia/responder.rb +76 -0
  19. data/lib/utopia/version.rb +1 -1
  20. data/setup/server/git/hooks/post-receive +1 -1
  21. data/setup/site/.gitignore +8 -7
  22. data/setup/site/{Gemfile → gems.rb} +0 -0
  23. metadata +74 -398
  24. data/.codeclimate.yml +0 -5
  25. data/.github/workflows/development.yml +0 -62
  26. data/.gitignore +0 -8
  27. data/.rspec +0 -4
  28. data/.yardopts +0 -2
  29. data/Gemfile +0 -28
  30. data/README.md +0 -90
  31. data/benchmark/call_vs_check.rb +0 -38
  32. data/benchmark/const_vs_hash.rb +0 -35
  33. data/benchmark/hash_vs_openstruct.rb +0 -54
  34. data/benchmark/string_vs_symbol.rb +0 -14
  35. data/benchmark/struct_vs_class.rb +0 -91
  36. data/docs/.nojekyll +0 -0
  37. data/docs/_components/jquery-litebox/jquery.litebox.css +0 -23
  38. data/docs/_components/jquery-litebox/jquery.litebox.gallery.css +0 -48
  39. data/docs/_components/jquery-litebox/jquery.litebox.js +0 -30
  40. data/docs/_components/jquery-syntax/base/jquery.syntax.brush.apache.css +0 -12
  41. data/docs/_components/jquery-syntax/base/jquery.syntax.brush.applescript.css +0 -5
  42. data/docs/_components/jquery-syntax/base/jquery.syntax.brush.assembly.css +0 -8
  43. data/docs/_components/jquery-syntax/base/jquery.syntax.brush.bash-script.css +0 -6
  44. data/docs/_components/jquery-syntax/base/jquery.syntax.brush.bash.css +0 -4
  45. data/docs/_components/jquery-syntax/base/jquery.syntax.brush.clang.css +0 -6
  46. data/docs/_components/jquery-syntax/base/jquery.syntax.brush.css.css +0 -14
  47. data/docs/_components/jquery-syntax/base/jquery.syntax.brush.diff.css +0 -16
  48. data/docs/_components/jquery-syntax/base/jquery.syntax.brush.html.css +0 -5
  49. data/docs/_components/jquery-syntax/base/jquery.syntax.brush.ocaml.css +0 -3
  50. data/docs/_components/jquery-syntax/base/jquery.syntax.brush.protobuf.css +0 -2
  51. data/docs/_components/jquery-syntax/base/jquery.syntax.brush.python.css +0 -6
  52. data/docs/_components/jquery-syntax/base/jquery.syntax.brush.ruby.css +0 -2
  53. data/docs/_components/jquery-syntax/base/jquery.syntax.brush.xml.css +0 -18
  54. data/docs/_components/jquery-syntax/base/jquery.syntax.core.css +0 -58
  55. data/docs/_components/jquery-syntax/base/jquery.syntax.editor.css +0 -6
  56. data/docs/_components/jquery-syntax/base/theme.js +0 -1
  57. data/docs/_components/jquery-syntax/bright/jquery.syntax.core.css +0 -27
  58. data/docs/_components/jquery-syntax/bright/theme.js +0 -1
  59. data/docs/_components/jquery-syntax/jquery.syntax.brush.apache.js +0 -3
  60. data/docs/_components/jquery-syntax/jquery.syntax.brush.applescript.js +0 -5
  61. data/docs/_components/jquery-syntax/jquery.syntax.brush.assembly.js +0 -3
  62. data/docs/_components/jquery-syntax/jquery.syntax.brush.bash-script.js +0 -4
  63. data/docs/_components/jquery-syntax/jquery.syntax.brush.bash.js +0 -2
  64. data/docs/_components/jquery-syntax/jquery.syntax.brush.basic.js +0 -5
  65. data/docs/_components/jquery-syntax/jquery.syntax.brush.clang.js +0 -5
  66. data/docs/_components/jquery-syntax/jquery.syntax.brush.csharp.js +0 -4
  67. data/docs/_components/jquery-syntax/jquery.syntax.brush.css.js +0 -5
  68. data/docs/_components/jquery-syntax/jquery.syntax.brush.diff.js +0 -2
  69. data/docs/_components/jquery-syntax/jquery.syntax.brush.go.js +0 -3
  70. data/docs/_components/jquery-syntax/jquery.syntax.brush.haskell.js +0 -3
  71. data/docs/_components/jquery-syntax/jquery.syntax.brush.html.js +0 -4
  72. data/docs/_components/jquery-syntax/jquery.syntax.brush.io.js +0 -3
  73. data/docs/_components/jquery-syntax/jquery.syntax.brush.java.js +0 -4
  74. data/docs/_components/jquery-syntax/jquery.syntax.brush.javascript.js +0 -3
  75. data/docs/_components/jquery-syntax/jquery.syntax.brush.kai.js +0 -2
  76. data/docs/_components/jquery-syntax/jquery.syntax.brush.lisp.js +0 -2
  77. data/docs/_components/jquery-syntax/jquery.syntax.brush.lua.js +0 -3
  78. data/docs/_components/jquery-syntax/jquery.syntax.brush.nginx.js +0 -2
  79. data/docs/_components/jquery-syntax/jquery.syntax.brush.ocaml.js +0 -4
  80. data/docs/_components/jquery-syntax/jquery.syntax.brush.ooc.js +0 -4
  81. data/docs/_components/jquery-syntax/jquery.syntax.brush.pascal.js +0 -4
  82. data/docs/_components/jquery-syntax/jquery.syntax.brush.perl5.js +0 -3
  83. data/docs/_components/jquery-syntax/jquery.syntax.brush.php-script.js +0 -4
  84. data/docs/_components/jquery-syntax/jquery.syntax.brush.php.js +0 -2
  85. data/docs/_components/jquery-syntax/jquery.syntax.brush.plain.js +0 -2
  86. data/docs/_components/jquery-syntax/jquery.syntax.brush.protobuf.js +0 -3
  87. data/docs/_components/jquery-syntax/jquery.syntax.brush.python.js +0 -5
  88. data/docs/_components/jquery-syntax/jquery.syntax.brush.ruby.js +0 -5
  89. data/docs/_components/jquery-syntax/jquery.syntax.brush.scala.js +0 -4
  90. data/docs/_components/jquery-syntax/jquery.syntax.brush.smalltalk.js +0 -2
  91. data/docs/_components/jquery-syntax/jquery.syntax.brush.sql.js +0 -4
  92. data/docs/_components/jquery-syntax/jquery.syntax.brush.super-collider.js +0 -3
  93. data/docs/_components/jquery-syntax/jquery.syntax.brush.swift.js +0 -3
  94. data/docs/_components/jquery-syntax/jquery.syntax.brush.trenni.js +0 -2
  95. data/docs/_components/jquery-syntax/jquery.syntax.brush.xml.js +0 -4
  96. data/docs/_components/jquery-syntax/jquery.syntax.brush.yaml.js +0 -2
  97. data/docs/_components/jquery-syntax/jquery.syntax.cache.js +0 -7
  98. data/docs/_components/jquery-syntax/jquery.syntax.core.js +0 -34
  99. data/docs/_components/jquery-syntax/jquery.syntax.editor.js +0 -11
  100. data/docs/_components/jquery-syntax/jquery.syntax.js +0 -8
  101. data/docs/_components/jquery-syntax/jquery.syntax.min.js +0 -13
  102. data/docs/_components/jquery-syntax/paper/jquery.syntax.core.css +0 -31
  103. data/docs/_components/jquery-syntax/paper/theme.js +0 -1
  104. data/docs/_components/jquery/jquery.js +0 -10872
  105. data/docs/_components/jquery/jquery.min.js +0 -2
  106. data/docs/_components/jquery/jquery.min.map +0 -1
  107. data/docs/_components/jquery/jquery.slim.js +0 -8777
  108. data/docs/_components/jquery/jquery.slim.min.js +0 -2
  109. data/docs/_components/jquery/jquery.slim.min.map +0 -1
  110. data/docs/_static/icon.png +0 -0
  111. data/docs/_static/site.css +0 -191
  112. data/docs/development-environment-setup/index.html +0 -54
  113. data/docs/faq/what-is-xnode/index.html +0 -73
  114. data/docs/index.html +0 -86
  115. data/docs/javascript/index.html +0 -108
  116. data/docs/middleware/content/index.html +0 -58
  117. data/docs/middleware/controller/actions/index.html +0 -111
  118. data/docs/middleware/controller/index.html +0 -98
  119. data/docs/middleware/controller/rewrite/index.html +0 -105
  120. data/docs/middleware/localization/index.html +0 -53
  121. data/docs/middleware/redirection/index.html +0 -55
  122. data/docs/middleware/session/index.html +0 -65
  123. data/docs/middleware/static/index.html +0 -51
  124. data/docs/server-setup/index.html +0 -87
  125. data/docs/testing/index.html +0 -53
  126. data/docs/updating-utopia/index.html +0 -102
  127. data/docs/your-first-page/index.html +0 -74
  128. data/materials/utopia.png +0 -0
  129. data/materials/utopia.svg +0 -1
  130. data/spec/mock_node.rb +0 -16
  131. data/spec/spec_helper.rb +0 -13
  132. data/spec/utopia/command_spec.rb +0 -164
  133. data/spec/utopia/content/document_spec.rb +0 -60
  134. data/spec/utopia/content/links/bar/index.xnode +0 -0
  135. data/spec/utopia/content/links/bar/parent/child/index.en.xnode +0 -0
  136. data/spec/utopia/content/links/bar/parent/child/index.ja.xnode +0 -0
  137. data/spec/utopia/content/links/bar/parent/links.yaml +0 -2
  138. data/spec/utopia/content/links/foo/index.xnode +0 -0
  139. data/spec/utopia/content/links/foo/links.yaml +0 -2
  140. data/spec/utopia/content/links/foo/test.de.xnode +0 -0
  141. data/spec/utopia/content/links/foo/test.en.xnode +0 -0
  142. data/spec/utopia/content/links/index.xnode +0 -0
  143. data/spec/utopia/content/links/links.yaml +0 -18
  144. data/spec/utopia/content/links/redirect/links.yaml +0 -2
  145. data/spec/utopia/content/links/welcome.xnode +0 -0
  146. data/spec/utopia/content/links_spec.rb +0 -218
  147. data/spec/utopia/content/localized/five/index.en.xnode +0 -0
  148. data/spec/utopia/content/localized/four/index.en.xnode +0 -0
  149. data/spec/utopia/content/localized/four/index.zh.xnode +0 -0
  150. data/spec/utopia/content/localized/four/links.yaml +0 -4
  151. data/spec/utopia/content/localized/links.yaml +0 -13
  152. data/spec/utopia/content/localized/one.xnode +0 -0
  153. data/spec/utopia/content/localized/three/index.xnode +0 -0
  154. data/spec/utopia/content/localized/two.en.xnode +0 -0
  155. data/spec/utopia/content/localized/two.zh.xnode +0 -0
  156. data/spec/utopia/content/markup_spec.rb +0 -96
  157. data/spec/utopia/content/namespace_spec.rb +0 -45
  158. data/spec/utopia/content/node/lookup/content.xnode +0 -1
  159. data/spec/utopia/content/node/lookup/index.xnode +0 -1
  160. data/spec/utopia/content/node/ordered/first.xnode +0 -0
  161. data/spec/utopia/content/node/ordered/index.xnode +0 -0
  162. data/spec/utopia/content/node/ordered/links.yaml +0 -4
  163. data/spec/utopia/content/node/ordered/second.xnode +0 -0
  164. data/spec/utopia/content/node/related/foo.en.xnode +0 -0
  165. data/spec/utopia/content/node/related/foo.ja.xnode +0 -0
  166. data/spec/utopia/content/node/related/links.yaml +0 -4
  167. data/spec/utopia/content/node_spec.rb +0 -97
  168. data/spec/utopia/content/response_spec.rb +0 -54
  169. data/spec/utopia/content/tags_spec.rb +0 -82
  170. data/spec/utopia/content_spec.rb +0 -100
  171. data/spec/utopia/content_spec.ru +0 -6
  172. data/spec/utopia/content_spec/_heading.xnode +0 -1
  173. data/spec/utopia/content_spec/content/_show-value.xnode +0 -1
  174. data/spec/utopia/content_spec/content/links.yaml +0 -2
  175. data/spec/utopia/content_spec/content/test-partial.xnode +0 -1
  176. data/spec/utopia/content_spec/index.xnode +0 -1
  177. data/spec/utopia/content_spec/node/index.xnode +0 -1
  178. data/spec/utopia/content_spec/test.xnode +0 -10
  179. data/spec/utopia/controller/actions_spec.rb +0 -62
  180. data/spec/utopia/controller/middleware_spec.rb +0 -88
  181. data/spec/utopia/controller/middleware_spec.ru +0 -6
  182. data/spec/utopia/controller/middleware_spec/controller/controller.rb +0 -27
  183. data/spec/utopia/controller/middleware_spec/controller/index.xnode +0 -1
  184. data/spec/utopia/controller/middleware_spec/controller/nested/controller.rb +0 -7
  185. data/spec/utopia/controller/middleware_spec/empty/controller.rb +0 -0
  186. data/spec/utopia/controller/middleware_spec/redirect/controller.rb +0 -12
  187. data/spec/utopia/controller/middleware_spec/redirect/test/controller.rb +0 -9
  188. data/spec/utopia/controller/respond_spec.rb +0 -174
  189. data/spec/utopia/controller/respond_spec.ru +0 -12
  190. data/spec/utopia/controller/respond_spec/api/controller.rb +0 -28
  191. data/spec/utopia/controller/respond_spec/errors/controller.rb +0 -14
  192. data/spec/utopia/controller/respond_spec/errors/file-not-found.xnode +0 -8
  193. data/spec/utopia/controller/respond_spec/html/controller.rb +0 -11
  194. data/spec/utopia/controller/respond_spec/rewrite/controller.rb +0 -13
  195. data/spec/utopia/controller/rewrite_spec.rb +0 -80
  196. data/spec/utopia/controller/sequence_spec.rb +0 -135
  197. data/spec/utopia/controller/variables_spec.rb +0 -59
  198. data/spec/utopia/controller/websocket_spec.rb +0 -68
  199. data/spec/utopia/controller/websocket_spec.ru +0 -5
  200. data/spec/utopia/controller/websocket_spec/server/controller.rb +0 -11
  201. data/spec/utopia/exceptions/handler_spec.rb +0 -47
  202. data/spec/utopia/exceptions/handler_spec.ru +0 -8
  203. data/spec/utopia/exceptions/handler_spec/controller.rb +0 -19
  204. data/spec/utopia/exceptions/mailer_spec.rb +0 -43
  205. data/spec/utopia/exceptions/mailer_spec.ru +0 -10
  206. data/spec/utopia/extensions_spec.rb +0 -73
  207. data/spec/utopia/http/status_spec.rb +0 -44
  208. data/spec/utopia/locale_spec.rb +0 -58
  209. data/spec/utopia/localization_spec.rb +0 -92
  210. data/spec/utopia/localization_spec.ru +0 -15
  211. data/spec/utopia/localization_spec/controller.rb +0 -21
  212. data/spec/utopia/localization_spec/localized.de.txt +0 -1
  213. data/spec/utopia/localization_spec/localized.en.txt +0 -1
  214. data/spec/utopia/localization_spec/localized.ja.txt +0 -1
  215. data/spec/utopia/localization_spec/test.txt +0 -1
  216. data/spec/utopia/middleware_spec.rb +0 -31
  217. data/spec/utopia/path/matcher_spec.rb +0 -66
  218. data/spec/utopia/path_spec.rb +0 -207
  219. data/spec/utopia/performance_spec.rb +0 -92
  220. data/spec/utopia/performance_spec/cache/head/readme.txt +0 -1
  221. data/spec/utopia/performance_spec/cache/meta/readme.txt +0 -1
  222. data/spec/utopia/performance_spec/config.ru +0 -35
  223. data/spec/utopia/performance_spec/lib/readme.txt +0 -1
  224. data/spec/utopia/performance_spec/pages/_heading.xnode +0 -2
  225. data/spec/utopia/performance_spec/pages/_page.xnode +0 -26
  226. data/spec/utopia/performance_spec/pages/api/controller.rb +0 -8
  227. data/spec/utopia/performance_spec/pages/errors/exception.xnode +0 -5
  228. data/spec/utopia/performance_spec/pages/errors/file-not-found.xnode +0 -5
  229. data/spec/utopia/performance_spec/pages/links.yaml +0 -2
  230. data/spec/utopia/performance_spec/pages/welcome/index.xnode +0 -17
  231. data/spec/utopia/rack_helper.rb +0 -32
  232. data/spec/utopia/redirection_spec.rb +0 -77
  233. data/spec/utopia/redirection_spec.ru +0 -27
  234. data/spec/utopia/session_spec.rb +0 -189
  235. data/spec/utopia/session_spec.ru +0 -24
  236. data/spec/utopia/setup_spec.rb +0 -56
  237. data/spec/utopia/static_spec.rb +0 -49
  238. data/spec/utopia/static_spec.ru +0 -5
  239. data/spec/utopia/static_spec/test.txt +0 -1
  240. data/utopia.gemspec +0 -52
  241. data/wiki/Gemfile +0 -9
  242. data/wiki/config.ru +0 -7
  243. data/wiki/pages/development-environment-setup/index.md +0 -16
  244. data/wiki/pages/faq/links.yaml +0 -2
  245. data/wiki/pages/faq/what-is-xnode/index.md +0 -37
  246. data/wiki/pages/faq/what-is-xnode/links.yaml +0 -2
  247. data/wiki/pages/index.md +0 -35
  248. data/wiki/pages/javascript/index.md +0 -75
  249. data/wiki/pages/javascript/links.yaml +0 -2
  250. data/wiki/pages/links.yaml +0 -2
  251. data/wiki/pages/middleware/content/index.md +0 -21
  252. data/wiki/pages/middleware/controller/actions/index.md +0 -76
  253. data/wiki/pages/middleware/controller/index.md +0 -62
  254. data/wiki/pages/middleware/controller/links.yaml +0 -4
  255. data/wiki/pages/middleware/controller/rewrite/index.md +0 -69
  256. data/wiki/pages/middleware/localization/index.md +0 -16
  257. data/wiki/pages/middleware/redirection/index.md +0 -17
  258. data/wiki/pages/middleware/session/index.md +0 -29
  259. data/wiki/pages/middleware/static/index.md +0 -13
  260. data/wiki/pages/server-setup/index.md +0 -52
  261. data/wiki/pages/testing/index.md +0 -15
  262. data/wiki/pages/updating-utopia/index.md +0 -63
  263. data/wiki/pages/your-first-page/index.md +0 -38
@@ -1,5 +0,0 @@
1
- exclude_paths:
2
- - "docs/**/*"
3
- - "documentation/**/*"
4
- - "setup/**/*"
5
- - "benchmarks/*"
@@ -1,62 +0,0 @@
1
- name: Development
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- test:
7
- runs-on: ${{matrix.os}}-latest
8
- continue-on-error: ${{matrix.experimental}}
9
-
10
- strategy:
11
- matrix:
12
- os:
13
- - ubuntu
14
- - macos
15
-
16
- ruby:
17
- - 2.5
18
- - 2.6
19
- - 2.7
20
-
21
- experimental: [false]
22
- env: [""]
23
-
24
- include:
25
- - os: ubuntu
26
- ruby: truffleruby
27
- experimental: true
28
- env: JRUBY_OPTS="--debug -X+O"
29
- - os: ubuntu
30
- ruby: jruby
31
- experimental: true
32
- - os: ubuntu
33
- ruby: head
34
- experimental: true
35
- - os: ubuntu
36
- ruby: 2.6
37
- experimental: false
38
- env: COVERAGE=PartialSummary,Coveralls
39
-
40
- steps:
41
- - uses: actions/checkout@v1
42
- - uses: ruby/setup-ruby@v1
43
- with:
44
- ruby-version: ${{matrix.ruby}}
45
-
46
- - name: Install dependencies
47
- run: ${{matrix.env}} bundle install
48
-
49
- - name: Installing packages (ubuntu)
50
- if: matrix.os == 'ubuntu'
51
- run: sudo apt-get install wget
52
-
53
- - name: Installing packages (macos)
54
- if: matrix.os == 'macos'
55
- run: brew install wget
56
-
57
- - name: Run tests
58
- timeout-minutes: 5
59
- run: |
60
- git config --global user.email "samuel@oriontransfer.net"
61
- git config --global user.name "Samuel Williams"
62
- ${{matrix.env}} bundle exec rspec
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- tmp
2
- .tags*
3
- *.gem
4
- Gemfile.lock
5
- documentation/run/*
6
- documentation/public/code/*
7
- .rspec_status
8
- .yardoc
data/.rspec DELETED
@@ -1,4 +0,0 @@
1
- --format documentation
2
- --backtrace
3
- --require spec_helper
4
- --warnings
data/.yardopts DELETED
@@ -1,2 +0,0 @@
1
- --markup markdown
2
- --asset materials:materials
data/Gemfile DELETED
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in utopia.gemspec
6
- gemspec
7
-
8
- group :development do
9
- gem 'yard'
10
-
11
- gem 'kramdown'
12
- gem 'kramdown-parser-gfm'
13
-
14
- gem 'json'
15
-
16
- gem 'rackula'
17
- end
18
-
19
- group :test do
20
- gem 'benchmark-ips'
21
- gem 'ruby-prof', platforms: :mri
22
-
23
- gem 'guard-falcon'
24
-
25
- gem 'rack-test'
26
- end
27
-
28
- gem "thread-local", "~> 1.0"
data/README.md DELETED
@@ -1,90 +0,0 @@
1
- # ![Utopia Logo](materials/utopia.svg)
2
-
3
- Utopia is a website generation framework which provides a robust set of tools to build highly complex dynamic websites. It uses the filesystem heavily for content and provides functions for interacting with files and directories as structure representing the website.
4
-
5
- [![Actions Status](https://github.com/socketry/utopia/workflows/Development/badge.svg)](https://github.com/socketry/async/actions?workflow=Development)
6
-
7
- ## Motivation
8
-
9
- The [original Utopia project](https://github.com/ioquatix/utopia-php) was written in PHP in the early 2000s. It consisted of an XML parser, a database layer and some code to assist with business logic. It was initially designed to reduce the amount of HTML required to build both content-centric websites and business apps. At the time, CSS was very poorly supported and thus a lot of the time, you'd be using quite complex `<table>`s with embedded `<img>`s to generate simple things like boxes with drop shadows, etc. Utopia provided a core concept - a node - which was essentially a small snippet of HTML, which could be composed into other nodes simply by using a named tag (similar to ColdFusion). Attributes and content were passed in, and thus you could easily build complex pages with simple semantic markup.
10
-
11
- At the time, the available frameworks were pretty basic. Utopia was a working, albeit poor, implementation of MVC and supported several commercial websites I developed at the time. I made it, partly just because I could, but also because it served a commercial purpose.
12
-
13
- Eventually one day I started using Ruby on Rails. There are aspects of the Rails framework which I like. However, at the time I was using it (starting with version 0.8), I found that it's flat organisation of controllers and views very limiting. Nested controllers and views make it easier to manage complexity in a web application. Utopia embraces this principle, and applies it to both the controller and view layers. I also developed a [model layer with similar principles](https://github.com/ioquatix/relaxo-model).
14
-
15
- So, Utopia exists because it suits my way of thinking about web applications, and it's conceptual core has been refined for over a decade. It provides a considered amount of both flexibility, and opinionated behavior.
16
-
17
- ### Is it production ready?
18
-
19
- Yes. We've used Utopia since about 2010 in production.
20
-
21
- ### Is it fast?
22
-
23
- Yes. [Trenni](https://github.com/ioquatix/trenni) includes native [Ragel](http://www.colm.net/open-source/ragel/) parsers, and Utopia uses [Concurrent::Map](https://github.com/ruby-concurrency/concurrent-ruby) for multi-thread safe caches. On my laptop, Utopia can process 3000 requests/s rendering content on a single thread.
24
-
25
- ## Installation
26
-
27
- Make sure you have git, ruby, and bundler installed and set up correctly.
28
-
29
- Install utopia:
30
-
31
- $ gem install utopia
32
-
33
- Create a new site:
34
-
35
- $ mkdir www.example.com
36
- $ cd www.example.com
37
- $ utopia site create
38
- $ rake
39
-
40
- ## Usage
41
-
42
- There is an excellent [documentation wiki](https://socketry.github.io/utopia/) included with the source code. Simply clone this repository and `rake documentation:server`. This documentation wiki is editable, so feel free to submit a PR with improvements.
43
-
44
- ## Contributing
45
-
46
- 1. Fork it
47
- 2. Create your feature branch (`git checkout -b my-new-feature`)
48
- 3. Commit your changes (`git commit -am 'Add some feature'`)
49
- 4. Push to the branch (`git push origin my-new-feature`)
50
- 5. Create new Pull Request
51
-
52
- ## See Also
53
-
54
- - [Trenni](https://github.com/ioquatix/trenni) — Template and markup parsers, markup generation.
55
- - [Trenni::Formatters](https://github.com/ioquatix/trenni-formatters) — Helpers for HTML generation including views and forms.
56
- - [Utopia::Gallery](https://github.com/ioquatix/utopia-gallery) — A fast photo gallery based on [libvips](https://github.com/jcupitt/libvips).
57
- - [Utopia::Analytics](https://github.com/ioquatix/utopia-analytics) — Simple integration with Google Analytics.
58
- - [HTTP::Accept](https://github.com/ioquatix/http-accept) — RFC compliant header parser.
59
- - [Samovar](https://github.com/ioquatix/samovar) — Command line parser used by Utopia.
60
- - [Mapping](https://github.com/ioquatix/mapping) — Provide structured conversions for web interfaces.
61
- - [Rack::Test::Body](https://github.com/ioquatix/rack-test-body) — Provide convenient helpers for testing web interfaces.
62
-
63
- ### Applications
64
-
65
- - [Financier](https://github.com/ioquatix/financier) — A small business management platform.
66
- - [mail.oriontransfer.net](https://github.com/oriontransfer/mail.oriontransfer.net) - Mail server account management.
67
-
68
- ## License
69
-
70
- Released under the MIT license.
71
-
72
- Copyright, 2009-2020, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
73
-
74
- Permission is hereby granted, free of charge, to any person obtaining a copy
75
- of this software and associated documentation files (the "Software"), to deal
76
- in the Software without restriction, including without limitation the rights
77
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
78
- copies of the Software, and to permit persons to whom the Software is
79
- furnished to do so, subject to the following conditions:
80
-
81
- The above copyright notice and this permission notice shall be included in
82
- all copies or substantial portions of the Software.
83
-
84
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
85
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
86
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
87
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
88
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
89
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
90
- THE SOFTWARE.
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'benchmark/ips'
4
-
5
- class A
6
- end
7
-
8
- class B
9
- def self.do
10
- end
11
- end
12
-
13
- class C
14
- def self.do
15
- end
16
- end
17
-
18
- Benchmark.ips do |x|
19
- x.report("responds_to? (nothing)") do |times|
20
- while (times -= 1) >= 0
21
- A.do if A.respond_to?(:do)
22
- end
23
- end
24
-
25
- x.report("B (empty method)") do |times|
26
- while (times -= 1) >= 0
27
- B.do
28
- end
29
- end
30
-
31
- x.report("responds_to? (empty method)") do |times|
32
- while (times -= 1) >= 0
33
- C.do if C.respond_to?(:do)
34
- end
35
- end
36
-
37
- x.compare!
38
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'benchmark/ips'
4
-
5
- module Foo
6
- class Bar
7
- end
8
- end
9
-
10
-
11
- THINGS = {
12
- 'Bar' => Foo::Bar
13
- }
14
-
15
- Benchmark.ips do |x|
16
- x.report("const_get('Bar')") do |i|
17
- while (i -= 1) > 0
18
- Foo.const_get('Bar')
19
- end
20
- end
21
-
22
- x.report("const_get(:Bar)") do |i|
23
- while (i -= 1) > 0
24
- Foo.const_get(:Bar)
25
- end
26
- end
27
-
28
- x.report("Hash\#[]") do |i|
29
- while (i -= 1) > 0
30
- THINGS['Bar']
31
- end
32
- end
33
-
34
- x.compare!
35
- end
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'benchmark/ips'
4
- require 'ostruct'
5
-
6
- # This benchmark compares accessing an instance variable vs accessing a struct member (via a function). The actual method dispatch is about 25% slower.
7
-
8
- puts "Ruby #{RUBY_VERSION} at #{Time.now}"
9
-
10
- NAME = "Test Name"
11
- EMAIL = "test@example.org"
12
-
13
- test = nil
14
-
15
- class ObjectHash
16
- def []= key, value
17
- instance_variable_set(key, value)
18
- end
19
-
20
- def [] key
21
- instance_variable_get(key)
22
- end
23
- end
24
-
25
- # There IS a measuarble difference:
26
- Benchmark.ips do |x|
27
- x.report("Hash") do |i|
28
- i.times do
29
- p = {name: NAME, email: EMAIL}
30
-
31
- test = p[:name] + p[:email]
32
- end
33
- end
34
-
35
- x.report("OpenStruct") do |i|
36
- i.times do
37
- p = OpenStruct.new(name: NAME, email: EMAIL)
38
-
39
- test = p.name + p.email
40
- end
41
- end
42
-
43
- x.report("ObjectHash") do |i|
44
- i.times do
45
- o = ObjectHash.new
46
- o[:@name] = NAME
47
- o[:@email] = EMAIL
48
-
49
- test = o[:@name] + o[:@email]
50
- end
51
- end
52
-
53
- x.compare!
54
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'benchmark/ips'
4
-
5
- STRING_HASH = { "foo" => "bar" }
6
- SYMBOL_HASH = { :foo => "bar" }
7
-
8
- Benchmark.ips do |x|
9
- x.report("string") { STRING_HASH["foo"] }
10
- x.report("symbol") { SYMBOL_HASH[:foo] }
11
- x.report("symbol-from-string") { SYMBOL_HASH["foo".to_sym] }
12
-
13
- x.compare!
14
- end
@@ -1,91 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'benchmark/ips'
4
-
5
- # This benchmark compares accessing an instance variable vs accessing a struct member (via a function). The actual method dispatch is about 25% slower.
6
-
7
- puts "Ruby #{RUBY_VERSION} at #{Time.now}"
8
-
9
- ItemsStruct = Struct.new(:items) do
10
- def initialize
11
- super []
12
- end
13
-
14
- def push_me_pull_you(value = :x)
15
- items = self.items
16
-
17
- items << value
18
- items.pop
19
- end
20
-
21
- def empty?
22
- self.items.empty?
23
- end
24
- end
25
-
26
- class ItemsClass
27
- def initialize
28
- @items = []
29
- end
30
-
31
- def push_me_pull_you(value = :x)
32
- items = @items
33
-
34
- items << value
35
- items.pop
36
- end
37
-
38
- def empty?
39
- @items.empty?
40
- end
41
- end
42
-
43
- # There IS a measuarble difference:
44
- Benchmark.ips do |x|
45
- x.report("Struct#empty?") do |times|
46
- i = 0
47
- instance = ItemsStruct.new
48
-
49
- while i < times
50
- break unless instance.empty?
51
- i += 1
52
- end
53
- end
54
-
55
- x.report("Class#empty?") do |times|
56
- i = 0
57
- instance = ItemsClass.new
58
-
59
- while i < times
60
- break unless instance.empty?
61
- i += 1
62
- end
63
- end
64
-
65
- x.compare!
66
- end
67
-
68
- # This shows that in the presence of additional work, the difference is neglegible.
69
- Benchmark.ips do |x|
70
- x.report("Struct#push_me_pull_you") do |times|
71
- i = 0
72
- a = A.new
73
-
74
- while i < times
75
- a.push_me_pull_you(i)
76
- i += 1
77
- end
78
- end
79
-
80
- x.report("Class#push_me_pull_you") do |times|
81
- i = 0
82
- b = B.new
83
-
84
- while i < times
85
- b.push_me_pull_you(i)
86
- i += 1
87
- end
88
- end
89
-
90
- x.compare!
91
- end