goatee 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e4968c0c33b69b0e7fca62a45dfabc9ea3225d8f
4
+ data.tar.gz: 1de1c6fc689a76ac14c855a8785370236ca83335
5
+ SHA512:
6
+ metadata.gz: 83d1e05555a2629409b7cc02356c94bb19f18d637411fc6cd0738203245d692c0b0f8e3f08390203f541ad702415d14f3d7c46998a2f9057acd32c6ddd459f09
7
+ data.tar.gz: 362ee9765dcc39b503de16de89ff7f0f1551ac6b36a45cdd156b9c5909c93c3c3f6e81cd759b4c2dc8a80888966132989943d943dd21c710d1c3f90bd6393cd3
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /test.rb
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ <h1 align="center">Goatee</h1>
2
+
3
+ <p align="center">
4
+ <a href="https://rubygems.org/gems/goatee">
5
+ <img src="https://img.shields.io/gem/v/goatee.svg?style=flat-square">
6
+ </a>
7
+ </p>
8
+
9
+ ### What?
10
+
11
+ Inspired by [mustache](https://github.com/mustache/mustache). **Goatee** wraps ERB to provide a framework-agnostic method of rendering views.
12
+
13
+ ### Config
14
+
15
+ ```ruby
16
+ # TODO
17
+ ```
18
+
19
+ ### Credits
20
+
21
+ - [@revett](https://github.com/revett)
22
+ - [@alexnorton](https://github.com/alexnorton)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/circle.yml ADDED
@@ -0,0 +1,11 @@
1
+ machine:
2
+ ruby:
3
+ version: 2.3.0
4
+
5
+ dependencies:
6
+ override:
7
+ - bundle install --jobs 4
8
+
9
+ test:
10
+ override:
11
+ - bundle exec rspec spec/
data/goatee.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "goatee/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "goatee"
8
+ spec.version = Goatee::VERSION
9
+ spec.authors = ["Charlie Revett"]
10
+ spec.email = ["charlie@vidsy.co"]
11
+
12
+ spec.summary = "**Goatee** wraps ERB to provide a framework-agnostic method of rendering views."
13
+
14
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|circle.yml|Rakefile)/}) }
15
+ spec.bindir = "exe"
16
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.9"
20
+ spec.add_development_dependency "rake", "~> 10.0"
21
+ spec.add_development_dependency "rspec", "~> 3.0"
22
+
23
+ spec.add_dependency "json"
24
+ end
@@ -0,0 +1,12 @@
1
+ module Goatee
2
+ class Configuration
3
+ class << self
4
+ attr_accessor :templates_directory
5
+
6
+ def configure(&block)
7
+ yield self
8
+ self
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ module Goatee
2
+ module Error
3
+ class TemplateNotFound < StandardError
4
+ def initialize(path)
5
+ super("Expecting template at path: '#{path}'")
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Goatee
2
+ VERSION = "0.0.1".freeze
3
+ end
@@ -0,0 +1,59 @@
1
+ require "goatee/configuration"
2
+ require "goatee/error/template_not_found"
3
+
4
+ module Goatee
5
+ class View
6
+ protected
7
+
8
+ def include(template_id)
9
+ render_template("includes/#{template_id}")
10
+ end
11
+
12
+ def render(template_id)
13
+ render_template(template_id)
14
+ end
15
+
16
+ private
17
+
18
+ def configuration
19
+ Configuration
20
+ end
21
+
22
+ def exist?(template_id)
23
+ File.exist?(
24
+ path_to_template(template_id)
25
+ )
26
+ end
27
+
28
+ def path_to_template(template_id)
29
+ File.join(
30
+ templates_directory,
31
+ "#{template_id}.erb"
32
+ )
33
+ end
34
+
35
+ def read_file(template_id)
36
+ File.read(
37
+ path_to_template(template_id)
38
+ )
39
+ end
40
+
41
+ def render_template(template_id)
42
+ template_not_found(template_id) unless exist?(template_id)
43
+
44
+ ERB.new(
45
+ read_file(template_id)
46
+ ).result binding
47
+ end
48
+
49
+ def templates_directory
50
+ configuration.templates_directory
51
+ end
52
+
53
+ def template_not_found(template_id)
54
+ raise Error::TemplateNotFound.new(
55
+ path_to_template(template_id)
56
+ )
57
+ end
58
+ end
59
+ end
data/lib/goatee.rb ADDED
@@ -0,0 +1,9 @@
1
+ require "goatee/configuration"
2
+ require "goatee/version"
3
+ require "goatee/view"
4
+
5
+ module Goatee
6
+ def self.configure(&block)
7
+ Configuration.configure(&block)
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: goatee
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Charlie Revett
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-04-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - charlie@vidsy.co
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - README.md
79
+ - Rakefile
80
+ - circle.yml
81
+ - goatee.gemspec
82
+ - lib/goatee.rb
83
+ - lib/goatee/configuration.rb
84
+ - lib/goatee/error/template_not_found.rb
85
+ - lib/goatee/version.rb
86
+ - lib/goatee/view.rb
87
+ homepage:
88
+ licenses: []
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.5.1
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: "**Goatee** wraps ERB to provide a framework-agnostic method of rendering
110
+ views."
111
+ test_files: []