minimal_exposure 0.0.1

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,18 @@
1
+ .idea
2
+ *.gem
3
+ *.rbc
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in minimal_exposure.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 James Martin
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,31 @@
1
+ # MinimalExposure
2
+
3
+ minimal_exposure is a really simple way to expose methods, rather than instance variables, to your views in a rails app.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'minimal_exposure'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install minimal_exposure
18
+
19
+ ## Usage
20
+
21
+ Proceed as normal. The instance variables declared in your controllers are now available as methods to your views.
22
+ It is important to note that this only works for partials that have been passed 'view_parameters' from the actions base view.
23
+ It is recommended to have a base view, i.e. 'new.html.haml' simply render '_new.html.haml' passing in the view_parameters hash.
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,8 @@
1
+ require 'minimal_exposure/view_helpers'
2
+ module MinimalExposure
3
+ class Railtie < Rails::Railtie
4
+ initializer "minimal_exposure.view_helpers" do
5
+ ActionView::Base.send :include, ViewHelpers
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module MinimalExposure
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,16 @@
1
+ require 'minimal_exposure/view_parameters'
2
+
3
+ module MinimalExposure
4
+ module ViewHelpers
5
+
6
+ def view_parameters
7
+ @view_parameters ||= ViewParameters.new(the_view_assigns)
8
+ end
9
+ alias vp view_parameters
10
+
11
+ def the_view_assigns
12
+ Rails.env == 'test' ? assigns[:_encapsulated_assigns] : controller.view_assigns.except('_routes')
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ module MinimalExposure
2
+ class ViewParameters
3
+
4
+ def initialize(the_rails_view_assigns)
5
+ @the_view_assigns = the_rails_view_assigns.symbolize_keys
6
+ @vp = {}
7
+ end
8
+
9
+ def keys
10
+ @the_view_assigns.keys
11
+ end
12
+
13
+ def [](key)
14
+ @vp[key] ||= @the_view_assigns[key]
15
+ end
16
+
17
+ def method_missing(m, *args)
18
+ @vp.send(m, *args)
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,6 @@
1
+ require 'minimal_exposure/version'
2
+ require 'minimal_exposure/railtie' if defined?(Rails)
3
+
4
+ module MinimalExposure
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'minimal_exposure/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "minimal_exposure"
8
+ gem.version = MinimalExposure::VERSION
9
+ gem.authors = ["James Martin"]
10
+ gem.email = ["jmartin2683@gmail.com"]
11
+ gem.description = %q{A simple way to expose methods to views.}
12
+ gem.summary = %q{A simple way to expose methods to views.}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minimal_exposure
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - James Martin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-09 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A simple way to expose methods to views.
15
+ email:
16
+ - jmartin2683@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - lib/minimal_exposure.rb
27
+ - lib/minimal_exposure/railtie.rb
28
+ - lib/minimal_exposure/version.rb
29
+ - lib/minimal_exposure/view_helpers.rb
30
+ - lib/minimal_exposure/view_parameters.rb
31
+ - minimal_exposure.gemspec
32
+ homepage: ''
33
+ licenses: []
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project:
52
+ rubygems_version: 1.8.24
53
+ signing_key:
54
+ specification_version: 3
55
+ summary: A simple way to expose methods to views.
56
+ test_files: []