inline_template_loader 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ *.swp
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ vendor/bundle
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ -c -fd
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+
5
+ script: 'bundle exec rspec'
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard 'rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Yuya Takeyama
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.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # InlineTemplateLoader
2
+
3
+ Loads Sinatraish inline template
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'inline_template_loader'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install inline_template_loader
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ require 'inline_template_loader'
23
+
24
+ templates = InlineTemplateLoader.load
25
+
26
+ puts templates[:foo]
27
+ puts templates[:bar]
28
+
29
+ __END__
30
+
31
+ @@ foo
32
+ <p>Here is the template named foo</p>
33
+
34
+ @@ bar
35
+ <p>Here is the template named bar</p>
36
+ ```
37
+
38
+ ## Contributing
39
+
40
+ 1. Fork it
41
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
42
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
43
+ 4. Push to the branch (`git push origin my-new-feature`)
44
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ require 'inline_template_loader'
2
+
3
+ templates = InlineTemplateLoader.load
4
+
5
+ puts templates[:foo]
6
+ puts templates[:bar]
7
+
8
+ __END__
9
+
10
+ @@ foo
11
+ <p>Here is the template named foo</p>
12
+
13
+ @@ bar
14
+ <p>Here is the template named bar</p>
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/inline_template_loader/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Yuya Takeyama"]
6
+ gem.email = ["sign.of.the.wolf.pentagram@gmail.com"]
7
+ gem.description = %q{Loads inline template as a Hash}
8
+ gem.summary = %q{Loads inline template as a Hash}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "inline_template_loader"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = InlineTemplateLoader::VERSION
17
+
18
+ gem.add_development_dependency('rspec', '~> 2.13.0')
19
+ gem.add_development_dependency('guard-rspec', '~> 2.5.0')
20
+ gem.add_development_dependency('rb-readline', '~> 0.4.2')
21
+ gem.add_development_dependency('rb-fsevent', '~> 0.9')
22
+ end
@@ -0,0 +1,3 @@
1
+ module InlineTemplateLoader
2
+ VERSION = "0.2.0"
3
+ end
@@ -0,0 +1,30 @@
1
+ require "inline_template_loader/version"
2
+
3
+ module InlineTemplateLoader
4
+ def self.load(file = nil)
5
+ if file.nil?
6
+ file = caller.first.split(':').first
7
+ end
8
+
9
+ templates = {}
10
+ sym = nil
11
+
12
+ app, data = ::IO.read(file).gsub("\r\n", "\n").split(/^__END__$/, 2)
13
+
14
+ data.each_line do |line|
15
+ if line =~ /^@@\s*(.*\S)\s*$/
16
+ sym = $1.to_sym
17
+ else
18
+ if sym
19
+ unless templates[sym]
20
+ templates[sym] = line
21
+ else
22
+ templates[sym] += line
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ templates
29
+ end
30
+ end
@@ -0,0 +1,29 @@
1
+ require 'inline_template_loader'
2
+
3
+ describe 'InlineTemplateLoader' do
4
+ describe '#load' do
5
+ shared_examples_for 'load templates correctly from this file' do
6
+ it { should == {foo: "Here is template named foo.\n\n", bar: "Here is template named bar.\n"} }
7
+ end
8
+
9
+ context 'with filepath' do
10
+ subject { InlineTemplateLoader.load(__FILE__) }
11
+
12
+ it_behaves_like 'load templates correctly from this file'
13
+ end
14
+
15
+ context 'without filepath' do
16
+ subject { InlineTemplateLoader.load }
17
+
18
+ it_behaves_like 'load templates correctly from this file'
19
+ end
20
+ end
21
+ end
22
+
23
+ __END__
24
+
25
+ @@ foo
26
+ Here is template named foo.
27
+
28
+ @@ bar
29
+ Here is template named bar.
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: inline_template_loader
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Yuya Takeyama
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.13.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 2.13.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: guard-rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 2.5.0
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.5.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: rb-readline
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.4.2
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.4.2
62
+ - !ruby/object:Gem::Dependency
63
+ name: rb-fsevent
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '0.9'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '0.9'
78
+ description: Loads inline template as a Hash
79
+ email:
80
+ - sign.of.the.wolf.pentagram@gmail.com
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - .gitignore
86
+ - .rspec
87
+ - .travis.yml
88
+ - Gemfile
89
+ - Guardfile
90
+ - LICENSE
91
+ - README.md
92
+ - Rakefile
93
+ - examples/example.rb
94
+ - inline_template_loader.gemspec
95
+ - lib/inline_template_loader.rb
96
+ - lib/inline_template_loader/version.rb
97
+ - spec/lib/inline_template_loader_spec.rb
98
+ homepage: ''
99
+ licenses: []
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ segments:
111
+ - 0
112
+ hash: -3902848851121274865
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ segments:
120
+ - 0
121
+ hash: -3902848851121274865
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 1.8.23
125
+ signing_key:
126
+ specification_version: 3
127
+ summary: Loads inline template as a Hash
128
+ test_files:
129
+ - spec/lib/inline_template_loader_spec.rb