httpong-rails 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -5
- data/lib/httpong/rails.rb +1 -0
- data/lib/httpong/rails/helper.rb +36 -15
- data/lib/httpong/rails/reloader.rb +16 -0
- data/lib/httpong/rails/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d26719b096610099353d54a4135138fbae73b297
|
4
|
+
data.tar.gz: fbedfc1d7014406d4e4b745e080abeb0c8828255
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3592ee6dc7d91dda62a7d25711b6c5ce9ca3b737d516a12e72f4a8be6f5fe3d5c256bc89fb6101b6ce2975f74fa5c8ddc76a96917fd257e0e6d5758da080f237
|
7
|
+
data.tar.gz: aad7a2a434fe7161f0d4b3a947daf6b0c971346b6090bad95ceb3b33a68f7e80dfeed315c957cf50dbd4389ab59b03be12aa8c23cc3629eb68c57be225a73a19
|
data/README.md
CHANGED
@@ -2,11 +2,15 @@
|
|
2
2
|
|
3
3
|
This library is meant to use with [HTTPong for Javascript][js]
|
4
4
|
|
5
|
-
You can put a `scheme.json`
|
5
|
+
You can put a `scheme.json` in the `/config` folder, and
|
6
6
|
that will be used as the default scheme.
|
7
7
|
|
8
|
+
```ruby
|
9
|
+
gem 'httpong-rails'
|
10
|
+
```
|
11
|
+
|
8
12
|
```bash
|
9
|
-
$ rails generate httpong
|
13
|
+
$ rails generate httpong
|
10
14
|
```
|
11
15
|
|
12
16
|
```ruby
|
@@ -18,9 +22,9 @@ end
|
|
18
22
|
|
19
23
|
```html
|
20
24
|
<head>
|
21
|
-
|
22
|
-
<%=
|
23
|
-
<%=
|
25
|
+
<%= httpong_scheme 'animal-farm' %>
|
26
|
+
<%= httpong_collection 'pigs', path: '/api/v1/pigs/index', locals: {pigs: @pigs} %>
|
27
|
+
<%= httpong_element 'user', path: '/api/v1/users/me', attributes: {'current-user': true} %>
|
24
28
|
</head>
|
25
29
|
```
|
26
30
|
|
data/lib/httpong/rails.rb
CHANGED
data/lib/httpong/rails/helper.rb
CHANGED
@@ -2,26 +2,47 @@ module HTTPong
|
|
2
2
|
module Rails
|
3
3
|
module Helper
|
4
4
|
def httpong_scheme(name_or_scheme = nil)
|
5
|
-
|
6
|
-
scheme = name_or_scheme
|
7
|
-
elsif name_or_scheme
|
8
|
-
scheme = HTTPong.get_scheme(name_or_scheme)
|
9
|
-
else
|
10
|
-
scheme = HTTPong.default_scheme
|
11
|
-
end
|
5
|
+
scheme = get_scheme_from_name_or_scheme(name_or_scheme)
|
12
6
|
content_tag(:meta, nil, name: 'httpong-scheme', content: scheme.to_json, scheme: scheme.name)
|
13
|
-
# "<meta name='httpong-scheme' content='#{scheme.to_json}' scheme='#{scheme.name}'/>"
|
14
7
|
end
|
15
8
|
|
16
|
-
def httpong_collection(name,
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
9
|
+
def httpong_collection(name, options = {})
|
10
|
+
scheme = get_scheme_from_name_or_scheme(options[:scheme])
|
11
|
+
# options[:locals] ||=
|
12
|
+
throw new StandardError('No path') if !options[:path]
|
13
|
+
attributes = {
|
14
|
+
name: 'httpong-collection',
|
15
|
+
content: h( render(template: options[:path], locals: options[:locals] || {}) ),
|
16
|
+
scheme: scheme.name,
|
17
|
+
collection: name
|
18
|
+
}
|
19
|
+
content_tag(:meta, nil, attributes)
|
20
|
+
end
|
21
|
+
|
22
|
+
def httpong_element(singular_name, options = {})
|
23
|
+
scheme = get_scheme_from_name_or_scheme(options[:scheme])
|
24
|
+
throw new StandardError('No path') if !options[:path]
|
25
|
+
attributes = {
|
26
|
+
name: 'httpong-element',
|
27
|
+
content: h( render(template: options[:path], locals: options[:locals] || {}) ),
|
28
|
+
scheme: scheme.name,
|
29
|
+
collection: singular_name.pluralize
|
30
|
+
}
|
31
|
+
options[:attributes].each do |name, value|
|
32
|
+
attributes[name] = value
|
33
|
+
end
|
34
|
+
content_tag(:meta, nil, attributes)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
def get_scheme_from_name_or_scheme(name_or_scheme)
|
39
|
+
if name_or_scheme.class == HTTPong::Scheme
|
40
|
+
name_or_scheme
|
41
|
+
elsif name_or_scheme
|
42
|
+
HTTPong.get_scheme(name_or_scheme)
|
21
43
|
else
|
22
|
-
|
44
|
+
HTTPong.default_scheme
|
23
45
|
end
|
24
|
-
content_tag(:meta, nil, name: 'httpong-collection', content: raw(render(template: path)), scheme: scheme.name, collection: name)
|
25
46
|
end
|
26
47
|
end
|
27
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httpong-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hans Otto Wirtz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07
|
11
|
+
date: 2016-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- lib/generators/httpong_generator.rb
|
79
79
|
- lib/httpong/rails.rb
|
80
80
|
- lib/httpong/rails/helper.rb
|
81
|
+
- lib/httpong/rails/reloader.rb
|
81
82
|
- lib/httpong/rails/version.rb
|
82
83
|
- lib/tasks/httpong/rails_tasks.rake
|
83
84
|
homepage: https://github.com/hansottowirtz/httpong-rails
|
@@ -105,3 +106,4 @@ signing_key:
|
|
105
106
|
specification_version: 4
|
106
107
|
summary: HTTPong for Rails
|
107
108
|
test_files: []
|
109
|
+
has_rdoc:
|