content_skipper 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ pkg/*
2
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :gemcutter
2
+
3
+ # Specify your gem's dependencies in content_skipper.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,15 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ content_skipper (0.1.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+
10
+ PLATFORMS
11
+ ruby
12
+
13
+ DEPENDENCIES
14
+ bundler (>= 1.0.0.rc.5)
15
+ content_skipper!
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ Content Skipper
2
+ ===============
3
+
4
+ In Controller:
5
+ --------------
6
+
7
+ Class methods:
8
+
9
+ skip_content :header
10
+ skip_content :footer, :only => 'index'
11
+ skip_content :navigation, :except => 'show'
12
+ skip_content [:comments, :faqs], :only => ['home', 'about']
13
+
14
+ Instance methods:
15
+
16
+ skip_content :header
17
+ dont_skip_content :header
18
+
19
+
20
+ In Views:
21
+ ---------
22
+
23
+ <%= render(:partial => 'footer') unless skip_content?(:footer) -%>
24
+
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler'
2
+ require 'rake/testtask'
3
+
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ desc 'Default: run unit tests'
7
+ task :default => :test
8
+
9
+ desc 'Test the plugin.'
10
+ Rake::TestTask.new(:test) do |t|
11
+ t.libs << 'test'
12
+ t.pattern = 'test/**/*_test.rb'
13
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
3
+ require 'content_skipper/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "content_skipper"
7
+ s.version = ContentSkipper::VERSION
8
+ s.date = Time.now.strftime('%Y-%m-%d')
9
+
10
+ s.summary = "Mark specific parts of your content to not be rendered"
11
+ s.description = "Mark specific parts of your content to not be rendered"
12
+
13
+ s.author = "Garret Alfert"
14
+ s.email = "garret.alfert@gmail.com"
15
+ s.homepage = "http://rubygems.org/gems/content_skipper"
16
+
17
+ s.platform = Gem::Platform::RUBY
18
+ s.required_rubygems_version = ">= 1.3.6"
19
+ s.add_development_dependency "bundler", ">= 1.0.0.rc.5"
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.require_path = 'lib'
23
+ s.has_rdoc = false
24
+ end
@@ -0,0 +1,7 @@
1
+ require 'content_skipper/common_methods'
2
+ require 'content_skipper/controller_methods'
3
+ require 'content_skipper/helper_methods'
4
+ require 'content_skipper/railtie'
5
+
6
+ module ContentSkipper
7
+ end
@@ -0,0 +1,16 @@
1
+ module ContentSkipper
2
+ module CommonMethods
3
+ def skipped_content
4
+ @skipped_content
5
+ end
6
+
7
+ def skipped_content=(content)
8
+ @skipped_content = case content
9
+ when Array
10
+ content.flatten.compact.map(&:to_sym).uniq
11
+ else
12
+ content.to_sym
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,25 @@
1
+ module ContentSkipper
2
+ module ControllerMethods
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ include ContentSkipper::CommonMethods
7
+ end
8
+
9
+ module ClassMethods
10
+ def skip_content(*args)
11
+ options = args.extract_options!
12
+
13
+ before_filter(options) do |controller|
14
+ controller.skipped_content = args
15
+ end
16
+ end
17
+ end
18
+
19
+ module InstanceMethods
20
+ def skip_content(content)
21
+ self.skipped_content = content
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,22 @@
1
+ module ContentSkipper
2
+ module HelperMethods
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ include ContentSkipper::CommonMethods
7
+ end
8
+
9
+ module InstanceMethods
10
+ def skip_content?(name)
11
+ return false unless skipped_content
12
+
13
+ case skipped_content
14
+ when Array
15
+ skipped_content.include?(name.to_sym)
16
+ else
17
+ skipped_content == name.to_sym
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,14 @@
1
+ module ContentSkipper
2
+ require 'rails'
3
+
4
+ class Railtie < Rails::Railtie
5
+ initializer 'content_skipper.initialize' do
6
+ ActiveSupport.on_load(:action_controller) do
7
+ include ContentSkipper::ControllerMethods
8
+ end
9
+ ActiveSupport.on_load(:action_view) do
10
+ include ContentSkipper::HelperMethods
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module ContentSkipper
2
+ VERSION = "0.0.8"
3
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: content_skipper
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 8
10
+ version: 0.0.8
11
+ platform: ruby
12
+ authors:
13
+ - Garret Alfert
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-09-29 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: bundler
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 15424063
30
+ segments:
31
+ - 1
32
+ - 0
33
+ - 0
34
+ - rc
35
+ - 5
36
+ version: 1.0.0.rc.5
37
+ type: :development
38
+ version_requirements: *id001
39
+ description: Mark specific parts of your content to not be rendered
40
+ email: garret.alfert@gmail.com
41
+ executables: []
42
+
43
+ extensions: []
44
+
45
+ extra_rdoc_files: []
46
+
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - README.md
52
+ - Rakefile
53
+ - content_skipper.gemspec
54
+ - lib/content_skipper.rb
55
+ - lib/content_skipper/common_methods.rb
56
+ - lib/content_skipper/controller_methods.rb
57
+ - lib/content_skipper/helper_methods.rb
58
+ - lib/content_skipper/railtie.rb
59
+ - lib/content_skipper/version.rb
60
+ has_rdoc: true
61
+ homepage: http://rubygems.org/gems/content_skipper
62
+ licenses: []
63
+
64
+ post_install_message:
65
+ rdoc_options: []
66
+
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 23
84
+ segments:
85
+ - 1
86
+ - 3
87
+ - 6
88
+ version: 1.3.6
89
+ requirements: []
90
+
91
+ rubyforge_project:
92
+ rubygems_version: 1.3.7
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: Mark specific parts of your content to not be rendered
96
+ test_files: []
97
+