equipment 1.4.96 → 1.5.103

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,5 +1,14 @@
1
1
  = Equipment Changelog
2
2
 
3
+ == Version 1.5.103
4
+
5
+ Cleanup and Camping 1.5 compatiblity release.
6
+
7
+ * lib/ext/form_helper.rb : Removed dependency on Ext::ActiveRecord.
8
+ * lib/ext/active_record.rb : Removed since Camping now has better AR integration.
9
+ * lib/ext/forward.rb : Print the errors on STDERR instead of STDOUT.
10
+ * examples/xulapp.rb : Testing XUL output for Camping. Not really functionnal.
11
+
3
12
  == Version 1.4.96
4
13
 
5
14
  This is a hotfix release. When using Ext::Forward, you could have infinite
data/README CHANGED
@@ -10,7 +10,6 @@ tools.
10
10
 
11
11
  Working equipment :
12
12
 
13
- * Ext::ActiveRecord : Decoupled ActiveRecord. One database per app. Does not force SQLite.
14
13
  * Ext::AppUtil : Access to your app from a controller extension.
15
14
  * Ext::BasicAuth : Handles HttpBasic authentication.
16
15
  * Ext::ErubyView : Add Erb/Erubis template handling to your app.
data/Rakefile CHANGED
@@ -28,7 +28,7 @@ PKG_NAME = "equipment"
28
28
  PKG_DESC = <<-EOF
29
29
  Equipment is a set of extensions you can use with your Camping apps.
30
30
  EOF
31
- PKG_VERSION = "1.4.96"
31
+ PKG_VERSION = "1.5.103"
32
32
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
33
33
  PKG_FILES = FileList[
34
34
  '[A-Z]*',
@@ -101,7 +101,7 @@ spec = Gem::Specification.new do |s|
101
101
 
102
102
  ### Dependencies
103
103
 
104
- s.add_dependency("camping", "= 1.4.157")
104
+ s.add_dependency("camping", ">= 1.5")
105
105
  end
106
106
 
107
107
  desc "Build Gem"
data/TODO CHANGED
@@ -1,14 +1,16 @@
1
1
  == The global TODO list for Equipment
2
2
 
3
3
  * More docs
4
- * Fix Og so that it works better with Camping
4
+ * Change the extension mechanism
5
+
5
6
  * Finish NegociateContent
6
7
  * Finish View content-type negociation
7
8
  * Finish Resource and Scaffolding
8
9
  * Finish Controls
10
+
9
11
  * TemplateView is almost useless
12
+
10
13
  * Fix XmlView
11
- * Logging mechanism
12
- * Run mode like in Rails
14
+
13
15
  * Debug mode
14
16
 
@@ -32,7 +32,7 @@ module CampExt
32
32
  # This will allow you to chain create methods.
33
33
  # It also restores the the missing modules.
34
34
  #
35
- # == Examplanation
35
+ # == Explanation
36
36
  #
37
37
  # When calling YourApp.create, the call order is :
38
38
  # * YourApp.create
@@ -13,7 +13,12 @@ require 'camping_ext'
13
13
  # will make it ready to provide new functionnalities to Camping apps.
14
14
  module Equipment
15
15
  LIB_PATH = File.expand_path(File.dirname(__FILE__))
16
- DATA_PATH = File.join(LIB_PATH, '..', 'share')
16
+
17
+ if File.exists?('/usr/share/equipment')
18
+ DATA_PATH = '/usr/share/equipment'
19
+ else
20
+ DATA_PATH = File.join(LIB_PATH, '..', 'data', 'equipment')
21
+ end
17
22
 
18
23
  attr_accessor :debug
19
24
 
@@ -59,7 +59,7 @@ module Ext
59
59
  # Only store Strings.
60
60
  class Flasher
61
61
  def initialize(cookies_in, cookies_out)
62
- @in, @out, @tmp = cookies_in.dup, cookies_out
62
+ @in, @out = cookies_in.dup, cookies_out
63
63
  @in.each do |k,v|
64
64
  @in[k] = nil if v.empty?
65
65
  end
@@ -1,5 +1,4 @@
1
1
  require 'equipment'
2
- require 'ext/active_record'
3
2
 
4
3
  module Ext
5
4
  # Hey a FormHelper.
@@ -21,7 +20,6 @@ module Ext
21
20
  #
22
21
  module FormHelpers
23
22
  extend Equipment
24
- depends_on ActiveRecord
25
23
 
26
24
  module Helpers
27
25
  # No relations yet
@@ -59,8 +59,8 @@ module Ext
59
59
 
60
60
  retry
61
61
  rescue => x
62
- pp x if $DBG
63
- pp x.backtrace if $DBG
62
+ STDERR.puts x.inspect if $DBG
63
+ STDERR.puts x.backtrace.join("\n") if $DBG
64
64
  k, a, m = self::Controllers::ServerError, [k,m,x], 'GET'
65
65
  k.new(r,e,m).service(*a)
66
66
  end
@@ -1,6 +1,8 @@
1
1
  require 'equipment'
2
2
  require 'og'
3
3
 
4
+ puts "WARNING : #{__FILE__} unsupported"
5
+
4
6
  module Ext
5
7
 
6
8
  # Add some facilities for using Og in Camping. Stores the manager outside of
@@ -3,6 +3,8 @@ require 'ext/flash'
3
3
  require 'ext/og'
4
4
  require 'ext/resource'
5
5
 
6
+ puts "WARNING : #{__FILE__} unsupported"
7
+
6
8
  module Ext
7
9
 
8
10
  # Allows Og Entities scaffolding. Not working yet.
@@ -2,6 +2,8 @@ require 'equipment'
2
2
  require 'ext/og'
3
3
  require 'glue/timestamped'
4
4
 
5
+ puts "WARNING : #{__FILE__} unsupported"
6
+
5
7
  module Ext
6
8
 
7
9
  # It's like Camping's Session but works with Og.
@@ -28,7 +28,7 @@ module Ext
28
28
  module CClassMethods
29
29
  def create
30
30
  puts "INFO: View#create called" if $DBG
31
- self::V.send :include, self::Helpers, self::Controllers
31
+ self::V.send :include, self::Helpers, self::Controllers, self::Views
32
32
  super
33
33
  end
34
34
  end
@@ -47,6 +47,8 @@ module Ext
47
47
  #
48
48
  # Layout was renamed to _layout because it is a partial. Also partials
49
49
  # don't use the layout feature (so layout doesn't have a layout)
50
+ #
51
+ =begin
50
52
  def method_missing(*a,&b)
51
53
  a.shift if a[0]==:render
52
54
  m=app::Mab.new({},self)
@@ -54,8 +56,6 @@ module Ext
54
56
  s=m.layout{s} if m.respond_to?:layout and a[0].to_s[0] != ?_
55
57
  s
56
58
  end
57
-
58
- =begin
59
59
  def render(m, *a, &b)
60
60
  str = view(m, *a, &b)
61
61
  # allow content-negotiation
@@ -0,0 +1,17 @@
1
+
2
+ module Ext
3
+ module XulView
4
+ extend Equipment
5
+ depends_on View
6
+
7
+ module Base
8
+ def render_xul(name)
9
+ @headers['Content-Type'] = 'application/vnd.mozilla.xul+xml'
10
+ view = app::V.new
11
+ view.instance_variables_send(self)
12
+ view.send(name)
13
+ end
14
+ end
15
+
16
+ end
17
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: equipment
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.4.96
7
- date: 2006-10-12 00:00:00 +02:00
6
+ version: 1.5.103
7
+ date: 2006-10-25 00:00:00 +02:00
8
8
  summary: Equipment (for Camping)
9
9
  require_paths:
10
10
  - lib
@@ -64,16 +64,10 @@ files:
64
64
  - lib/ext/og_scaffold.rb
65
65
  - lib/ext/security.rb
66
66
  - lib/ext/og_session.rb
67
- - lib/ext/active_record.rb
68
67
  - lib/ext/view.rb
69
68
  - lib/ext/view_slot.rb
70
69
  - lib/ext/command.rb
71
- - share/js
72
- - share/js/prototype.js
73
- - share/js/date_ext.js
74
- - share/js/event-selector.js
75
- - share/js/jquery.js
76
- - share/js/es-confirm.js
70
+ - lib/ext/xul_view.rb
77
71
  test_files: []
78
72
 
79
73
  rdoc_options:
@@ -98,7 +92,7 @@ dependencies:
98
92
  version_requirement:
99
93
  version_requirements: !ruby/object:Gem::Version::Requirement
100
94
  requirements:
101
- - - "="
95
+ - - ">="
102
96
  - !ruby/object:Gem::Version
103
- version: 1.4.157
97
+ version: "1.5"
104
98
  version:
@@ -1,146 +0,0 @@
1
- # Override the camping's autoload
2
- #autoload :ActiveRecord,'camping_ext'
3
-
4
- require 'equipment'
5
-
6
- begin
7
- ActiveRecord # loads 'camping/db' if camping is loaded.
8
- rescue NameError # camping not used
9
- class MissingLibrary < Exception #:nodoc: all
10
- end
11
- begin
12
- require 'active_record'
13
- rescue LoadError => e
14
- raise MissingLibrary, "ActiveRecord could not be loaded (is it installed?): #{e.message}"
15
- end
16
- end
17
-
18
- # restoring some adapters
19
- #RAILS_CONNECTION_ADAPTERS.replace ["mysql", "postgresql", "sqlite", "firebird", "sqlserver", "db2", "oracle", "sybase", "openbase"]
20
-
21
- #RAILS_CONNECTION_ADAPTERS.each do |adapter|
22
- # require "active_record/connection_adapters/" + adapter + "_adapter"
23
- #end
24
-
25
-
26
- module Ext
27
- # ActiveRecord extension. Overrides Camping's behaviour.
28
- #
29
- # NOTE : This Equipment is usable without Camping.
30
- #
31
- # == Dependencies
32
- #
33
- # * ActiveRecord
34
- # * Equipment
35
- #
36
- module ActiveRecord
37
- extend Equipment
38
-
39
- def self.equip(app)
40
- unless app.const_defined? :C
41
- app.module_eval "C=self"
42
- end
43
- app.module_eval "module Models;end"
44
- super
45
- end
46
-
47
- module Models
48
- class AllYourBase < ::ActiveRecord::Base;end
49
- class << AllYourBase
50
- # This is a facility to create your schemas.
51
- #
52
- # == Example (in your models)
53
- #
54
- # class Post < Base
55
- # self.schema do |c|
56
- # c.create_table table_name, :force=>true do |t|
57
- # t.column :title, :string, :limit => 255
58
- # t.column :body, :text
59
- # end
60
- # end
61
- # end
62
- #
63
- def schema(&block)
64
- @schema = block if block_given?
65
- @schema
66
- end
67
-
68
- # This method checks if your table exists, otherwise it calls
69
- # the #schema with the model's connection.
70
- def check_create
71
- if schema and connection and not table_exists?
72
- schema.call(connection)
73
- reset_column_information
74
- end
75
- end
76
-
77
- # The default prefix for Camping model classes is the topmost module name lowercase
78
- # and followed with an underscore.
79
- #
80
- # Tepee::Models::Page.table_name_prefix
81
- # #=> "tepee_pages"
82
- #
83
- def table_name_prefix
84
- "#{name[/\w+/]}_".downcase.sub(/^(activerecord|camping)_/i,'')
85
- end
86
-
87
- # I has to override this method too to get the right table name
88
- # working
89
- def reset_table_name #:nodoc:
90
- table_name = Inflector.underscore(Inflector.demodulize(self.name))
91
- table_name = Inflector.pluralize(table_name) if pluralize_table_names
92
- name = "#{table_name_prefix}#{table_name}#{table_name_suffix}"
93
- set_table_name(name)
94
- name
95
- end
96
-
97
- end
98
- end
99
-
100
- # Class methods for you app
101
- module CClassMethods
102
- # If set, #create will launch your database with those params.
103
- attr_accessor :database
104
-
105
- # Set if #create initialized your database.
106
- attr_reader :manager
107
-
108
- # Tries to connect and create the databases.
109
- def create
110
- puts "INFO: ActiveRecord#create called" if $DBG
111
-
112
- if self.database and not @manager
113
-
114
- # Loads the adapter dynamically
115
- adapter = self.database[:adapter] || self.database['adapter']
116
- unless adapter.nil? or RAILS_CONNECTION_ADAPTERS.include? adapter
117
- require "active_record/connection_adapters/" + adapter + "_adapter"
118
- RAILS_CONNECTION_ADAPTERS << adapter
119
- end
120
-
121
- @manager = self::Models::AllYourBase.establish_connection self.database
122
- puts "INFO: ActiveRecord connection established : #{@manager.inspect}" if $DBG
123
- case @logger
124
- when Logger
125
- self::Models::AllYourBase.logger = @logger
126
- when String
127
- self::Models::AllYourBase.logger = Logger.new(@logger == "-" ? STDOUT : @logger)
128
- else
129
- self::Models::AllYourBase.logger = Logger.new(STDOUT)
130
- end
131
- end
132
-
133
- # run check_create on models
134
- self::Models.constants.each do |c|
135
- if c != 'Base'
136
- c = self::Models.const_get(c)
137
- c.check_create if c.respond_to? :check_create
138
- end
139
- end
140
-
141
- super
142
- end
143
- end
144
- end
145
- end
146
-
@@ -1,234 +0,0 @@
1
-
2
- // BEGIN: DATE OBJECT PATCHES
3
-
4
- /** Adds the number of days array to the Date object. */
5
- Date._MD = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
6
-
7
- /** Constants used for time computations */
8
- Date.SECOND = 1000 /* milliseconds */;
9
- Date.MINUTE = 60 * Date.SECOND;
10
- Date.HOUR = 60 * Date.MINUTE;
11
- Date.DAY = 24 * Date.HOUR;
12
- Date.WEEK = 7 * Date.DAY;
13
-
14
- Date.parseDate = function(str, fmt) {
15
- var today = new Date();
16
- var y = 0;
17
- var m = -1;
18
- var d = 0;
19
- var a = str.split(/\W+/);
20
- var b = fmt.match(/%./g);
21
- var i = 0, j = 0;
22
- var hr = 0;
23
- var min = 0;
24
- for (i = 0; i < a.length; ++i) {
25
- if (!a[i])
26
- continue;
27
- switch (b[i]) {
28
- case "%d":
29
- case "%e":
30
- d = parseInt(a[i], 10);
31
- break;
32
-
33
- case "%m":
34
- m = parseInt(a[i], 10) - 1;
35
- break;
36
-
37
- case "%Y":
38
- case "%y":
39
- y = parseInt(a[i], 10);
40
- (y < 100) && (y += (y > 29) ? 1900 : 2000);
41
- break;
42
-
43
- case "%b":
44
- case "%B":
45
- for (j = 0; j < 12; ++j) {
46
- if (Calendar._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { m = j; break; }
47
- }
48
- break;
49
-
50
- case "%H":
51
- case "%I":
52
- case "%k":
53
- case "%l":
54
- hr = parseInt(a[i], 10);
55
- break;
56
-
57
- case "%P":
58
- case "%p":
59
- if (/pm/i.test(a[i]) && hr < 12)
60
- hr += 12;
61
- else if (/am/i.test(a[i]) && hr >= 12)
62
- hr -= 12;
63
- break;
64
-
65
- case "%M":
66
- min = parseInt(a[i], 10);
67
- break;
68
- }
69
- }
70
- if (isNaN(y)) y = today.getFullYear();
71
- if (isNaN(m)) m = today.getMonth();
72
- if (isNaN(d)) d = today.getDate();
73
- if (isNaN(hr)) hr = today.getHours();
74
- if (isNaN(min)) min = today.getMinutes();
75
- if (y != 0 && m != -1 && d != 0)
76
- return new Date(y, m, d, hr, min, 0);
77
- y = 0; m = -1; d = 0;
78
- for (i = 0; i < a.length; ++i) {
79
- if (a[i].search(/[a-zA-Z]+/) != -1) {
80
- var t = -1;
81
- for (j = 0; j < 12; ++j) {
82
- if (Calendar._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { t = j; break; }
83
- }
84
- if (t != -1) {
85
- if (m != -1) {
86
- d = m+1;
87
- }
88
- m = t;
89
- }
90
- } else if (parseInt(a[i], 10) <= 12 && m == -1) {
91
- m = a[i]-1;
92
- } else if (parseInt(a[i], 10) > 31 && y == 0) {
93
- y = parseInt(a[i], 10);
94
- (y < 100) && (y += (y > 29) ? 1900 : 2000);
95
- } else if (d == 0) {
96
- d = a[i];
97
- }
98
- }
99
- if (y == 0)
100
- y = today.getFullYear();
101
- if (m != -1 && d != 0)
102
- return new Date(y, m, d, hr, min, 0);
103
- return today;
104
- };
105
-
106
- /** Returns the number of days in the current month */
107
- Date.prototype.getMonthDays = function(month) {
108
- var year = this.getFullYear();
109
- if (typeof month == "undefined") {
110
- month = this.getMonth();
111
- }
112
- if (((0 == (year%4)) && ( (0 != (year%100)) || (0 == (year%400)))) && month == 1) {
113
- return 29;
114
- } else {
115
- return Date._MD[month];
116
- }
117
- };
118
-
119
- /** Returns the number of day in the year. */
120
- Date.prototype.getDayOfYear = function() {
121
- var now = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
122
- var then = new Date(this.getFullYear(), 0, 0, 0, 0, 0);
123
- var time = now - then;
124
- return Math.floor(time / Date.DAY);
125
- };
126
-
127
- /** Returns the number of the week in year, as defined in ISO 8601. */
128
- Date.prototype.getWeekNumber = function() {
129
- var d = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
130
- var DoW = d.getDay();
131
- d.setDate(d.getDate() - (DoW + 6) % 7 + 3); // Nearest Thu
132
- var ms = d.valueOf(); // GMT
133
- d.setMonth(0);
134
- d.setDate(4); // Thu in Week 1
135
- return Math.round((ms - d.valueOf()) / (7 * 864e5)) + 1;
136
- };
137
-
138
- /** Checks date and time equality */
139
- Date.prototype.equalsTo = function(date) {
140
- return ((this.getFullYear() == date.getFullYear()) &&
141
- (this.getMonth() == date.getMonth()) &&
142
- (this.getDate() == date.getDate()) &&
143
- (this.getHours() == date.getHours()) &&
144
- (this.getMinutes() == date.getMinutes()));
145
- };
146
-
147
- /** Set only the year, month, date parts (keep existing time) */
148
- Date.prototype.setDateOnly = function(date) {
149
- var tmp = new Date(date);
150
- this.setDate(1);
151
- this.setFullYear(tmp.getFullYear());
152
- this.setMonth(tmp.getMonth());
153
- this.setDate(tmp.getDate());
154
- };
155
-
156
- /** Prints the date in a string according to the given format. */
157
- Date.prototype.print = function (str) {
158
- var m = this.getMonth();
159
- var d = this.getDate();
160
- var y = this.getFullYear();
161
- var wn = this.getWeekNumber();
162
- var w = this.getDay();
163
- var s = {};
164
- var hr = this.getHours();
165
- var pm = (hr >= 12);
166
- var ir = (pm) ? (hr - 12) : hr;
167
- var dy = this.getDayOfYear();
168
- if (ir == 0)
169
- ir = 12;
170
- var min = this.getMinutes();
171
- var sec = this.getSeconds();
172
- // s["%a"] = Calendar._SDN[w]; // abbreviated weekday name [FIXME: I18N]
173
- // s["%A"] = Calendar._DN[w]; // full weekday name
174
- // s["%b"] = Calendar._SMN[m]; // abbreviated month name [FIXME: I18N]
175
- // s["%B"] = Calendar._MN[m]; // full month name
176
- // FIXME: %c : preferred date and time representation for the current locale
177
- s["%C"] = 1 + Math.floor(y / 100); // the century number
178
- s["%d"] = (d < 10) ? ("0" + d) : d; // the day of the month (range 01 to 31)
179
- s["%e"] = d; // the day of the month (range 1 to 31)
180
- // FIXME: %D : american date style: %m/%d/%y
181
- // FIXME: %E, %F, %G, %g, %h (man strftime)
182
- s["%H"] = (hr < 10) ? ("0" + hr) : hr; // hour, range 00 to 23 (24h format)
183
- s["%I"] = (ir < 10) ? ("0" + ir) : ir; // hour, range 01 to 12 (12h format)
184
- s["%j"] = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy; // day of the year (range 001 to 366)
185
- s["%k"] = hr; // hour, range 0 to 23 (24h format)
186
- s["%l"] = ir; // hour, range 1 to 12 (12h format)
187
- s["%m"] = (m < 9) ? ("0" + (1+m)) : (1+m); // month, range 01 to 12
188
- s["%M"] = (min < 10) ? ("0" + min) : min; // minute, range 00 to 59
189
- s["%n"] = "\n"; // a newline character
190
- s["%p"] = pm ? "PM" : "AM";
191
- s["%P"] = pm ? "pm" : "am";
192
- // FIXME: %r : the time in am/pm notation %I:%M:%S %p
193
- // FIXME: %R : the time in 24-hour notation %H:%M
194
- s["%s"] = Math.floor(this.getTime() / 1000);
195
- s["%S"] = (sec < 10) ? ("0" + sec) : sec; // seconds, range 00 to 59
196
- s["%t"] = "\t"; // a tab character
197
- // FIXME: %T : the time in 24-hour notation (%H:%M:%S)
198
- s["%U"] = s["%W"] = s["%V"] = (wn < 10) ? ("0" + wn) : wn;
199
- s["%u"] = w + 1; // the day of the week (range 1 to 7, 1 = MON)
200
- s["%w"] = w; // the day of the week (range 0 to 6, 0 = SUN)
201
- // FIXME: %x : preferred date representation for the current locale without the time
202
- // FIXME: %X : preferred time representation for the current locale without the date
203
- s["%y"] = ('' + y).substr(2, 2); // year without the century (range 00 to 99)
204
- s["%Y"] = y; // year with the century
205
- s["%%"] = "%"; // a literal '%' character
206
-
207
- var re = /%./g;
208
- // if (!Calendar.is_ie5 && !Calendar.is_khtml)
209
- // return str.replace(re, function (par) { return s[par] || par; });
210
-
211
- var a = str.match(re);
212
- for (var i = 0; i < a.length; i++) {
213
- var tmp = s[a[i]];
214
- if (tmp) {
215
- re = new RegExp(a[i], 'g');
216
- str = str.replace(re, tmp);
217
- }
218
- }
219
-
220
- return str;
221
- };
222
-
223
- Date.prototype.__msh_oldSetFullYear = Date.prototype.setFullYear;
224
- Date.prototype.setFullYear = function(y) {
225
- var d = new Date(this);
226
- d.__msh_oldSetFullYear(y);
227
- if (d.getMonth() != this.getMonth())
228
- this.setDate(28);
229
- this.__msh_oldSetFullYear(y);
230
- };
231
-
232
- // END: DATE OBJECT PATCHES
233
-
234
-