visionmedia-drupal 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +6 -0
- data/README.txt +3 -2
- data/drupal.gemspec +2 -2
- data/lib/drupal.rb +21 -4
- data/lib/drupal/install.rb +44 -19
- metadata +2 -2
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -17,8 +17,9 @@ to quickly generate and manage Drupal modules.
|
|
17
17
|
|
18
18
|
== ARGUMENTS:
|
19
19
|
|
20
|
-
create module <module_name>
|
21
|
-
todo list [total]
|
20
|
+
create module <module_name> Generates a module skeleton from an interactive wizard.
|
21
|
+
todo list [total] Displays list of todo items or a total.
|
22
|
+
install <core | project> [dir] Install a Drupal project or core itself to [dir]
|
22
23
|
|
23
24
|
== OPTIONS:
|
24
25
|
|
data/drupal.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "drupal"
|
3
|
-
s.version = "0.0.
|
4
|
-
s.date = "2008-
|
3
|
+
s.version = "0.0.3"
|
4
|
+
s.date = "2008-10-03"
|
5
5
|
s.summary = "Drupal development kit"
|
6
6
|
s.email = "tj@vision-media.ca"
|
7
7
|
s.homepage = "http://vision-media.ca/resources/drupal/drupal-module-builder-gem"
|
data/lib/drupal.rb
CHANGED
@@ -6,8 +6,9 @@
|
|
6
6
|
#
|
7
7
|
# == ARGUMENTS:
|
8
8
|
#
|
9
|
-
#
|
10
|
-
#
|
9
|
+
# create module <module_name> [dir] Generates a module skeleton from an interactive wizard. Current directory unless [dir] is specified.
|
10
|
+
# todo list [total] Displays list of todo items or a total.
|
11
|
+
# install <core | project> [dir] Install a Drupal project or core itself to [dir]
|
11
12
|
#
|
12
13
|
# == OPTIONS:
|
13
14
|
#
|
@@ -30,7 +31,13 @@
|
|
30
31
|
#
|
31
32
|
# View total todo items only.
|
32
33
|
# drupal todo list total ./sites/all/modules
|
33
|
-
|
34
|
+
# Install a module to the modules folder in my new installation (from drupal root)
|
35
|
+
# drupal install devel ./sites/all/modules
|
36
|
+
#
|
37
|
+
# Install a module when in the 'modules directory
|
38
|
+
# drupal install devel
|
39
|
+
#
|
40
|
+
|
34
41
|
require 'optparse'
|
35
42
|
require 'ostruct'
|
36
43
|
require File.dirname(__FILE__) + '/drupal/create_module'
|
@@ -41,7 +48,7 @@ class Drupal
|
|
41
48
|
|
42
49
|
MAJOR = 0
|
43
50
|
MINOR = 0
|
44
|
-
TINY =
|
51
|
+
TINY = 3
|
45
52
|
VERSION = [MAJOR, MINOR, TINY].join('.')
|
46
53
|
|
47
54
|
# Run the drupal development tool.
|
@@ -94,6 +101,7 @@ class Drupal
|
|
94
101
|
|
95
102
|
create module <module_name> [dir] Generates a module skeleton from an interactive wizard. Current directory unless [dir] is specified.
|
96
103
|
todo list [total] Displays list of todo items or a total.
|
104
|
+
install <core | project> [dir] Install a Drupal project or core itself to [dir]
|
97
105
|
|
98
106
|
EXAMPLES:
|
99
107
|
|
@@ -111,6 +119,15 @@ class Drupal
|
|
111
119
|
|
112
120
|
View total todo items only.
|
113
121
|
drupal todo list total ./sites/all/modules
|
122
|
+
|
123
|
+
Install drupal core to the current directory.
|
124
|
+
drupal install core
|
125
|
+
|
126
|
+
Install a module to the modules folder in my new installation (from drupal root)
|
127
|
+
drupal install devel ./sites/all/modules
|
128
|
+
|
129
|
+
Install a module when in the 'modules directory
|
130
|
+
drupal install devel
|
114
131
|
|
115
132
|
USAGE
|
116
133
|
exit
|
data/lib/drupal/install.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
|
2
|
-
require '
|
2
|
+
require 'zlib'
|
3
|
+
require 'net/http'
|
3
4
|
|
4
5
|
class Drupal
|
5
6
|
class Install
|
@@ -7,13 +8,11 @@ class Drupal
|
|
7
8
|
# Attempt to download core installation or module.
|
8
9
|
def run(arguments)
|
9
10
|
@project = arguments[0]
|
10
|
-
@dest = arguments[1] || '.'
|
11
|
+
@dest = arguments[1] || '.' # TODO: strip leading /
|
12
|
+
abort "Destination #{@dest} is not a directory." unless File.directory?(@dest)
|
11
13
|
abort 'Project name required (core | <project>).' if arguments.empty?
|
12
|
-
print "Destination '#{@dest}' is not empty, are you sure you want continue installation? (yes|no): " unless destination_empty?
|
13
|
-
confirmation = STDIN.gets unless destination_empty?
|
14
|
-
abort 'Installation aborted.' unless confirmation =~ /y|yes/
|
15
14
|
check_core
|
16
|
-
install_project
|
15
|
+
install_project
|
17
16
|
end
|
18
17
|
|
19
18
|
def debug(message)
|
@@ -30,14 +29,6 @@ class Drupal
|
|
30
29
|
@project = 'drupal' if @project =~ /^core|drupal$/
|
31
30
|
end
|
32
31
|
|
33
|
-
# Determine if the project passed actually exists as a module.
|
34
|
-
def project_exists?
|
35
|
-
debug 'Locating project page'
|
36
|
-
if !uri_available?("http://drupal.org/project/#{@project}")
|
37
|
-
abort "Failed to find #{@project}."
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
32
|
# Check if a uri is available.
|
42
33
|
def uri_available?(uri)
|
43
34
|
open(uri) rescue false
|
@@ -45,11 +36,45 @@ class Drupal
|
|
45
36
|
|
46
37
|
# Install project.
|
47
38
|
def install_project
|
48
|
-
debug "
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
39
|
+
debug "Locating #{@project} page"
|
40
|
+
# Locate tarball from project page
|
41
|
+
begin
|
42
|
+
response = Net::HTTP.get_response(URI.parse("http://drupal.org/project/#{@project}"))
|
43
|
+
@markup = response.body
|
44
|
+
# TODO: check 404
|
45
|
+
debug 'Located the project page'
|
46
|
+
rescue
|
47
|
+
puts 'Failed to request page'
|
48
|
+
end
|
49
|
+
@markup.match /(#{@project}-6(?:.*?)\.gz)/
|
50
|
+
@tarball = $1
|
51
|
+
@tarpath = File.expand_path("#{@dest}/#{@tarball}")
|
52
|
+
abort "Failed to find Drupal 6 tar of #{@project}" if @tarball.nil?
|
53
|
+
debug "Found tarball #{@tarball}"
|
54
|
+
|
55
|
+
# Fetch tarball
|
56
|
+
begin
|
57
|
+
response = Net::HTTP.get_response(URI.parse("http://ftp.drupal.org/files/projects/#{@tarball}"))
|
58
|
+
File.open(@tarpath, 'w') do |f|
|
59
|
+
f.write response.body
|
60
|
+
end
|
61
|
+
debug "Copied tarball to #{@tarpath}"
|
62
|
+
rescue
|
63
|
+
abort "Failed to find #{@tarpath}"
|
64
|
+
end
|
65
|
+
|
66
|
+
# Extract tarball
|
67
|
+
@pwd = File.dirname(__FILE__)
|
68
|
+
Dir.chdir File.dirname(@tarpath)
|
69
|
+
Kernel.system "tar -xf #{@tarpath}" rescue abort "Failed to extract #{@tarpath}"
|
70
|
+
Dir.chdir @pwd
|
71
|
+
|
72
|
+
# Remove tarball
|
73
|
+
Kernel.system "rm #{@tarpath}" rescue abort "Failed to remove #{@tarpath}"
|
74
|
+
|
75
|
+
# Installation complete
|
76
|
+
debug "Project installed to #{File.dirname(@tarpath)}" unless @dest == '.'
|
77
|
+
debug 'Installation complete'
|
53
78
|
end
|
54
79
|
end
|
55
80
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: visionmedia-drupal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tj@vision-media.ca
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-10-03 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|