alephant-renderer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e22139dfc1e97138eb2a3ddcdb39f408255ce81b
4
+ data.tar.gz: c627489d2092e3414562e9e7fc3a9a1ff3b5d6b3
5
+ SHA512:
6
+ metadata.gz: 134a33c4a1f67b96019082f7c7e01e12b15e831e60dcb80ecbcf37afb090b5dc3e1b6e31fc52b0cdc083a228559bf469548c32f7eb7dba407aee8cfa6c5e7106
7
+ data.tar.gz: 62a7e0496e498da2adcef46f825a4d463a841cf0cb0158a683f76fbba94d52317f52918e2b445b3b496e390d502df8a513b7c56d8cc81be38f94a5811259f1d5
@@ -0,0 +1,10 @@
1
+ /config/*.yaml
2
+ /config/*.yml
3
+ Gemfile.lock
4
+ .rspec
5
+ *.gem
6
+
7
+ /pkg
8
+ /tmp
9
+ /components
10
+
@@ -0,0 +1 @@
1
+ jruby-1.7.9
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - "jruby"
4
+ notifications:
5
+ email:
6
+ recipients:
7
+ - kenoir@gmail.com
8
+ on_failure: change
9
+ on_success: never
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in alephant-renderer.gemspec
4
+ gemspec
@@ -0,0 +1,6 @@
1
+ guard 'rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/.+\.rb$})
4
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
5
+ watch('spec/spec_helper.rb') { "spec" }
6
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Robert Kenny
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,37 @@
1
+ # Alephant::Renderer
2
+
3
+ Render HTML snippets
4
+
5
+ [![Build Status](https://travis-ci.org/BBC-News/alephant-renderer.png?branch=master)](https://travis-ci.org/BBC-News/alephant-renderer)
6
+
7
+ [![Gem Version](https://badge.fury.io/rb/alephant-renderer.png)](http://badge.fury.io/rb/alephant-renderer)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'alephant-renderer'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install alephant-renderer
22
+
23
+ ## Usage
24
+
25
+ ```rb
26
+ require 'alephant/renderer'
27
+
28
+ Alephant::Renderer.create('foo_template', '/base/path', 'foo_model')
29
+ ```
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it ( http://github.com/<my-github-username>/alephant-renderer/fork )
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create new Pull Request
@@ -0,0 +1,9 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), 'lib')
2
+
3
+ require 'rspec/core/rake_task'
4
+ require 'bundler/gem_tasks'
5
+ require 'alephant/renderer'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ task :default => :spec
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'alephant/renderer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "alephant-renderer"
8
+ spec.version = Alephant::Renderer::VERSION
9
+ spec.authors = ["Robert Kenny"]
10
+ spec.email = ["kenoir@gmail.com"]
11
+ spec.summary = "Render HTML snippets"
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "rspec"
21
+ spec.add_development_dependency "rspec-nc"
22
+ spec.add_development_dependency "guard"
23
+ spec.add_development_dependency "guard-rspec"
24
+ spec.add_development_dependency "pry"
25
+ spec.add_development_dependency "pry-remote"
26
+ spec.add_development_dependency "pry-nav"
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.5"
29
+ spec.add_development_dependency "rake"
30
+ end
@@ -0,0 +1,12 @@
1
+ require 'alephant/renderer/version'
2
+ require 'alephant/renderer/engines/mustache'
3
+
4
+ module Alephant
5
+ module Renderer
6
+
7
+ def self.create(*args)
8
+ Mustache.new(*args)
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,38 @@
1
+ require 'alephant/logger'
2
+ require 'mustache'
3
+
4
+ module Alephant
5
+ module Renderer
6
+ class Mustache
7
+ include ::Alephant::Logger
8
+
9
+ attr_reader :template_file
10
+
11
+ def initialize(template_file, base_path, model)
12
+ @template_file = template_file
13
+ @base_path = base_path
14
+ @model = model
15
+
16
+ logger.info("Renderer.initialize: end with @base_path set to #{@base_path}")
17
+ end
18
+
19
+ def render
20
+ logger.info("Renderer.render: rendered template #{template_file}")
21
+ ::Mustache.render(template, @model)
22
+ end
23
+
24
+ def template
25
+ template_location = File.join(@base_path, 'templates', "#{template_file}.mustache")
26
+
27
+ begin
28
+ logger.info("Renderer.template: #{template_location}")
29
+ File.open(template_location).read
30
+ rescue Exception => e
31
+ logger.error("Renderer.template: view template #{template_file} not found")
32
+ end
33
+ end
34
+ end
35
+
36
+ end
37
+ end
38
+
@@ -0,0 +1,5 @@
1
+ module Alephant
2
+ module Renderer
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ module MyApp
2
+ class FooFoo < ::Alephant::Views::Base
3
+ def content
4
+ "content"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ describe Alephant::Renderer do
4
+ let(:template_file) { 'foo' }
5
+ let(:base_path) { :base_path }
6
+ let(:model) { :model }
7
+
8
+ before(:each) do
9
+ @base_path = File.join(
10
+ File.dirname(__FILE__),
11
+ 'fixtures',
12
+ 'components',
13
+ 'foo'
14
+ )
15
+ end
16
+
17
+ describe ".create(template_file, base_path, model)" do
18
+ it "returns a Alephant::Renderer::Mustache" do
19
+ expect(subject.create(template_file, base_path, model)).to be_a Alephant::Renderer::Mustache
20
+ end
21
+ end
22
+
23
+ describe Alephant::Renderer::Mustache do
24
+ subject { Alephant::Renderer::Mustache }
25
+ describe "initialize(template_file, base_path, model)" do
26
+ context "template_file = :template_file" do
27
+ it "sets the attribute template_file" do
28
+ expect(subject.new(template_file, base_path, model).template_file).to eq(template_file)
29
+ end
30
+ end
31
+ end
32
+
33
+ describe "template()" do
34
+ it "returns the template" do
35
+ instance = subject.new(template_file, @base_path, model)
36
+ template = instance.template
37
+ expect(template).to eq("{{content}}\n")
38
+ end
39
+ end
40
+
41
+ describe "render()" do
42
+ it 'renders a template returned from template(template_file)' do
43
+ ::Mustache
44
+ .any_instance
45
+ .stub(:render)
46
+ .with(:template, :model)
47
+ .and_return(:content)
48
+
49
+ Alephant::Renderer::Mustache
50
+ .any_instance
51
+ .stub(:template)
52
+ .and_return(:template)
53
+
54
+ expect(subject.new(template_file, @base_path, model).render).to eq(:content)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,5 @@
1
+ $: << File.join(File.dirname(__FILE__),"..", "lib")
2
+
3
+ require 'pry'
4
+ require 'alephant/renderer'
5
+
metadata ADDED
@@ -0,0 +1,192 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alephant-renderer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Robert Kenny
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ requirement: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - '>='
23
+ - !ruby/object:Gem::Version
24
+ version: '0'
25
+ prerelease: false
26
+ type: :development
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec-nc
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ prerelease: false
40
+ type: :development
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ prerelease: false
54
+ type: :development
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ prerelease: false
68
+ type: :development
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ prerelease: false
82
+ type: :development
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-remote
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirement: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ prerelease: false
96
+ type: :development
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry-nav
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirement: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ prerelease: false
110
+ type: :development
111
+ - !ruby/object:Gem::Dependency
112
+ name: bundler
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '1.5'
118
+ requirement: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ~>
121
+ - !ruby/object:Gem::Version
122
+ version: '1.5'
123
+ prerelease: false
124
+ type: :development
125
+ - !ruby/object:Gem::Dependency
126
+ name: rake
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirement: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ prerelease: false
138
+ type: :development
139
+ description:
140
+ email:
141
+ - kenoir@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - .gitignore
147
+ - .ruby-version
148
+ - .travis.yml
149
+ - Gemfile
150
+ - Guardfile
151
+ - LICENSE.txt
152
+ - README.md
153
+ - Rakefile
154
+ - alephant-renderer.gemspec
155
+ - lib/alephant/renderer.rb
156
+ - lib/alephant/renderer/engines/mustache.rb
157
+ - lib/alephant/renderer/version.rb
158
+ - spec/fixtures/components/foo/models/foo.rb
159
+ - spec/fixtures/components/foo/templates/bar.mustache
160
+ - spec/fixtures/components/foo/templates/foo.mustache
161
+ - spec/renderer_spec.rb
162
+ - spec/spec_helper.rb
163
+ homepage: ''
164
+ licenses:
165
+ - MIT
166
+ metadata: {}
167
+ post_install_message:
168
+ rdoc_options: []
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '>='
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ requirements: []
182
+ rubyforge_project:
183
+ rubygems_version: 2.1.9
184
+ signing_key:
185
+ specification_version: 4
186
+ summary: Render HTML snippets
187
+ test_files:
188
+ - spec/fixtures/components/foo/models/foo.rb
189
+ - spec/fixtures/components/foo/templates/bar.mustache
190
+ - spec/fixtures/components/foo/templates/foo.mustache
191
+ - spec/renderer_spec.rb
192
+ - spec/spec_helper.rb