html_fn 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +39 -3
- data/html_fn.gemspec +1 -1
- data/lib/html_fn/attributes.rb +6 -6
- data/lib/html_fn/version.rb +1 -1
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17102465634775d6835f13de6bc0ca28a3d01e689a4debd729a7799cd2c97b87
|
4
|
+
data.tar.gz: 505c7de48f41cd4b047299f0975d3a8ca472e36ac0581ac4e380313f813d7f72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45f42fcc367a4fa79c396509b68b58ee6c6a910c24dd1cb8ac30306a6f53e874ac3443bda70abecec13de000ce911366349c2ae87e08b4828c38f3b069b79814
|
7
|
+
data.tar.gz: e019528fdecb6c4c5d811d3f58e7225ec6d772be366cdda5e2bd9233b5884e4234acd862c3459a71840c1e4326f904f7d629a8aca673e81c6a5dc4865019edc0
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
html_fn (0.3.
|
4
|
+
html_fn (0.3.1)
|
5
5
|
fn_reader
|
6
6
|
|
7
7
|
GEM
|
@@ -9,7 +9,7 @@ GEM
|
|
9
9
|
specs:
|
10
10
|
fn_reader (0.1.0)
|
11
11
|
minitest (5.11.3)
|
12
|
-
rake (
|
12
|
+
rake (13.0.3)
|
13
13
|
|
14
14
|
PLATFORMS
|
15
15
|
ruby
|
@@ -18,7 +18,7 @@ DEPENDENCIES
|
|
18
18
|
bundler (~> 1.17)
|
19
19
|
html_fn!
|
20
20
|
minitest (~> 5.0)
|
21
|
-
rake (
|
21
|
+
rake (>= 12.3.3)
|
22
22
|
|
23
23
|
BUNDLED WITH
|
24
24
|
1.17.2
|
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# HtmlFn
|
2
2
|
|
3
|
-
|
3
|
+
DSL for building HTML without using metaprogram magic.
|
4
4
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
5
|
|
7
6
|
## Installation
|
8
7
|
|
@@ -22,7 +21,44 @@ Or install it yourself as:
|
|
22
21
|
|
23
22
|
## Usage
|
24
23
|
|
25
|
-
|
24
|
+
```ruby
|
25
|
+
require 'htlm_fp'
|
26
|
+
|
27
|
+
|
28
|
+
include HttpFp
|
29
|
+
include HttpFp::Attributes
|
30
|
+
|
31
|
+
|
32
|
+
my_table =
|
33
|
+
table.([class_.("table")]).(
|
34
|
+
[thead.([]).(
|
35
|
+
[tr.([]).(
|
36
|
+
[th.([]).([text.("Name")]),
|
37
|
+
th.([]).([text.("Age")])]
|
38
|
+
)]
|
39
|
+
|
40
|
+
),
|
41
|
+
tbody.([]).(
|
42
|
+
[tr.([]).([
|
43
|
+
td.([]).([text.("Martin")]),
|
44
|
+
td.([]).([text.("34")]),
|
45
|
+
])]
|
46
|
+
)]
|
47
|
+
)
|
48
|
+
```
|
49
|
+
|
50
|
+
|
51
|
+
Note that the html will not be formated. If you want to format it, you can use a function as such:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
def pretty_print(a)
|
55
|
+
require "rexml/document"
|
56
|
+
d = REXML::Document.new(a)
|
57
|
+
d.write(s = "", 2)
|
58
|
+
s
|
59
|
+
end
|
60
|
+
|
61
|
+
```
|
26
62
|
|
27
63
|
## Development
|
28
64
|
|
data/html_fn.gemspec
CHANGED
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.require_paths = ["lib"]
|
38
38
|
|
39
39
|
spec.add_development_dependency "bundler", "~> 1.17"
|
40
|
-
spec.add_development_dependency "rake", "
|
40
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
41
41
|
spec.add_development_dependency "minitest", "~> 5.0"
|
42
42
|
spec.add_dependency "fn_reader"
|
43
43
|
end
|
data/lib/html_fn/attributes.rb
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
module HtmlFn
|
3
3
|
module Attributes
|
4
4
|
fn_reader :merge_attrs, :attrs_to_s, :string_property,
|
5
|
-
|
5
|
+
:class_, :style, :name_, :content, :href, :rel
|
6
6
|
|
7
7
|
# Your code goes here...
|
8
8
|
# module HtmlFnc
|
9
|
-
@@merge_attrs = ->
|
9
|
+
@@merge_attrs = ->hash {
|
10
10
|
hash.inject({}) do |group, (key, values)|
|
11
11
|
group[key] ||= []
|
12
12
|
group[key] += [values]
|
@@ -14,25 +14,25 @@ module HtmlFn
|
|
14
14
|
end.map { |key, val| [key, val.join(" ")] }.to_h
|
15
15
|
}
|
16
16
|
|
17
|
-
@@attrs_to_s = ->
|
17
|
+
@@attrs_to_s = ->attrs {
|
18
18
|
merged = @@merge_attrs.(attrs)
|
19
19
|
merged.map do |(attr_name, values)|
|
20
20
|
%{#{attr_name}="#{values}"}
|
21
21
|
end.join(" ")
|
22
22
|
}
|
23
23
|
|
24
|
-
@@string_property = ->
|
24
|
+
@@string_property = ->name, string {
|
25
25
|
[name, string]
|
26
26
|
}.curry
|
27
27
|
|
28
|
-
@@style = ->
|
28
|
+
@@style = ->styles {
|
29
29
|
string_property.("style").
|
30
30
|
(styles.map { |(key, val)| %{#{key}: #{val};} }.join(" "))
|
31
31
|
}
|
32
32
|
|
33
33
|
@@class_ = string_property.(:class)
|
34
34
|
@@id_ = string_property.(:id)
|
35
|
-
@@
|
35
|
+
@@name_ = string_property.(:name)
|
36
36
|
@@content = string_property.(:content)
|
37
37
|
@@href = string_property.(:href)
|
38
38
|
@@rel = string_property.(:rel)
|
data/lib/html_fn/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html_fn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Chabot
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 12.3.3
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 12.3.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description:
|
69
|
+
description:
|
70
70
|
email:
|
71
71
|
- chabotm@gmail.com
|
72
72
|
executables: []
|
@@ -93,7 +93,7 @@ licenses:
|
|
93
93
|
metadata:
|
94
94
|
homepage_uri: https://github.com/martinos/html_fn
|
95
95
|
source_code_uri: https://github.com/martinos/html_fn
|
96
|
-
post_install_message:
|
96
|
+
post_install_message:
|
97
97
|
rdoc_options: []
|
98
98
|
require_paths:
|
99
99
|
- lib
|
@@ -108,8 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
|
-
rubygems_version: 3.
|
112
|
-
signing_key:
|
111
|
+
rubygems_version: 3.1.4
|
112
|
+
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: Bunch of lamdas for building Html
|
115
115
|
test_files: []
|