controller_concerned 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in controller_concerned.gemspec
4
+ gemspec
data/README ADDED
@@ -0,0 +1,12 @@
1
+ Organize your controller and place each action/functionality in a separate file.
2
+ Especially if your controller actions are too big you can use controller_concerned.
3
+ I know, the better way is to refactor your controller code to avoid masses of lines,
4
+ but if you haven't enough time for refactoring, try this.
5
+
6
+ class UsersController < ApplicationController
7
+ controller_concerned
8
+ end
9
+
10
+ For UsersController controller_concerned will include all *.rb files
11
+ found in controller/users_concerns
12
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "controller_concerned/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "controller_concerned"
7
+ s.version = ControllerConcerned::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Matthias Zirnstein"]
10
+ s.email = ["matthias.zirnstein@googlemail.com"]
11
+ s.homepage = "https://github.com/zirni/controller_concerned"
12
+ s.summary = %q{Organize your controller and place each action/functionality in a separate file}
13
+ s.description = %q{}
14
+
15
+ s.rubyforge_project = "controller_concerned"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,22 @@
1
+ module ControllerConcerned
2
+ module Base
3
+ def self.included(base)
4
+ base.class_eval do
5
+ extend ClassMethods
6
+ end
7
+ end
8
+
9
+ module ClassMethods
10
+ def controller_concerned
11
+ module_name = self.name.underscore.gsub(/_controller$/, "") << "_concerns"
12
+ concerned_path = Rails.root.join("app", "controllers", module_name)
13
+
14
+ Dir.glob("#{concerned_path}/*.rb").each do |file|
15
+ file = Pathname.new(file).basename.to_s
16
+ camelized = "#{module_name}/#{file.gsub(".rb", "")}".camelize
17
+ self.send :include, camelized.constantize
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module ControllerConcerned
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,3 @@
1
+ require File.expand_path("../controller_concerned/base", __FILE__)
2
+
3
+ ActionController::Base.send(:include, ControllerConcerned::Base)
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: controller_concerned
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.3
6
+ platform: ruby
7
+ authors:
8
+ - Matthias Zirnstein
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-10 00:00:00 Z
14
+ dependencies: []
15
+
16
+ description: ""
17
+ email:
18
+ - matthias.zirnstein@googlemail.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - .gitignore
27
+ - Gemfile
28
+ - README
29
+ - Rakefile
30
+ - controller_concerned.gemspec
31
+ - lib/controller_concerned.rb
32
+ - lib/controller_concerned/base.rb
33
+ - lib/controller_concerned/version.rb
34
+ homepage: https://github.com/zirni/controller_concerned
35
+ licenses: []
36
+
37
+ post_install_message:
38
+ rdoc_options: []
39
+
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ requirements: []
55
+
56
+ rubyforge_project: controller_concerned
57
+ rubygems_version: 1.7.2
58
+ signing_key:
59
+ specification_version: 3
60
+ summary: Organize your controller and place each action/functionality in a separate file
61
+ test_files: []
62
+