caterpillar 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog ADDED
@@ -0,0 +1,8 @@
1
+ = 0.9.1
2
+ Released at 2008-12-18
3
+ - task to install the Rails-portlet
4
+
5
+
6
+ = 0.9.0
7
+ Released at 2008-12-17
8
+ - the initial release
@@ -6,11 +6,15 @@ Caterpillar::Config.new do |portlet|
6
6
  portlet.container = Liferay
7
7
  # portlet.container.version = '5.1.1'
8
8
 
9
- # Dince liferay-display-ext.xml does not exist, all portlets are categorized in
10
- # liferay-display.xml. If you intend to keep other portlets still intact,
11
- # you need to specify the location of WEB-INF.
12
- # No changes are made to any of the files in this directory.
13
- portlet.container.WEB_INF = '/usr/local/liferay/webapps/ROOT/WEB-INF/'
9
+ # If you want to install the Rails-portlet JAR into the container, the container
10
+ # WEB-INF will be used.
11
+ #
12
+ # Since liferay-display-ext.xml does not exist, all portlets are categorized in
13
+ # liferay-display.xml. Caterpillar parses this file and appends Rails portlets.
14
+ #
15
+ # No changes are made to any of the files in this directory while making XML,
16
+ # only the deploy and install tasks make any changes.
17
+ portlet.container.root = '/usr/local/liferay/'
14
18
 
15
19
  # The hostname and port.
16
20
  # By default the values are taken from the request.
data/lib/caterpillar.rb CHANGED
@@ -4,12 +4,14 @@
4
4
  # software license details.
5
5
  #++
6
6
 
7
-
8
7
  module Caterpillar
8
+ VERSION='0.9.1'
9
9
  end
10
10
 
11
- file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
12
- this_dir = File.dirname(File.expand_path(file))
11
+ this_file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
12
+ this_dir = File.dirname(File.expand_path(this_file))
13
+
14
+ CATERPILLAR_LIBS=this_dir
13
15
 
14
16
  require 'find'
15
17
 
@@ -22,6 +24,7 @@ Find.find(this_dir) do |file|
22
24
  next
23
25
  end
24
26
  else
25
- require file if file[/.rb$/]
27
+ # do not require this file twice
28
+ require file if file[/.rb$/] and File.basename(file) != File.basename(this_file)
26
29
  end
27
- end
30
+ end
@@ -12,15 +12,21 @@ module Caterpillar
12
12
  # Liferay version
13
13
  attr_accessor :version
14
14
 
15
- # The location of Liferay's WEB-INF folder for XML analyzation
16
- attr_accessor :WEB_INF
15
+ # the installation directory
16
+ attr_accessor :root
17
17
 
18
18
  def initialize(version='5.1.1')
19
19
  @version = version
20
20
  end
21
21
 
22
+ # The location of Liferay's WEB-INF folder for XML analyzation.
23
+ # This is relative to installation directory (self.root)
24
+ def WEB_INF
25
+ raise 'Configure container root folder' unless self.root
26
+ File.join(self.root,'webapps','ROOT','WEB-INF')
27
+ end
28
+
22
29
  def analyze(type)
23
- raise 'Configure WEB-INF' unless self.WEB_INF
24
30
  require 'hpricot'
25
31
  return nil unless type==:native
26
32
 
@@ -38,7 +38,6 @@ module Caterpillar
38
38
 
39
39
  # The main task.
40
40
  # Reads the configuration file and launches appropriate tasks.
41
- # Defines the rake task prefix 'jsr'.
42
41
  def initialize(name = :usage, config = nil, tasks = :define_tasks)
43
42
  @name = name
44
43
  @config = Util.eval_configuration(config)
@@ -62,18 +61,21 @@ module Caterpillar
62
61
  define_liferayportlets_task
63
62
  define_migrate_task
64
63
  define_rollback_task
64
+ define_jar_install_task
65
+ define_jar_uninstall_task
66
+ define_jar_version_task
65
67
  end
66
68
 
67
69
  # the main XML generator task
68
70
  def define_main_task
69
71
  desc 'Create all XML files according to configuration'
70
- tasks = [:parse,"#{@name}:portletxml"]
72
+ tasks = [:parse,"#{@name}:portlet"]
71
73
  if @config.container.kind_of? Liferay
72
- tasks << "#{@name}:liferayportletappxml"
73
- tasks << "#{@name}:liferaydisplayxml"
74
+ tasks << "#{@name}:liferayportletapp"
75
+ tasks << "#{@name}:liferaydisplay"
74
76
  end
75
77
  tasks << "portlets" # finally print produced portlets
76
- task :jsr => tasks
78
+ task :xml => tasks
77
79
  end
78
80
 
79
81
  def define_usage_task
@@ -155,7 +157,7 @@ module Caterpillar
155
157
 
156
158
  # Writes the portlet.xml file
157
159
  def define_portletxml_task
158
- @name = :jsr
160
+ @name = :xml
159
161
  # set the output filename
160
162
  if @config.container.kind_of? Liferay
161
163
  file = 'portlet-ext.xml'
@@ -163,8 +165,8 @@ module Caterpillar
163
165
  file = 'portlet.xml'
164
166
  end
165
167
  with_namespace_and_config do |name, config|
166
- desc "Create JSR286 portlet XML"
167
- task "portletxml" do
168
+ desc 'Create JSR286 portlet XML'
169
+ task :portlet do
168
170
  system('touch %s' % file)
169
171
  f=File.open(file,'w')
170
172
  f.write Portlet.xml(@portlets)
@@ -176,11 +178,11 @@ module Caterpillar
176
178
 
177
179
  # Writes liferay-portlet-ext.xml
178
180
  def define_liferayportletappxml_task
179
- @name = :jsr
181
+ @name = :xml
180
182
  file = 'liferay-portlet-ext.xml'
181
183
  with_namespace_and_config do |name, config|
182
184
  desc 'Create Liferay portlet XML'
183
- task "liferayportletappxml" do
185
+ task :liferayportletapp do
184
186
  system('touch %s' % file)
185
187
  f=File.open(file,'w')
186
188
  f.write config.container.portletapp_xml(@portlets)
@@ -192,11 +194,11 @@ module Caterpillar
192
194
 
193
195
  # Writes liferay-display.xml
194
196
  def define_liferaydisplayxml_task
195
- @name = :jsr
197
+ @name = :xml
196
198
  file = 'liferay-display.xml'
197
199
  with_namespace_and_config do |name, config|
198
- desc "Create Liferay display XML"
199
- task "liferaydisplayxml" do
200
+ desc 'Create Liferay display XML'
201
+ task :liferaydisplay do
200
202
  system('touch %s' % file)
201
203
  f=File.open(file,'w')
202
204
  f.write config.container.display_xml(@portlets)
@@ -207,10 +209,10 @@ module Caterpillar
207
209
  end
208
210
 
209
211
  def define_liferayportlets_task
210
- @name = :jsr
212
+ @name = :liferay
211
213
  with_namespace_and_config do |name, config|
212
- desc 'Analyses native Liferay portlets XML'
213
- task "portlets" do
214
+ desc 'Analyses native Liferay portlet-display XML'
215
+ task :portlets do
214
216
  @portlets = config.container.analyze(:native)
215
217
  print_portlets(@portlets)
216
218
  end
@@ -241,6 +243,7 @@ module Caterpillar
241
243
  end
242
244
 
243
245
  def define_rollback_task
246
+ @name = :db
244
247
  with_namespace_and_config do |name, config|
245
248
  desc "Wipes out Caterpillar database tables"
246
249
  task :rollback => :environment do
@@ -254,6 +257,100 @@ module Caterpillar
254
257
  end
255
258
  end
256
259
 
260
+ def define_jar_install_task
261
+ @name = :jar
262
+ with_namespace_and_config do |name, config|
263
+ desc 'Installs Rails-portlet JAR into the portlet container'
264
+ task :install do
265
+ raise 'Only Liferay is supported' unless @config.container.kind_of? Liferay
266
+ require 'find'
267
+
268
+ portlet_jar = nil
269
+ old_jar = nil
270
+ version = nil
271
+ source = File.join(CATERPILLAR_LIBS,'java')
272
+ target = File.join(@config.container.WEB_INF,'lib')
273
+
274
+ Find.find(source) do |file|
275
+ if File.basename(file) =~ /rails-portlet/
276
+ portlet_jar = file
277
+ version = file[/(\d.\d.\d).jar/,1]
278
+ end
279
+ end
280
+
281
+ # check for previous installs..
282
+ Find.find(target) do |file|
283
+ if File.basename(file) =~ /rails-portlet/
284
+ old_version = file[/(\d.\d.\d).jar/,1]
285
+ # check if there's an update available
286
+ if version.gsub(/\./,'').to_i > old_version.gsub(/\./,'').to_i
287
+ info 'Rails-portlet version %s is found, but an update is available.' % old_version
288
+ old_jar = file
289
+ else
290
+ info 'Rails-portlet version %s is already installed.' % old_version
291
+ exit 0
292
+ end
293
+ end
294
+ end
295
+
296
+ info 'Installing Rails-portlet version %s to %s' % [version, target]
297
+ system('cp %s %s' % [portlet_jar,target])
298
+ if old_jar
299
+ info 'Removing old version'
300
+ system('rm -f %s' % old_jar)
301
+ end
302
+
303
+ end
304
+ end
305
+ end
306
+
307
+ def define_jar_uninstall_task
308
+ @name = :jar
309
+ with_namespace_and_config do |name, config|
310
+ desc 'Uninstalls Rails-portlet JAR from the portlet container'
311
+ task :uninstall do
312
+ raise 'Only Liferay is supported' unless @config.container.kind_of? Liferay
313
+ require 'find'
314
+ target = File.join(@config.container.WEB_INF,'lib')
315
+
316
+ Find.find(target) do |file|
317
+ if File.basename(file) =~ /rails-portlet/
318
+ version = file[/(\d.\d.\d).jar/,1]
319
+ info 'Uninstalling Rails-portlet version %s from %s' % [version, target]
320
+ system('rm -f %s' % file)
321
+ exit 0
322
+ end
323
+ end
324
+
325
+ info 'Rails-portlet was not found in %s' % target
326
+ exit 1
327
+ end
328
+ end
329
+ end
330
+
331
+ def define_jar_version_task
332
+ @name = :jar
333
+ with_namespace_and_config do |name, config|
334
+ desc 'Checks the installed Rails-portlet version'
335
+ task :version do
336
+ raise 'Only Liferay is supported' unless @config.container.kind_of? Liferay
337
+ require 'find'
338
+ target = File.join(@config.container.WEB_INF,'lib')
339
+
340
+ Find.find(target) do |file|
341
+ if File.basename(file) =~ /rails-portlet/
342
+ version = file[/(\d.\d.\d).jar/,1]
343
+ info 'Rails-portlet version %s found in %s' % [version, target]
344
+ exit 0
345
+ end
346
+ end
347
+
348
+ info 'Rails-portlet was not found in %s' % target
349
+ exit 1
350
+ end
351
+ end
352
+ end
353
+
257
354
  def with_namespace_and_config
258
355
  name, config = @name, @config
259
356
  namespace name do
@@ -279,6 +376,10 @@ module Caterpillar
279
376
  end
280
377
  end
281
378
 
379
+ def info(msg)
380
+ STDOUT.puts ' * ' + msg
381
+ end
382
+
282
383
 
283
384
 
284
385
  end
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caterpillar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Lammentausta
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-17 00:00:00 +02:00
12
+ date: 2008-12-18 00:00:00 +02:00
13
13
  default_executable: caterpillar
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -43,15 +43,17 @@ extra_rdoc_files:
43
43
  - LICENSES.txt
44
44
  files:
45
45
  - Rakefile
46
+ - ChangeLog
46
47
  - install.rb
47
48
  - init.rb
49
+ - lib/java
50
+ - lib/java/rails-portlet-0.5.2.jar
48
51
  - lib/caterpillar
49
52
  - lib/caterpillar/config.rb
50
53
  - lib/caterpillar/navigation.rb
51
54
  - lib/caterpillar/liferay_portlet.rb
52
55
  - lib/caterpillar/usage.rb
53
56
  - lib/caterpillar/liferay.rb
54
- - lib/caterpillar/version.rb
55
57
  - lib/caterpillar/portlet.rb
56
58
  - lib/caterpillar/parser.rb
57
59
  - lib/caterpillar/util.rb
@@ -1,9 +0,0 @@
1
- #--
2
- # (c) Copyright 2008 Mikael Lammentausta
3
- # See the file LICENSES.txt included with the distribution for
4
- # software license details.
5
- #++
6
-
7
- module Caterpillar
8
- VERSION = '0.9.0'
9
- end