berkes-drupal.rb 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +4 -2
- data/drupal.rb.gemspec +30 -15
- data/lib/drupal/create_module.rb +23 -10
- data/lib/drupal/install.rb +1 -1
- data/lib/drupal/templates/5.x/base/info +6 -0
- data/lib/drupal/templates/{comments → 5.x/comments}/file +0 -0
- data/lib/drupal/templates/{comments → 5.x/comments}/large +0 -0
- data/lib/drupal/templates/{hooks → 5.x/hooks}/block +9 -10
- data/lib/drupal/templates/{hooks → 5.x/hooks}/cron +0 -0
- data/lib/drupal/templates/5.x/hooks/form_alter +11 -0
- data/lib/drupal/templates/{hooks → 5.x/hooks}/init +0 -0
- data/lib/drupal/templates/5.x/hooks/install +15 -0
- data/lib/drupal/templates/5.x/hooks/menu +24 -0
- data/lib/drupal/templates/5.x/hooks/perm +7 -0
- data/lib/drupal/templates/{txt → 5.x/txt}/changelog +0 -0
- data/lib/drupal/templates/{txt → 5.x/txt}/readme +0 -0
- data/lib/drupal/templates/6.x/base/info +6 -0
- data/lib/drupal/templates/6.x/comments/file +9 -0
- data/lib/drupal/templates/6.x/comments/large +6 -0
- data/lib/drupal/templates/6.x/hooks/block +45 -0
- data/lib/drupal/templates/{hooks → 6.x/hooks}/boot +0 -0
- data/lib/drupal/templates/6.x/hooks/cron +7 -0
- data/lib/drupal/templates/{hooks → 6.x/hooks}/form_alter +0 -0
- data/lib/drupal/templates/6.x/hooks/init +7 -0
- data/lib/drupal/templates/{hooks → 6.x/hooks}/install +0 -0
- data/lib/drupal/templates/6.x/hooks/menu +17 -0
- data/lib/drupal/templates/{hooks → 6.x/hooks}/perm +0 -0
- data/lib/drupal/templates/{hooks → 6.x/hooks}/schema +0 -0
- data/lib/drupal/templates/{hooks → 6.x/hooks}/theme +0 -0
- data/lib/drupal/templates/6.x/txt/changelog +9 -0
- data/lib/drupal/templates/6.x/txt/readme +36 -0
- metadata +28 -15
- data/lib/drupal/templates/hooks/menu +0 -17
data/README.txt
CHANGED
@@ -71,14 +71,16 @@ to quickly generate and manage Drupal modules.
|
|
71
71
|
Alternatively you can copy the example from the doc dir in the package.
|
72
72
|
|
73
73
|
== TODO:
|
74
|
+
* Move module, install to base too.
|
75
|
+
* Add support for database scheme upgrades, similar to rake db: commands. Should add hook_update to .install.
|
74
76
|
* Move helptext into one include instead of having it on 4 places (DRY!)
|
75
|
-
*
|
77
|
+
* Improve Drupal version support to defaults.yml.
|
76
78
|
* Remove ':' from todo list items
|
77
|
-
* Add formatted help option
|
78
79
|
* Support versions for installer
|
79
80
|
* Support version prompt for project installation
|
80
81
|
* Support installing a list from file(s) so that devs may have lists of core modules they use
|
81
82
|
* Add hook dependencies
|
83
|
+
* Add an option to write and/or change defaults.yml from commandline
|
82
84
|
* Add installer for jQuery plugins?
|
83
85
|
* Add graceful error handling
|
84
86
|
* Add / refactor tests, using rspec
|
data/drupal.rb.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "drupal.rb"
|
3
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.9"
|
4
4
|
s.date = "2008-10-16"
|
5
5
|
s.summary = "Drupal development kit"
|
6
6
|
s.email = "ber@webschuur.com"
|
@@ -18,20 +18,35 @@ Gem::Specification.new do |s|
|
|
18
18
|
"lib/drupal/create_module.rb",
|
19
19
|
"lib/drupal/todo_list.rb",
|
20
20
|
"lib/drupal/install.rb",
|
21
|
-
"lib/drupal/templates/comments/file",
|
22
|
-
"lib/drupal/templates/comments/large",
|
23
|
-
"lib/drupal/templates/hooks/block",
|
24
|
-
"lib/drupal/templates/hooks/boot",
|
25
|
-
"lib/drupal/templates/hooks/install",
|
26
|
-
"lib/drupal/templates/hooks/cron",
|
27
|
-
"lib/drupal/templates/hooks/form_alter",
|
28
|
-
"lib/drupal/templates/hooks/init",
|
29
|
-
"lib/drupal/templates/hooks/menu",
|
30
|
-
"lib/drupal/templates/hooks/perm",
|
31
|
-
"lib/drupal/templates/hooks/schema",
|
32
|
-
"lib/drupal/templates/hooks/theme",
|
33
|
-
"lib/drupal/templates/txt/changelog",
|
34
|
-
"lib/drupal/templates/txt/readme",
|
21
|
+
"lib/drupal/templates/6.x/comments/file",
|
22
|
+
"lib/drupal/templates/6.x/comments/large",
|
23
|
+
"lib/drupal/templates/6.x/hooks/block",
|
24
|
+
"lib/drupal/templates/6.x/hooks/boot",
|
25
|
+
"lib/drupal/templates/6.x/hooks/install",
|
26
|
+
"lib/drupal/templates/6.x/hooks/cron",
|
27
|
+
"lib/drupal/templates/6.x/hooks/form_alter",
|
28
|
+
"lib/drupal/templates/6.x/hooks/init",
|
29
|
+
"lib/drupal/templates/6.x/hooks/menu",
|
30
|
+
"lib/drupal/templates/6.x/hooks/perm",
|
31
|
+
"lib/drupal/templates/6.x/hooks/schema",
|
32
|
+
"lib/drupal/templates/6.x/hooks/theme",
|
33
|
+
"lib/drupal/templates/6.x/txt/changelog",
|
34
|
+
"lib/drupal/templates/6.x/txt/readme",
|
35
|
+
"lib/drupal/templates/6.x/base/info",
|
36
|
+
|
37
|
+
"lib/drupal/templates/5.x/comments/file",
|
38
|
+
"lib/drupal/templates/5.x/comments/large",
|
39
|
+
"lib/drupal/templates/5.x/hooks/block",
|
40
|
+
"lib/drupal/templates/5.x/hooks/install",
|
41
|
+
"lib/drupal/templates/5.x/hooks/cron",
|
42
|
+
"lib/drupal/templates/5.x/hooks/form_alter",
|
43
|
+
"lib/drupal/templates/5.x/hooks/init",
|
44
|
+
"lib/drupal/templates/5.x/hooks/menu",
|
45
|
+
"lib/drupal/templates/5.x/hooks/perm",
|
46
|
+
"lib/drupal/templates/5.x/txt/changelog",
|
47
|
+
"lib/drupal/templates/5.x/txt/readme",
|
48
|
+
"lib/drupal/templates/5.x/base/info",
|
49
|
+
|
35
50
|
"bin/drupal"]
|
36
51
|
s.executables = ["drupal"]
|
37
52
|
s.test_files = ["test/test_drupal.rb", "test/test_install.rb", "test/test_create_module.rb", "test/test_todo_list.rb"]
|
data/lib/drupal/create_module.rb
CHANGED
@@ -27,7 +27,8 @@ class Drupal
|
|
27
27
|
# TODO create self.log() with padding to even output
|
28
28
|
defaults = get_defaults
|
29
29
|
|
30
|
-
#
|
30
|
+
# TODO make each ask have a commandline-option equivalent.
|
31
|
+
@version = self.ask('What drupal version to scaffold for?:', defaults[:version])
|
31
32
|
@author = self.ask('What is your name?:', defaults[:author])
|
32
33
|
@link = self.ask('What is the URI to your companies website?:', defaults[:link])
|
33
34
|
@email = self.ask('What is your email?:', defaults[:email])
|
@@ -131,14 +132,26 @@ class Drupal
|
|
131
132
|
|
132
133
|
# Create info file.
|
133
134
|
def create_module_info_file
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
135
|
+
tokens = {
|
136
|
+
'module_name' => @module_name,
|
137
|
+
'module_description' => @module_description,
|
138
|
+
'version' => @version,
|
139
|
+
}
|
140
|
+
|
141
|
+
if !@module_dependencies.nil?
|
142
|
+
#In 6.x each dep has a new line. In 5.x they are on a single line.
|
143
|
+
if (@version == '6.x')
|
144
|
+
@module_dependencies.each do |dependency|
|
145
|
+
tokens['dependencies_chunk'] = "\ndependencies[] = #{dependency}"
|
146
|
+
end
|
147
|
+
elsif (@version == '5.x')
|
148
|
+
tokens['dependencies_chunk'] = "dependencies = " + @module_dependencies.join(',')
|
149
|
+
end
|
140
150
|
end
|
141
|
-
|
151
|
+
|
152
|
+
filepath = "#{@module}.info"
|
153
|
+
create_file(filepath)
|
154
|
+
append_template(filepath, "base/info", tokens)
|
142
155
|
end
|
143
156
|
|
144
157
|
# Create a new directory.
|
@@ -213,10 +226,10 @@ class Drupal
|
|
213
226
|
|
214
227
|
private
|
215
228
|
def get_template_location
|
216
|
-
location = File.expand_path
|
229
|
+
location = File.expand_path "~/.drupal.rb/templates/#{@version}"
|
217
230
|
|
218
231
|
unless File.directory? location
|
219
|
-
location = File.dirname(__FILE__) +
|
232
|
+
location = File.dirname(__FILE__) + "/templates/#{@version}"
|
220
233
|
end
|
221
234
|
|
222
235
|
return location + '/'
|
data/lib/drupal/install.rb
CHANGED
File without changes
|
File without changes
|
@@ -7,9 +7,8 @@ function [module]_block($op = 'list', $delta = 0, $edit = array()) {
|
|
7
7
|
case 'list':
|
8
8
|
$blocks = array();
|
9
9
|
$blocks[0] = array(
|
10
|
-
|
11
|
-
|
12
|
-
);
|
10
|
+
'info' => t('Block desc in listing'),
|
11
|
+
);
|
13
12
|
return $blocks;
|
14
13
|
|
15
14
|
case 'configure':
|
@@ -17,10 +16,10 @@ function [module]_block($op = 'list', $delta = 0, $edit = array()) {
|
|
17
16
|
switch($delta){
|
18
17
|
default:
|
19
18
|
$form['item'] = array(
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
'#type' => 'textfield',
|
20
|
+
'#title' => t('Form Item'),
|
21
|
+
'#default_value' => variable_get('item_var', 0),
|
22
|
+
);
|
24
23
|
}
|
25
24
|
return $form;
|
26
25
|
|
@@ -36,9 +35,9 @@ function [module]_block($op = 'list', $delta = 0, $edit = array()) {
|
|
36
35
|
switch($delta) {
|
37
36
|
case 0:
|
38
37
|
$block = array(
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
'subject' => t('Block title'),
|
39
|
+
'content' => 'content here',
|
40
|
+
);
|
42
41
|
}
|
43
42
|
return $block;
|
44
43
|
}
|
File without changes
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
/**
|
3
|
+
* Implementation of hook_install().
|
4
|
+
*/
|
5
|
+
function [module]_install() {
|
6
|
+
switch ($GLOBALS['db_type']) {
|
7
|
+
case 'mysql':
|
8
|
+
case 'mysqli':
|
9
|
+
db_query();
|
10
|
+
break;
|
11
|
+
default:
|
12
|
+
drupal_set_message(t('Database type %dbtype is currently not supported. Please create database table manually.', array('%dbtype' => $GLOBALS['db_type'])), 'error');
|
13
|
+
break;
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
/**
|
3
|
+
* Implementation of hook_menu().
|
4
|
+
*/
|
5
|
+
function [module]_menu($may_cache) {
|
6
|
+
$items = array();
|
7
|
+
|
8
|
+
if ($may_cache) {
|
9
|
+
$items[] = array(
|
10
|
+
'path' => 'admin/settings/[module]',
|
11
|
+
'title' => t('[module]'),
|
12
|
+
'callback' => '[module]_settings_page',
|
13
|
+
'access' => user_access('access administration pages'),
|
14
|
+
);
|
15
|
+
$items[] = array(
|
16
|
+
'path' => '',
|
17
|
+
'title' => t(''),
|
18
|
+
'callback' => '',
|
19
|
+
'access' => user_access(''),
|
20
|
+
'type' => MENU_SUGGESTED_ITEM,
|
21
|
+
);
|
22
|
+
}
|
23
|
+
return $items;
|
24
|
+
}
|
File without changes
|
File without changes
|
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
/**
|
3
|
+
* Implementation of hook_block().
|
4
|
+
*/
|
5
|
+
function [module]_block($op = 'list', $delta = 0, $edit = array()) {
|
6
|
+
switch($op) {
|
7
|
+
case 'list':
|
8
|
+
$blocks = array();
|
9
|
+
$blocks[0] = array(
|
10
|
+
'info' => t('Block desc in listing'),
|
11
|
+
'cache' => BLOCK_CACHE_PER_ROLE | BLOCK_CACHE_PER_PAGE,
|
12
|
+
);
|
13
|
+
return $blocks;
|
14
|
+
|
15
|
+
case 'configure':
|
16
|
+
$form = array();
|
17
|
+
switch($delta){
|
18
|
+
default:
|
19
|
+
$form['item'] = array(
|
20
|
+
'#type' => 'textfield',
|
21
|
+
'#title' => t('Form Item'),
|
22
|
+
'#default_value' => variable_get('item_var', 0),
|
23
|
+
);
|
24
|
+
}
|
25
|
+
return $form;
|
26
|
+
|
27
|
+
case 'save':
|
28
|
+
switch($delta){
|
29
|
+
default:
|
30
|
+
variable_set('item_var', $edit['item_var']);
|
31
|
+
}
|
32
|
+
break;
|
33
|
+
|
34
|
+
case 'view':
|
35
|
+
$block = array();
|
36
|
+
switch($delta) {
|
37
|
+
case 0:
|
38
|
+
$block = array(
|
39
|
+
'subject' => t('Block title'),
|
40
|
+
'content' => 'content here',
|
41
|
+
);
|
42
|
+
}
|
43
|
+
return $block;
|
44
|
+
}
|
45
|
+
}
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
/**
|
3
|
+
* Implementation of hook_menu().
|
4
|
+
*/
|
5
|
+
function [module]_menu() {
|
6
|
+
$items = array();
|
7
|
+
|
8
|
+
$items['admin/settings/[module]'] = array(
|
9
|
+
'title' => '[module]',
|
10
|
+
'page callback' => 'drupal_get_form',
|
11
|
+
'page arguments' => array('[module]_settings'),
|
12
|
+
'access arguments' => array('administer [module]'),
|
13
|
+
'file' => '[module].admin.inc',
|
14
|
+
);
|
15
|
+
|
16
|
+
return $items;
|
17
|
+
}
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
$Id$
|
3
|
+
|
4
|
+
|
5
|
+
[module]
|
6
|
+
Provided by [link]
|
7
|
+
Developed by [author]
|
8
|
+
|
9
|
+
-------------------------------------------------------------------------------
|
10
|
+
INSTALLATION
|
11
|
+
-------------------------------------------------------------------------------
|
12
|
+
|
13
|
+
todo
|
14
|
+
|
15
|
+
-------------------------------------------------------------------------------
|
16
|
+
PERMISSIONS
|
17
|
+
-------------------------------------------------------------------------------
|
18
|
+
|
19
|
+
permission
|
20
|
+
- description
|
21
|
+
|
22
|
+
|
23
|
+
-------------------------------------------------------------------------------
|
24
|
+
PUBLIC API
|
25
|
+
-------------------------------------------------------------------------------
|
26
|
+
|
27
|
+
todo
|
28
|
+
|
29
|
+
-------------------------------------------------------------------------------
|
30
|
+
CONVENTIONS
|
31
|
+
-------------------------------------------------------------------------------
|
32
|
+
|
33
|
+
todo
|
34
|
+
|
35
|
+
|
36
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: berkes-drupal.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tj@vision-media.ca
|
@@ -34,20 +34,33 @@ files:
|
|
34
34
|
- lib/drupal/create_module.rb
|
35
35
|
- lib/drupal/todo_list.rb
|
36
36
|
- lib/drupal/install.rb
|
37
|
-
- lib/drupal/templates/comments/file
|
38
|
-
- lib/drupal/templates/comments/large
|
39
|
-
- lib/drupal/templates/hooks/block
|
40
|
-
- lib/drupal/templates/hooks/boot
|
41
|
-
- lib/drupal/templates/hooks/install
|
42
|
-
- lib/drupal/templates/hooks/cron
|
43
|
-
- lib/drupal/templates/hooks/form_alter
|
44
|
-
- lib/drupal/templates/hooks/init
|
45
|
-
- lib/drupal/templates/hooks/menu
|
46
|
-
- lib/drupal/templates/hooks/perm
|
47
|
-
- lib/drupal/templates/hooks/schema
|
48
|
-
- lib/drupal/templates/hooks/theme
|
49
|
-
- lib/drupal/templates/txt/changelog
|
50
|
-
- lib/drupal/templates/txt/readme
|
37
|
+
- lib/drupal/templates/6.x/comments/file
|
38
|
+
- lib/drupal/templates/6.x/comments/large
|
39
|
+
- lib/drupal/templates/6.x/hooks/block
|
40
|
+
- lib/drupal/templates/6.x/hooks/boot
|
41
|
+
- lib/drupal/templates/6.x/hooks/install
|
42
|
+
- lib/drupal/templates/6.x/hooks/cron
|
43
|
+
- lib/drupal/templates/6.x/hooks/form_alter
|
44
|
+
- lib/drupal/templates/6.x/hooks/init
|
45
|
+
- lib/drupal/templates/6.x/hooks/menu
|
46
|
+
- lib/drupal/templates/6.x/hooks/perm
|
47
|
+
- lib/drupal/templates/6.x/hooks/schema
|
48
|
+
- lib/drupal/templates/6.x/hooks/theme
|
49
|
+
- lib/drupal/templates/6.x/txt/changelog
|
50
|
+
- lib/drupal/templates/6.x/txt/readme
|
51
|
+
- lib/drupal/templates/6.x/base/info
|
52
|
+
- lib/drupal/templates/5.x/comments/file
|
53
|
+
- lib/drupal/templates/5.x/comments/large
|
54
|
+
- lib/drupal/templates/5.x/hooks/block
|
55
|
+
- lib/drupal/templates/5.x/hooks/install
|
56
|
+
- lib/drupal/templates/5.x/hooks/cron
|
57
|
+
- lib/drupal/templates/5.x/hooks/form_alter
|
58
|
+
- lib/drupal/templates/5.x/hooks/init
|
59
|
+
- lib/drupal/templates/5.x/hooks/menu
|
60
|
+
- lib/drupal/templates/5.x/hooks/perm
|
61
|
+
- lib/drupal/templates/5.x/txt/changelog
|
62
|
+
- lib/drupal/templates/5.x/txt/readme
|
63
|
+
- lib/drupal/templates/5.x/base/info
|
51
64
|
- bin/drupal
|
52
65
|
has_rdoc: true
|
53
66
|
homepage: http://berkes.github.com/drupal.rb/
|
@@ -1,17 +0,0 @@
|
|
1
|
-
|
2
|
-
/**
|
3
|
-
* Implementation of hook_menu().
|
4
|
-
*/
|
5
|
-
function [module]_menu() {
|
6
|
-
$items = array();
|
7
|
-
|
8
|
-
$items['admin/settings/[module]'] = array(
|
9
|
-
'title' => '[module]',
|
10
|
-
'page callback' => 'drupal_get_form',
|
11
|
-
'page arguments' => array('[module]_settings'),
|
12
|
-
'access arguments' => array('administer [module]'),
|
13
|
-
'file' => '[module].admin.inc',
|
14
|
-
);
|
15
|
-
|
16
|
-
return $items;
|
17
|
-
}
|