fugleman 0.1.5 → 0.1.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/fugleman.gemspec +1 -1
- data/lib/fugleman/helpers.rb +16 -8
- data/lib/fugleman/namespace.rb +27 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73c3ad2ea7d52eecda0540ab8dd83caafcf1c97c
|
4
|
+
data.tar.gz: 6dd0ba68a547b4f56fe51100c146be393375aa55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a516e4bac574cb274ee711532109e82b5dcfa9a27466d46ae6a17f3e3a2048354022c4add16d49a3883eb8d345d665dccd112f221c0feceea4db13e6995a39c2
|
7
|
+
data.tar.gz: 7688d44b1d9381a14f204f227020552998880aa6d053fa7cb92b78d48a075a0427f6fb37cba54dcb59471a8b5223d893d27a840141d52e319f2e9a2ab5883ea4
|
data/fugleman.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "fugleman"
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.6"
|
6
6
|
s.summary = "Helpers and stuff for working with sinatra. Really simple."
|
7
7
|
s.homepage = "https://bitbucket.org/technologyastronauts/fugleman"
|
8
8
|
s.authors = ['Kaspar Schiess']
|
data/lib/fugleman/helpers.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
|
2
|
+
require 'fugleman/namespace'
|
3
|
+
|
2
4
|
# This started out life as a copy of code found in padrino, but was heavily
|
3
5
|
# simplified and then forked.
|
4
6
|
#
|
@@ -6,7 +8,13 @@
|
|
6
8
|
#
|
7
9
|
module Fugleman::Helpers
|
8
10
|
|
9
|
-
#
|
11
|
+
# -------------------------------------------------------------- form creation
|
12
|
+
|
13
|
+
def form_namespace path, obj=nil, &block
|
14
|
+
block.call(::Fugleman::Namespace.new(self, path, obj))
|
15
|
+
end
|
16
|
+
|
17
|
+
# --------------------------------------------------------------..---- linking
|
10
18
|
|
11
19
|
# Creates a link element with given name, url and options.
|
12
20
|
#
|
@@ -21,12 +29,12 @@ module Fugleman::Helpers
|
|
21
29
|
block_given? ? content_tag(:a, options, &block) : content_tag(:a, name, options)
|
22
30
|
end
|
23
31
|
|
24
|
-
#
|
32
|
+
# ------------------------------------------------------------------- partials
|
25
33
|
def partial name, opts={}, &block
|
26
34
|
slim name, { layout: false }.update(opts), &block
|
27
35
|
end
|
28
36
|
|
29
|
-
#
|
37
|
+
# -------------------------------------------------------------- tag rendering
|
30
38
|
def input_tag(type, name=nil, options = {})
|
31
39
|
tag(
|
32
40
|
:input,
|
@@ -52,7 +60,7 @@ module Fugleman::Helpers
|
|
52
60
|
output
|
53
61
|
end
|
54
62
|
|
55
|
-
#
|
63
|
+
# --------------------------------------------------------------------- assets
|
56
64
|
def image_tag(url, options={})
|
57
65
|
options.reverse_merge!(:src => image_path(url))
|
58
66
|
tag(:img, options)
|
@@ -91,7 +99,7 @@ module Fugleman::Helpers
|
|
91
99
|
"?#{stamp}"
|
92
100
|
end
|
93
101
|
|
94
|
-
#
|
102
|
+
# ------------------------------------------------------------------- escapism
|
95
103
|
def escape_html(text)
|
96
104
|
Rack::Utils.escape_html(text)
|
97
105
|
end
|
@@ -101,18 +109,18 @@ module Fugleman::Helpers
|
|
101
109
|
string.to_s.gsub(ESCAPE_REGEXP) { |c| ESCAPE_VALUES[c] }
|
102
110
|
end
|
103
111
|
|
104
|
-
#
|
112
|
+
# ---------------------------------------------------------- delayed rendering
|
105
113
|
|
106
114
|
# For content_for, etc.. please use Sinatra::ContentFor,
|
107
115
|
# part of sinatra-contrib.
|
108
116
|
|
109
|
-
#
|
117
|
+
# ------------------------------------------------------------------- captures
|
110
118
|
|
111
119
|
def capture_html(*args, &block)
|
112
120
|
# block.call(*args)
|
113
121
|
end
|
114
122
|
|
115
|
-
#
|
123
|
+
# ----------------------------------------------------------- foundation stuff
|
116
124
|
|
117
125
|
# Returns the URI root of the application with optional paths appended.
|
118
126
|
#
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Fugleman
|
4
|
+
class Namespace
|
5
|
+
attr_reader :path
|
6
|
+
|
7
|
+
def initialize context, path, obj
|
8
|
+
@context = context
|
9
|
+
@path = path
|
10
|
+
@obj = obj
|
11
|
+
end
|
12
|
+
|
13
|
+
def input_tag type, name, opts={}
|
14
|
+
opts = {value: value(name)}.merge(opts)
|
15
|
+
@context.input_tag type, full_name(name), opts
|
16
|
+
end
|
17
|
+
|
18
|
+
def full_name something
|
19
|
+
@path.to_s + "[#{something}]"
|
20
|
+
end
|
21
|
+
def value name
|
22
|
+
if @obj.respond_to? name
|
23
|
+
return @obj.send(name)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fugleman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kaspar Schiess
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- fugleman.gemspec
|
39
39
|
- lib/fugleman.rb
|
40
40
|
- lib/fugleman/helpers.rb
|
41
|
+
- lib/fugleman/namespace.rb
|
41
42
|
homepage: https://bitbucket.org/technologyastronauts/fugleman
|
42
43
|
licenses: []
|
43
44
|
metadata: {}
|