not_only_but_also 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -60,4 +60,10 @@ OR the shorthand version:
60
60
  end
61
61
 
62
62
 
63
+ There is a generator for quickly creating the context file and the directory if need be
64
+
65
+ ./script/generate not_only_but_also Post validations
66
+
67
+ Adding the context to the model to have it loaded is left for as an exercise for the developer.
68
+
63
69
  Copyright (c) 2009 Adam Meehan, released under the MIT license
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rubygems/specification'
5
5
  require 'spec/rake/spectask'
6
6
 
7
7
  GEM_NAME = "not_only_but_also"
8
- GEM_VERSION = '0.1.0'
8
+ GEM_VERSION = '0.2.0'
9
9
  AUTHOR = "Adam Meehan"
10
10
  EMAIL = "adam.meehan@gmail.com"
11
11
  HOMEPAGE = "http://github.com/adzap/not_only_but_also"
@@ -26,7 +26,7 @@ spec = Gem::Specification.new do |s|
26
26
 
27
27
  s.require_path = 'lib'
28
28
  s.autorequire = GEM_NAME
29
- s.files = %w(MIT-LICENSE README.rdoc Rakefile) + Dir.glob("{lib,spec}/**/*")
29
+ s.files = %w(MIT-LICENSE README.rdoc Rakefile) + Dir.glob("{lib,spec,generators}/**/*")
30
30
  end
31
31
 
32
32
  desc 'Default: run specs.'
@@ -0,0 +1,26 @@
1
+ class NotOnlyButAlsoGenerator < Rails::Generator::NamedBase
2
+
3
+ attr_reader :context
4
+
5
+ def initialize(runtime_args, runtime_options = {})
6
+ super
7
+ unless File.exists?(File.join('app/models', file_name + ".rb"))
8
+ raise "Model for #{class_name} does not seem to exist"
9
+ end
10
+ @context = args.shift
11
+ end
12
+
13
+ def manifest
14
+ record do |m|
15
+ m.directory(File.join('app/models', file_path))
16
+ m.template 'context.erb', File.join('app/models', file_path, "#{context}.rb")
17
+ end
18
+ end
19
+
20
+ protected
21
+ def banner
22
+ "Usage: #{$0} #{spec.name} Model context"
23
+ end
24
+
25
+ end
26
+
@@ -0,0 +1,2 @@
1
+ <%= class_name %>.also_has do
2
+ end
@@ -17,14 +17,10 @@ module NotOnlyButAlso
17
17
 
18
18
  module Helpers
19
19
 
20
- class << self
21
-
22
- def require_context_file(class_name, context)
23
- require_dependency "#{class_name.underscore}/#{context}"
24
- rescue MissingSourceFile => e
25
- raise e, "NotOnlyButAlso could not find a file for #{class_name} using context #{context}"
26
- end
27
-
20
+ def self.require_context_file(class_name, context)
21
+ require_dependency "#{class_name.underscore}/#{context}"
22
+ rescue MissingSourceFile => e
23
+ raise e, "NotOnlyButAlso could not find a file for #{class_name} using context #{context}"
28
24
  end
29
25
 
30
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: not_only_but_also
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Meehan
@@ -9,7 +9,7 @@ autorequire: not_only_but_also
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-06 00:00:00 +11:00
12
+ date: 2009-11-13 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -26,11 +26,13 @@ files:
26
26
  - README.rdoc
27
27
  - Rakefile
28
28
  - lib/not_only_but_also.rb
29
- - spec/not_only_but_also_spec.rb
30
- - spec/spec_helper.rb
29
+ - spec/rails_root/app/models/post.rb
31
30
  - spec/rails_root/app/models/post/stuff.rb
32
31
  - spec/rails_root/app/models/post/validations.rb
33
- - spec/rails_root/app/models/post.rb
32
+ - spec/not_only_but_also_spec.rb
33
+ - spec/spec_helper.rb
34
+ - generators/not_only_but_also/templates/context.erb
35
+ - generators/not_only_but_also/not_only_but_also_generator.rb
34
36
  has_rdoc: true
35
37
  homepage: http://github.com/adzap/not_only_but_also
36
38
  licenses: []
@@ -55,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
57
  requirements: []
56
58
 
57
59
  rubyforge_project: not_only_but_also
58
- rubygems_version: 1.3.4
60
+ rubygems_version: 1.3.5
59
61
  signing_key:
60
62
  specification_version: 3
61
63
  summary: Rails plugin to split large models into separate files of concern. Like concerned_with but a little more convenient.