dapper 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .DS_Store
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in dapper.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Jefferson Carley
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,29 @@
1
+ # Dapper
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'dapper'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install dapper
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/dapper/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Jefferson Carley"]
6
+ gem.email = ["jeff.carley@gmail.com"]
7
+ gem.description = %q{A gem for using presenters in your rails application.}
8
+ gem.summary = %q{Dapper makes it really easy to include presenters into your application. Very handy for cleaning up your views.}
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 = "dapper"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Dapper::VERSION
17
+ end
@@ -0,0 +1,5 @@
1
+ require "dapper/version"
2
+ require 'dapper/system'
3
+ require 'dapper/base'
4
+ require 'dapper/view_context'
5
+ require 'dapper/railtie'
@@ -0,0 +1,17 @@
1
+ module Dapper
2
+ class Base
3
+
4
+ def helpers
5
+ self.class.helpers
6
+ end
7
+ alias :h :helpers
8
+
9
+ class << self
10
+ def helpers
11
+ Dapper::ViewContext.current
12
+ end
13
+ alias :h :helpers
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ require 'rails/railtie'
2
+
3
+ module Dapper
4
+ class Railtie < Rails::Railtie
5
+
6
+ config.to_prepare do
7
+ ::Dapper::System.load_app_local_presenters
8
+ end
9
+
10
+ config.after_initialize do |app|
11
+ app.config.paths.add 'app/presenters', :eager_load => true
12
+ end
13
+
14
+ initializer "dapper.extend_action_controller_base" do |app|
15
+ ActiveSupport.on_load(:action_controller) do
16
+ Dapper::System.setup(self)
17
+ end
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ module Dapper
2
+
3
+ class System
4
+ def self.app_local_presenters_glob
5
+ 'app/presenters/**/*_presenter.rb'
6
+ end
7
+
8
+ def self.load_app_local_presenters
9
+ presenter_files = Dir[ "#{ Rails.root }/#{ app_local_presenters_glob }" ]
10
+ presenter_files.each { |d| require_dependency d }
11
+ end
12
+
13
+ def self.setup(component)
14
+ component.class_eval do
15
+ include Dapper::ViewContextFilter
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module Dapper
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,21 @@
1
+ module Dapper
2
+ module ViewContext
3
+ def self.current
4
+ Thread.current[:current_view_context]
5
+ end
6
+
7
+ def self.current=(input)
8
+ Thread.current[:current_view_context] = input
9
+ end
10
+ end
11
+
12
+ module ViewContextFilter
13
+ def set_current_view_context
14
+ Dapper::ViewContext.current = self.view_context
15
+ end
16
+
17
+ def self.included(source)
18
+ source.send(:before_filter, :set_current_view_context) if source.respond_to?(:before_filter)
19
+ end
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jefferson Carley
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-17 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A gem for using presenters in your rails application.
15
+ email:
16
+ - jeff.carley@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE
24
+ - README.md
25
+ - Rakefile
26
+ - dapper.gemspec
27
+ - lib/dapper.rb
28
+ - lib/dapper/base.rb
29
+ - lib/dapper/railtie.rb
30
+ - lib/dapper/system.rb
31
+ - lib/dapper/version.rb
32
+ - lib/dapper/view_context.rb
33
+ homepage: ''
34
+ licenses: []
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubyforge_project:
53
+ rubygems_version: 1.8.17
54
+ signing_key:
55
+ specification_version: 3
56
+ summary: Dapper makes it really easy to include presenters into your application. Very
57
+ handy for cleaning up your views.
58
+ test_files: []