glimmer-dsl-web 0.8.5 → 0.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +24 -2
- data/VERSION +1 -1
- data/glimmer-dsl-web.gemspec +5 -2
- data/lib/glimmer/util/url_builder.rb +116 -0
- metadata +30 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 38be4742b6e4be32704d86bbe0db19af0259b3c56a1f039028ceadfeb7fa42f2
|
|
4
|
+
data.tar.gz: bbe4558de7ce49a1a20cd6abb6b837ef0e5e6853472db91145b6719414524b6f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 98dfb5213321451ac67ebe397e0d8663d27c49dfb9397b694994b74deca7b31fad351e7a9cc4d637fdabccfb1ce3d6620228c123b519e71480d58f944f571752
|
|
7
|
+
data.tar.gz: 63e7e036931c362ab49894f7f2222c87fb5d8cc398e0a5de8b1b0420e0a9631f4901f2b7d1a1c32555a0152caa804102fc932866f4e29d7ff722ec20a9d1c90a
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 0.8.6
|
|
4
|
+
|
|
5
|
+
- `Glimmer::Util::UrlBuilder` implementation to facilitate building URLs (with protocol scheme, host, path, query params, and fragment)
|
|
6
|
+
|
|
3
7
|
## 0.8.5
|
|
4
8
|
|
|
5
9
|
- Update `Rails::ResourceService` to generate class resource name through correct underscored name (not just downcased)
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Web 0.8.
|
|
1
|
+
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Web 0.8.6 (Beta)
|
|
2
2
|
## Ruby-in-the-Browser Web Frontend Framework
|
|
3
3
|
### The "Rails" of Frontend Frameworks!!! ([Fukuoka Award Winning](https://andymaleh.blogspot.com/2025/01/glimmer-dsl-for-web-wins-in-fukuoka.html))
|
|
4
4
|
#### Finally, Ruby Developer Productivity, Happiness, and Fun in the Frontend!!!
|
|
@@ -1423,7 +1423,7 @@ rails new glimmer_app_server
|
|
|
1423
1423
|
Add the following to `Gemfile`:
|
|
1424
1424
|
|
|
1425
1425
|
```
|
|
1426
|
-
gem 'glimmer-dsl-web', '~> 0.8.
|
|
1426
|
+
gem 'glimmer-dsl-web', '~> 0.8.6'
|
|
1427
1427
|
```
|
|
1428
1428
|
|
|
1429
1429
|
Run:
|
|
@@ -1774,6 +1774,28 @@ Note that there are alternative ways of invoking the `Rails::ResourceService.upd
|
|
|
1774
1774
|
- `Rails::ResourceService.update(update_resource_url: "/contacts/#{form_contact.id}.json", resource_attributes: {first_name: form_contact.first_name, ...}) { |response, resource, errors| ... }`
|
|
1775
1775
|
- `Rails::ResourceService.update(update_resource_url: "/contacts/#{form_contact.id}.json", params: {contact: {first_name: form_contact.first_name, ...}}) { |response, resource, errors| ... }`
|
|
1776
1776
|
|
|
1777
|
+
### Glimmer::Util::UrlBuilder
|
|
1778
|
+
|
|
1779
|
+
`Glimmer::Util::UrlBuilder` is a convenience class that facilitate building URLs (with protocol scheme, host, path, query params, and fragment)
|
|
1780
|
+
|
|
1781
|
+
First, make sure to require the class file:
|
|
1782
|
+
```ruby
|
|
1783
|
+
require 'glimmer/util/url_builder'
|
|
1784
|
+
```
|
|
1785
|
+
|
|
1786
|
+
Usage:
|
|
1787
|
+
```ruby
|
|
1788
|
+
Glimmer::Util::UrlBuilder.new.scheme('http').host('www.google.com').path('/results').param('q', 'sports').fragment('#yesterday').to_url
|
|
1789
|
+
# => 'http://www.google.com/results?q=sports#yesterday'
|
|
1790
|
+
```
|
|
1791
|
+
|
|
1792
|
+
Or you can start from the URL of the current webpage, and amend the URL with extra params:
|
|
1793
|
+
```ruby
|
|
1794
|
+
# Current URL: http://www.google.com/results?q=sports
|
|
1795
|
+
Glimmer::Util::UrlBuilder.current.param('year', '2036').to_url
|
|
1796
|
+
# => 'http://www.google.com/results?q=sports&year=2036'
|
|
1797
|
+
```
|
|
1798
|
+
|
|
1777
1799
|
## Supported Glimmer DSL Keywords
|
|
1778
1800
|
|
|
1779
1801
|
[All HTML elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Element), following the Ruby method name standard of lowercase and underscored names.
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.8.
|
|
1
|
+
0.8.6
|
data/glimmer-dsl-web.gemspec
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
|
5
|
-
# stub: glimmer-dsl-web 0.8.
|
|
5
|
+
# stub: glimmer-dsl-web 0.8.6 ruby lib
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |s|
|
|
8
8
|
s.name = "glimmer-dsl-web".freeze
|
|
9
|
-
s.version = "0.8.
|
|
9
|
+
s.version = "0.8.6".freeze
|
|
10
10
|
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
12
12
|
s.require_paths = ["lib".freeze]
|
|
@@ -89,6 +89,7 @@ Gem::Specification.new do |s|
|
|
|
89
89
|
"lib/glimmer/dsl/web/style_element_expression.rb",
|
|
90
90
|
"lib/glimmer/helpers/glimmer_helper.rb",
|
|
91
91
|
"lib/glimmer/util/proc_tracker.rb",
|
|
92
|
+
"lib/glimmer/util/url_builder.rb",
|
|
92
93
|
"lib/glimmer/web.rb",
|
|
93
94
|
"lib/glimmer/web/component.rb",
|
|
94
95
|
"lib/glimmer/web/component/component_style_container.rb",
|
|
@@ -119,5 +120,7 @@ Gem::Specification.new do |s|
|
|
|
119
120
|
s.add_development_dependency(%q<jeweler>.freeze, [">= 2.3.9".freeze, "< 3.0.0".freeze])
|
|
120
121
|
s.add_development_dependency(%q<rdoc>.freeze, [">= 6.2.1".freeze, "< 7.0.0".freeze])
|
|
121
122
|
s.add_development_dependency(%q<opal-rspec>.freeze, ["~> 0.8.0.alpha2".freeze])
|
|
123
|
+
s.add_development_dependency(%q<minitest>.freeze, ["~> 5.25.4".freeze])
|
|
124
|
+
s.add_development_dependency(%q<minitest-focus>.freeze, ["~> 1.4.1".freeze])
|
|
122
125
|
end
|
|
123
126
|
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Copyright (c) 2023-2026 Andy Maleh
|
|
2
|
+
#
|
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
# a copy of this software and associated documentation files (the
|
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
# the following conditions:
|
|
10
|
+
#
|
|
11
|
+
# The above copyright notice and this permission notice shall be
|
|
12
|
+
# included in all copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
# TODO consider extracting this class into its own Ruby gem
|
|
23
|
+
require 'delegate'
|
|
24
|
+
|
|
25
|
+
module Glimmer
|
|
26
|
+
module Util
|
|
27
|
+
class UrlBuilder
|
|
28
|
+
DEFAULT_SCHEME = 'https'
|
|
29
|
+
REGEXP_URL = /^(http|https)?(:\/\/)?(([^\/\:]+):?(\d+)?)?(\/[^?#]*)?(\?[^#]*)?(\#.+)?$/
|
|
30
|
+
|
|
31
|
+
class << self
|
|
32
|
+
def current
|
|
33
|
+
new.url($$.document.location.href) if RUBY_ENGINE == 'opal'
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def initialize
|
|
38
|
+
@scheme = DEFAULT_SCHEME
|
|
39
|
+
@params = {}
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def scheme(value)
|
|
43
|
+
@scheme = value || DEFAULT_SCHEME
|
|
44
|
+
self
|
|
45
|
+
end
|
|
46
|
+
alias protocol scheme
|
|
47
|
+
|
|
48
|
+
def host(value)
|
|
49
|
+
return self if value.nil?
|
|
50
|
+
|
|
51
|
+
@host = value
|
|
52
|
+
@host.gsub('/', '')
|
|
53
|
+
self
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def port(value)
|
|
57
|
+
return self if value.nil?
|
|
58
|
+
|
|
59
|
+
@port = value
|
|
60
|
+
self
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def path(value)
|
|
64
|
+
return self if value.nil?
|
|
65
|
+
|
|
66
|
+
@path = value
|
|
67
|
+
@path = "/#{@path}" unless @path.start_with?('/')
|
|
68
|
+
self
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def param(name, value)
|
|
72
|
+
@params[name.to_s] = value
|
|
73
|
+
self
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def query(value)
|
|
77
|
+
return self if value.nil?
|
|
78
|
+
|
|
79
|
+
value = value.sub('?', '') if value.start_with?('?')
|
|
80
|
+
value.split('&').each do |param_pair|
|
|
81
|
+
name, value = param_pair.split('=')
|
|
82
|
+
@params[name.to_s] = value
|
|
83
|
+
end
|
|
84
|
+
self
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def fragment(value)
|
|
88
|
+
return self if value.nil?
|
|
89
|
+
|
|
90
|
+
@fragment = value
|
|
91
|
+
@fragment = "##{@fragment}" unless @fragment.start_with?('#')
|
|
92
|
+
self
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def url(value)
|
|
96
|
+
url_scheme, url_slashes, url_host_port, url_host, url_port, url_path, url_query, url_fragment = REGEXP_URL.match(value).to_a.drop(1)
|
|
97
|
+
scheme(url_scheme).host(url_host).port(url_port).path(url_path).query(url_query).fragment(url_fragment)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def to_url
|
|
101
|
+
output = "#{@scheme}://#{@host}"
|
|
102
|
+
output += ":#{@port}" if @port
|
|
103
|
+
output += "#{@path}#{compute_query}#{@fragment}"
|
|
104
|
+
output
|
|
105
|
+
end
|
|
106
|
+
alias to_s to_url
|
|
107
|
+
alias build to_url
|
|
108
|
+
|
|
109
|
+
def compute_query
|
|
110
|
+
computed_query = @params.map { |name, value| "#{name}=#{value}" }.join('&')
|
|
111
|
+
computed_query = "?#{computed_query}" unless computed_query.empty?
|
|
112
|
+
computed_query
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: glimmer-dsl-web
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andy Maleh
|
|
@@ -235,6 +235,34 @@ dependencies:
|
|
|
235
235
|
- - "~>"
|
|
236
236
|
- !ruby/object:Gem::Version
|
|
237
237
|
version: 0.8.0.alpha2
|
|
238
|
+
- !ruby/object:Gem::Dependency
|
|
239
|
+
name: minitest
|
|
240
|
+
requirement: !ruby/object:Gem::Requirement
|
|
241
|
+
requirements:
|
|
242
|
+
- - "~>"
|
|
243
|
+
- !ruby/object:Gem::Version
|
|
244
|
+
version: 5.25.4
|
|
245
|
+
type: :development
|
|
246
|
+
prerelease: false
|
|
247
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
248
|
+
requirements:
|
|
249
|
+
- - "~>"
|
|
250
|
+
- !ruby/object:Gem::Version
|
|
251
|
+
version: 5.25.4
|
|
252
|
+
- !ruby/object:Gem::Dependency
|
|
253
|
+
name: minitest-focus
|
|
254
|
+
requirement: !ruby/object:Gem::Requirement
|
|
255
|
+
requirements:
|
|
256
|
+
- - "~>"
|
|
257
|
+
- !ruby/object:Gem::Version
|
|
258
|
+
version: 1.4.1
|
|
259
|
+
type: :development
|
|
260
|
+
prerelease: false
|
|
261
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
262
|
+
requirements:
|
|
263
|
+
- - "~>"
|
|
264
|
+
- !ruby/object:Gem::Version
|
|
265
|
+
version: 1.4.1
|
|
238
266
|
description: Glimmer DSL for Web (Ruby in the Browser Web Frontend Framework) enables
|
|
239
267
|
building Web Frontends using Ruby in the Browser, as per Matz's recommendation in
|
|
240
268
|
his RubyConf 2022 keynote speech to replace JavaScript with Ruby. It aims at providing
|
|
@@ -328,6 +356,7 @@ files:
|
|
|
328
356
|
- lib/glimmer/dsl/web/style_element_expression.rb
|
|
329
357
|
- lib/glimmer/helpers/glimmer_helper.rb
|
|
330
358
|
- lib/glimmer/util/proc_tracker.rb
|
|
359
|
+
- lib/glimmer/util/url_builder.rb
|
|
331
360
|
- lib/glimmer/web.rb
|
|
332
361
|
- lib/glimmer/web/component.rb
|
|
333
362
|
- lib/glimmer/web/component/component_style_container.rb
|