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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 07294314006ad4217991f4b26ff1040cbe0fb67b
4
- data.tar.gz: 8b0b554d67165c9b4ccd49f79bbcee5431ab3399
3
+ metadata.gz: 78da025443869396966e37d63dd39b84478da386
4
+ data.tar.gz: a87ffc1a2569bea18154138d4d80c725b1ad446d
5
5
  SHA512:
6
- metadata.gz: c2795266f07d5a29c4a31df12f769f95b42924c94db9316143de48e360b71bb9daadde920156c1427c8d388891711416d25110ec5ef064d1ff1ba609e4ac70b1
7
- data.tar.gz: 029fb948f604ac22484b7ae9eb8dd11b1df98171b4cc42a5f08936acbe1fab33258e5a43448a66bc93f6e50750a06682a07764808fbf47c5a665ab9f195cb6e2
6
+ metadata.gz: 73288066bc8c3d3b3ece1e395bd9b20c32fcd0adaac3d37fca844fcd854a40257db9f03cb005fba0b5d331dea1ce6838c28fb220d608bf08703987913a72e42d
7
+ data.tar.gz: afd244b9f61afcdb8dc3f2116216d77bd69005b46ab4c053f9711c9933f06c052be9834b764ac5cfed576112a312043d1569abb935f9793e602ba8f24ca2bd1d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ # v0.2.0
4
+
5
+ * Better error handling for missing templates
6
+
3
7
  # v0.1.0
4
8
 
5
9
  * Initial release
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Style Guide API
2
2
 
3
- TODO: Write a gem description
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
@@ -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"][name]
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
@@ -1,3 +1,3 @@
1
1
  module StyleGuideAPI
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -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
@@ -28,6 +28,11 @@ describe StyleGuideAPI do
28
28
  HTML
29
29
  end
30
30
 
31
+ it "should fail with a helpful error when the template is not known" do
32
+ assert_raises StyleGuideAPI::UnknownTemplateError do
33
+ StyleGuideAPI.render("does_not_exist")
34
+ end
35
+ end
31
36
  end
32
37
 
33
38
  end
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.1.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-10 00:00:00.000000000 Z
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