vrb 0.1.2
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.gitmodules +3 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +78 -0
- data/Rakefile +6 -0
- data/lib/vrb.rb +42 -0
- data/lib/vrb/version.rb +3 -0
- data/sample/sample.erb +2 -0
- data/sample/sample.rb +39 -0
- data/sample/sample.txt +1 -0
- data/sample/sample_error.erb +1 -0
- data/vrb.gemspec +23 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7b30579e2b31c35fbced0a4cb6ac8434fe6e0a4c
|
4
|
+
data.tar.gz: 87578776b1ed373aaaa72e15da248dffcaf089a4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d9258aeafbee417af668f1534c8f8b1ac1148ccbc386291cb27ca0c4e131b96ac994bfd3163016cfd17c9ac7be80d69a2ad0a7c161b1509e1fa0d12fa6296e6b
|
7
|
+
data.tar.gz: 629b4556964b4fa80095e37952f8d2e3f0932827d284fefb43575706baf4f6bf981a6f11db0398b0f0f453472323b6db8c0730512ce95ede29916c8acad078d0
|
data/.gitignore
ADDED
data/.gitmodules
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 liveralmask
|
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,78 @@
|
|
1
|
+
# VRB
|
2
|
+
|
3
|
+
MVC of View for Ruby
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'vrb'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install vrb
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
[sample.rb]
|
22
|
+
|
23
|
+
require "vrb"
|
24
|
+
|
25
|
+
class Sample < VRB
|
26
|
+
def view_txt( text )
|
27
|
+
"txt:#{text}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def view_erb( text )
|
31
|
+
"erb:#{super( text )}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def view( path )
|
35
|
+
"sample:#{super( path )}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def output
|
39
|
+
@version = 1.0
|
40
|
+
|
41
|
+
puts view( "./sample.erb" )
|
42
|
+
=begin
|
43
|
+
sample:erb:1.0
|
44
|
+
sample:txt:2.0
|
45
|
+
=end
|
46
|
+
|
47
|
+
puts view( "./sample" )
|
48
|
+
=begin
|
49
|
+
sample:File Read Error: ./sample
|
50
|
+
=end
|
51
|
+
|
52
|
+
puts view( "./sample_error.erb" )
|
53
|
+
=begin
|
54
|
+
sample:View Error: ./sample_error.erb
|
55
|
+
undefined local variable or method `error' for #XXX
|
56
|
+
(erb):1:in `view_erb'
|
57
|
+
=end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
Sample.new.output
|
62
|
+
|
63
|
+
[sample.erb]
|
64
|
+
|
65
|
+
<%= @version %>
|
66
|
+
<%= view( "./sample.txt" ) %>
|
67
|
+
|
68
|
+
[sample.txt]
|
69
|
+
|
70
|
+
2.0
|
71
|
+
|
72
|
+
## Contributing
|
73
|
+
|
74
|
+
1. Fork it
|
75
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
76
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
77
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
78
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/vrb.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require "vrb/version"
|
2
|
+
require "erb"
|
3
|
+
|
4
|
+
class VRB
|
5
|
+
def initialize
|
6
|
+
@view_erb_count = 0
|
7
|
+
end
|
8
|
+
|
9
|
+
def view( path )
|
10
|
+
text = ""
|
11
|
+
|
12
|
+
Dir.chdir( File.dirname( path ) ){
|
13
|
+
begin
|
14
|
+
text = File.read( path )
|
15
|
+
rescue
|
16
|
+
return "File Read Error: #{path}"
|
17
|
+
end
|
18
|
+
|
19
|
+
ext = File.extname( path )
|
20
|
+
func_name = "view#{ext.gsub( /\./, '_' )}"
|
21
|
+
|
22
|
+
begin
|
23
|
+
text = self.send( func_name, text ) if self.respond_to?( func_name )
|
24
|
+
rescue => err
|
25
|
+
return <<EOS
|
26
|
+
View Error: #{path}
|
27
|
+
#{err.message}
|
28
|
+
#{err.backtrace.first}
|
29
|
+
EOS
|
30
|
+
end
|
31
|
+
}
|
32
|
+
|
33
|
+
text
|
34
|
+
end
|
35
|
+
|
36
|
+
def view_erb( text )
|
37
|
+
@view_erb_count += 1
|
38
|
+
result = ERB.new( text, nil, "-", "_erbout_#{@view_erb_count}" ).result( binding )
|
39
|
+
@view_erb_count -= 1
|
40
|
+
result
|
41
|
+
end
|
42
|
+
end
|
data/lib/vrb/version.rb
ADDED
data/sample/sample.erb
ADDED
data/sample/sample.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require "vrb"
|
2
|
+
|
3
|
+
class Sample < VRB
|
4
|
+
def view_txt( text )
|
5
|
+
"txt:#{text}"
|
6
|
+
end
|
7
|
+
|
8
|
+
def view_erb( text )
|
9
|
+
"erb:#{super( text )}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def view( path )
|
13
|
+
"sample:#{super( path )}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def output
|
17
|
+
@version = 1.0
|
18
|
+
|
19
|
+
puts view( "./sample.erb" )
|
20
|
+
=begin
|
21
|
+
sample:erb:1.0
|
22
|
+
sample:txt:2.0
|
23
|
+
=end
|
24
|
+
|
25
|
+
puts view( "./sample" )
|
26
|
+
=begin
|
27
|
+
sample:File Read Error: ./sample
|
28
|
+
=end
|
29
|
+
|
30
|
+
puts view( "./sample_error.erb" )
|
31
|
+
=begin
|
32
|
+
sample:View Error: ./sample_error.erb
|
33
|
+
undefined local variable or method `error' for #XXX
|
34
|
+
(erb):1:in `view_erb'
|
35
|
+
=end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Sample.new.output
|
data/sample/sample.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= error %>
|
data/vrb.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vrb/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vrb"
|
8
|
+
spec.version = VRB::VERSION
|
9
|
+
spec.authors = ["liveralmask"]
|
10
|
+
spec.email = ["liveralmask.lisk@gmail.com"]
|
11
|
+
spec.description = %q{MVC of View for Ruby}
|
12
|
+
spec.summary = %q{View Ruby}
|
13
|
+
spec.homepage = "https://github.com/liveralmask/vrb"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake", "~> 0"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vrb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- liveralmask
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-29 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: MVC of View for Ruby
|
42
|
+
email:
|
43
|
+
- liveralmask.lisk@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".gitmodules"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/vrb.rb
|
55
|
+
- lib/vrb/version.rb
|
56
|
+
- sample/sample.erb
|
57
|
+
- sample/sample.rb
|
58
|
+
- sample/sample.txt
|
59
|
+
- sample/sample_error.erb
|
60
|
+
- vrb.gemspec
|
61
|
+
homepage: https://github.com/liveralmask/vrb
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.2.0
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: View Ruby
|
85
|
+
test_files: []
|