blockpile 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/MIT-LICENSE +20 -0
- data/README +13 -0
- data/Rakefile +39 -0
- data/VERSION +1 -0
- data/blockpile.gemspec +55 -0
- data/lib/blockpile/base.rb +31 -0
- data/lib/blockpile/setup.rb +18 -0
- data/lib/blockpile.rb +17 -0
- data/lib/generators/blockpile/USAGE +8 -0
- data/lib/generators/blockpile/blockpile_generator.rb +19 -0
- data/lib/generators/blockpile/templates/blockpile.html.erb +0 -0
- data/lib/generators/blockpile/templates/blockpile.rb +7 -0
- data/lib/tasks/blockpile_tasks.rake +4 -0
- data/test/blockpile_test.rb +8 -0
- data/test/test_helper.rb +3 -0
- metadata +79 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 [name of plugin creator]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the blockpile plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.libs << 'test'
|
12
|
+
t.pattern = 'test/**/*_test.rb'
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate documentation for the blockpile plugin.'
|
17
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'Blockpile'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
+
rdoc.rdoc_files.include('README')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
24
|
+
|
25
|
+
begin
|
26
|
+
require 'jeweler'
|
27
|
+
Jeweler::Tasks.new do |gemspec|
|
28
|
+
gemspec.name = "blockpile"
|
29
|
+
gemspec.summary = "piles of extendable rails view blocks, triggered and masked behind simple helpers"
|
30
|
+
gemspec.description = "This module attempts to create structured view helpers. Essentially, a blockpile consists of a ruby class file, and a template. This allows for isolated blocks of view logic, that can maintain a clean separation of markup language from ruby code. Blocks can be inherited from to DRY up view logic."
|
31
|
+
gemspec.email = "tylerflint@gmail.com"
|
32
|
+
gemspec.homepage = "http://github.com/tylerflint/blockpile"
|
33
|
+
gemspec.authors = ["Tyler Flint"]
|
34
|
+
end
|
35
|
+
Jeweler::GemcutterTasks.new
|
36
|
+
rescue LoadError
|
37
|
+
puts "Jeweler not available. Install it with: gem install jeweler"
|
38
|
+
end
|
39
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
data/blockpile.gemspec
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{blockpile}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Tyler Flint"]
|
12
|
+
s.date = %q{2010-08-08}
|
13
|
+
s.description = %q{This module attempts to create structured view helpers. Essentially, a blockpile consists of a ruby class file, and a template. This allows for isolated blocks of view logic, that can maintain a clean separation of markup language from ruby code. Blocks can be inherited from to DRY up view logic.}
|
14
|
+
s.email = %q{tylerflint@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"MIT-LICENSE",
|
20
|
+
"README",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"blockpile.gemspec",
|
24
|
+
"lib/blockpile.rb",
|
25
|
+
"lib/blockpile/base.rb",
|
26
|
+
"lib/blockpile/setup.rb",
|
27
|
+
"lib/generators/blockpile/USAGE",
|
28
|
+
"lib/generators/blockpile/blockpile_generator.rb",
|
29
|
+
"lib/generators/blockpile/templates/blockpile.html.erb",
|
30
|
+
"lib/generators/blockpile/templates/blockpile.rb",
|
31
|
+
"lib/tasks/blockpile_tasks.rake",
|
32
|
+
"test/blockpile_test.rb",
|
33
|
+
"test/test_helper.rb"
|
34
|
+
]
|
35
|
+
s.homepage = %q{http://github.com/tylerflint/blockpile}
|
36
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
s.rubygems_version = %q{1.3.7}
|
39
|
+
s.summary = %q{piles of extendable rails view blocks, triggered and masked behind simple helpers}
|
40
|
+
s.test_files = [
|
41
|
+
"test/blockpile_test.rb",
|
42
|
+
"test/test_helper.rb"
|
43
|
+
]
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
47
|
+
s.specification_version = 3
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
+
else
|
51
|
+
end
|
52
|
+
else
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class Blockpile::Base
|
2
|
+
|
3
|
+
def initialize(helper, session, params, template, *args)
|
4
|
+
@helper = helper
|
5
|
+
@session = session
|
6
|
+
@params = params
|
7
|
+
@template = template
|
8
|
+
build *args
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_html
|
12
|
+
render_template @template
|
13
|
+
end
|
14
|
+
|
15
|
+
def build
|
16
|
+
# override this method to build your block
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
# Assumes /views/helper/ as base
|
22
|
+
def render_template(template)
|
23
|
+
@path ||= '/app/views/blockpiles/'
|
24
|
+
ERB.new( File.read(Rails.root.to_s + @path + template + ".html.erb") ).result binding
|
25
|
+
end
|
26
|
+
|
27
|
+
def method_missing(*args, &block)
|
28
|
+
@helper.send(*args, &block)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Blockpile
|
2
|
+
module Setup
|
3
|
+
def self.add_load_path(path)
|
4
|
+
ActiveSupport::Dependencies.autoload_paths << path
|
5
|
+
Dir.glob(path + "*.rb") do |file|
|
6
|
+
file_name = file.split(/\//).pop.gsub(/.rb/, '')
|
7
|
+
class_name = file_name.classify
|
8
|
+
ActionView::Base.class_eval %{
|
9
|
+
def #{file_name}(*args, &block)
|
10
|
+
block = #{class_name}.new(self, session, params, '#{file_name}', *args)
|
11
|
+
yield block
|
12
|
+
raw block.to_html
|
13
|
+
end
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/blockpile.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require 'blockpile/setup'
|
3
|
+
require 'blockpile/base'
|
4
|
+
|
5
|
+
module Blockpile
|
6
|
+
class Railtie < Rails::Railtie
|
7
|
+
initializer "blockpile.setup default directories" do
|
8
|
+
Blockpile.setup do |config|
|
9
|
+
config.add_load_path Rails.root.to_s + '/app/helpers/blockpiles/'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.setup
|
15
|
+
yield Blockpile::Setup
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class BlockpileGenerator < Rails::Generators::NamedBase
|
2
|
+
source_root File.expand_path('../templates', __FILE__)
|
3
|
+
|
4
|
+
def generate
|
5
|
+
template "blockpile.rb", "app/helpers/blockpiles/#{file_name}.rb"
|
6
|
+
copy_file "blockpile.html.erb", "app/views/blockpiles/#{file_name}.html.erb"
|
7
|
+
end
|
8
|
+
|
9
|
+
protected
|
10
|
+
|
11
|
+
def file_name
|
12
|
+
name.underscore
|
13
|
+
end
|
14
|
+
|
15
|
+
def class_name
|
16
|
+
name.classify
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
File without changes
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: blockpile
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Tyler Flint
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-08-08 00:00:00 -06:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: This module attempts to create structured view helpers. Essentially, a blockpile consists of a ruby class file, and a template. This allows for isolated blocks of view logic, that can maintain a clean separation of markup language from ruby code. Blocks can be inherited from to DRY up view logic.
|
22
|
+
email: tylerflint@gmail.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- README
|
29
|
+
files:
|
30
|
+
- MIT-LICENSE
|
31
|
+
- README
|
32
|
+
- Rakefile
|
33
|
+
- VERSION
|
34
|
+
- blockpile.gemspec
|
35
|
+
- lib/blockpile.rb
|
36
|
+
- lib/blockpile/base.rb
|
37
|
+
- lib/blockpile/setup.rb
|
38
|
+
- lib/generators/blockpile/USAGE
|
39
|
+
- lib/generators/blockpile/blockpile_generator.rb
|
40
|
+
- lib/generators/blockpile/templates/blockpile.html.erb
|
41
|
+
- lib/generators/blockpile/templates/blockpile.rb
|
42
|
+
- lib/tasks/blockpile_tasks.rake
|
43
|
+
- test/blockpile_test.rb
|
44
|
+
- test/test_helper.rb
|
45
|
+
has_rdoc: true
|
46
|
+
homepage: http://github.com/tylerflint/blockpile
|
47
|
+
licenses: []
|
48
|
+
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options:
|
51
|
+
- --charset=UTF-8
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
requirements: []
|
71
|
+
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 1.3.7
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: piles of extendable rails view blocks, triggered and masked behind simple helpers
|
77
|
+
test_files:
|
78
|
+
- test/blockpile_test.rb
|
79
|
+
- test/test_helper.rb
|