styleguide-api 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +3 -1
- data/lib/styleguide-api.rb +13 -1
- data/lib/styleguide-api/version.rb +1 -1
- data/styleguide-api.gemspec +1 -0
- data/test/render_test.rb +5 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78da025443869396966e37d63dd39b84478da386
|
4
|
+
data.tar.gz: a87ffc1a2569bea18154138d4d80c725b1ad446d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73288066bc8c3d3b3ece1e395bd9b20c32fcd0adaac3d37fca844fcd854a40257db9f03cb005fba0b5d331dea1ce6838c28fb220d608bf08703987913a72e42d
|
7
|
+
data.tar.gz: afd244b9f61afcdb8dc3f2116216d77bd69005b46ab4c053f9711c9933f06c052be9834b764ac5cfed576112a312043d1569abb935f9793e602ba8f24ca2bd1d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Style Guide API
|
2
2
|
|
3
|
-
|
3
|
+
This Gem will turn your style guide into an API by providing all templates to consuming applications via JSON.
|
4
|
+
|
5
|
+
It supports all templating engines supported by [Tilt](https://github.com/rtomayko/tilt#readme) such as ERB and Haml.
|
4
6
|
|
5
7
|
|
6
8
|
## Installation
|
data/lib/styleguide-api.rb
CHANGED
@@ -10,6 +10,16 @@ module StyleGuideAPI
|
|
10
10
|
attr_accessor :theme
|
11
11
|
end
|
12
12
|
|
13
|
+
class UnknownTemplateError < StandardError
|
14
|
+
def initialize(template_name)
|
15
|
+
@template_name = template_name
|
16
|
+
end
|
17
|
+
|
18
|
+
def message
|
19
|
+
"Template '#{@template_name}' is not known."
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
13
23
|
def self.initialize
|
14
24
|
@live = false
|
15
25
|
@templates = {}
|
@@ -51,7 +61,9 @@ module StyleGuideAPI
|
|
51
61
|
|
52
62
|
def self.template_for(name)
|
53
63
|
@templates[theme][name] if @templates[theme] && @templates[theme][name]
|
54
|
-
template = data[theme]["templates"]
|
64
|
+
template = data[theme]["templates"].fetch(name) do
|
65
|
+
fail UnknownTemplateError, name
|
66
|
+
end
|
55
67
|
@templates[theme] ||= {}
|
56
68
|
@templates[theme][name] = Tilt[template["type"]].new { template["source"] }
|
57
69
|
end
|
data/styleguide-api.gemspec
CHANGED
@@ -23,5 +23,6 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.7"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
25
|
spec.add_development_dependency "minitest"
|
26
|
+
spec.add_development_dependency "haml"
|
26
27
|
spec.add_development_dependency "heredoc_unindent"
|
27
28
|
end
|
data/test/render_test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: styleguide-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nico Hagenburger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tilt
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: haml
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: heredoc_unindent
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|