blob: 340c03dd4e6f924d1ab9efb62d0bbc88cafde50b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
== Appendix ==
If you prefer to use RSpec instead of Test::Unit, you may be interested in the http://github.com/pat-maddox/rspec-plugin-generator/tree/master[RSpec Plugin Generator].
=== References ===
* http://nubyonrails.com/articles/the-complete-guide-to-rails-plugins-part-i
* http://nubyonrails.com/articles/2006/05/09/the-complete-guide-to-rails-plugins-part-ii
* http://github.com/technoweenie/attachment_fu/tree/master
* http://daddy.platte.name/2007/05/rails-plugins-keep-initrb-thin.html
* http://www.mbleigh.com/2008/6/11/gemplugins-a-brief-introduction-to-the-future-of-rails-plugins
* http://weblog.jamisbuck.org/2006/10/26/monkey-patching-rails-extending-routes-2.
=== Contents of 'lib/yaffle.rb' ===
*vendor/plugins/yaffle/lib/yaffle.rb:*
[source, ruby]
----------------------------------------------
require "yaffle/core_ext"
require "yaffle/acts_as_yaffle"
require "yaffle/commands"
require "yaffle/routing"
%w{ models controllers helpers }.each do |dir|
path = File.join(File.dirname(__FILE__), 'app', dir)
$LOAD_PATH << path
ActiveSupport::Dependencies.load_paths << path
ActiveSupport::Dependencies.load_once_paths.delete(path)
end
# optionally:
# Dir.glob(File.join(File.dirname(__FILE__), "db", "migrate", "*")).each do |file|
# require file
# end
----------------------------------------------
=== Final plugin directory structure ===
The final plugin should have a directory structure that looks something like this:
------------------------------------------------
|-- MIT-LICENSE
|-- README
|-- Rakefile
|-- generators
| |-- yaffle_definition
| | |-- USAGE
| | |-- templates
| | | `-- definition.txt
| | `-- yaffle_definition_generator.rb
| |-- yaffle_migration
| | |-- USAGE
| | |-- templates
| | `-- yaffle_migration_generator.rb
| `-- yaffle_route
| |-- USAGE
| |-- templates
| `-- yaffle_route_generator.rb
|-- install.rb
|-- lib
| |-- app
| | |-- controllers
| | | `-- woodpeckers_controller.rb
| | |-- helpers
| | | `-- woodpeckers_helper.rb
| | `-- models
| | `-- woodpecker.rb
| |-- db
| | `-- migrate
| | `-- 20081116181115_create_birdhouses.rb
| |-- yaffle
| | |-- acts_as_yaffle.rb
| | |-- commands.rb
| | |-- core_ext.rb
| | `-- routing.rb
| `-- yaffle.rb
|-- pkg
| `-- yaffle-0.0.1.gem
|-- rails
| `-- init.rb
|-- tasks
| `-- yaffle_tasks.rake
|-- test
| |-- acts_as_yaffle_test.rb
| |-- core_ext_test.rb
| |-- database.yml
| |-- debug.log
| |-- definition_generator_test.rb
| |-- migration_generator_test.rb
| |-- route_generator_test.rb
| |-- routes_test.rb
| |-- schema.rb
| |-- test_helper.rb
| |-- woodpecker_test.rb
| |-- woodpeckers_controller_test.rb
| |-- wookpeckers_helper_test.rb
| |-- yaffle_plugin.sqlite3.db
| `-- yaffle_test.rb
`-- uninstall.rb
------------------------------------------------
|