spiderfw 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ = 0.6.1
2
+ == 2 May, 2011
3
+ * Bundler support
4
+ * Bugfixes
5
+
1
6
  = 0.6.0
2
7
  == 20 April, 2011
3
8
  * Test support
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.6.1
@@ -83,6 +83,7 @@ Spider.Widget = Class.extend({
83
83
  startup: function(){},
84
84
  ready: function(){},
85
85
  update: function(){},
86
+ afterReplace: function(){},
86
87
 
87
88
  replaceHTML: function(html){
88
89
  var el = $(html);
@@ -92,7 +93,7 @@ Spider.Widget = Class.extend({
92
93
  this.ready();
93
94
  Spider.newHTML(this.el);
94
95
  this.applyReady();
95
-
96
+ this.afterReplace();
96
97
  },
97
98
 
98
99
  replaceEl: function(el){
@@ -101,6 +102,7 @@ Spider.Widget = Class.extend({
101
102
  this.update();
102
103
  this.ready();
103
104
  this.applyReady();
105
+ this.afterReplace();
104
106
  },
105
107
 
106
108
  findWidgets: function(){
@@ -1,6 +1,7 @@
1
1
  .spider.forms.form .errors{
2
2
  margin: 0px 15px;
3
3
  padding: 10px;
4
+ border: 1px solid #D9766F;
4
5
  }
5
6
 
6
7
  .spider.forms.form .errors ul{
@@ -28,7 +29,10 @@
28
29
  }
29
30
 
30
31
  .spider.forms.form .row.error label{
31
- padding-left: 4px;
32
+ }
33
+
34
+ .spider.forms.form .row.error input{
35
+ background-color: #FF9999;
32
36
  }
33
37
 
34
38
  .spider.forms.form .row{
@@ -287,6 +287,11 @@ module Spider; module Forms
287
287
  input.condition = el.condition if el.condition
288
288
  end
289
289
  @multipart = true if input.needs_multipart?
290
+ if errs = @errors[el.name]
291
+ while err = errs.pop
292
+ input.add_error(err)
293
+ end
294
+ end
290
295
  return input
291
296
  end
292
297
 
@@ -406,7 +411,11 @@ module Spider; module Forms
406
411
  def add_error(message, element_name=nil, exception=nil)
407
412
  @error = true
408
413
  @errors[element_name] ||= []
409
- @errors[element_name] << message
414
+ if @inputs[element_name]
415
+ @inputs[element_name].add_error(message)
416
+ else
417
+ @errors[element_name] << message
418
+ end
410
419
  end
411
420
 
412
421
  def is_new?
@@ -1,6 +1,5 @@
1
1
  <div class="{ @widget[:css_class] }">
2
2
  <tpl:assets widgets="forms:datetime,forms:file,forms:select,forms:search-select,forms:textarea" />
3
-
4
3
  <tpl:asset type="css" src="css/form.css" />
5
4
  <tpl:asset type="js" src="form.js" />
6
5
  <div sp:if="@error" class='errors'>
@@ -0,0 +1 @@
1
+ gem "mail", "~> 2.3.0", :groups => [:messenger, :messenger_email, :email]
@@ -21,8 +21,6 @@ require 'apps/messenger/messenger'
21
21
  require 'apps/messenger/controllers/messenger_controller'
22
22
  require 'apps/messenger/controllers/mixins/messenger_helper'
23
23
 
24
- # gem dependencies: mailfactory for sending email from templates
25
-
26
24
  available_backends = {}
27
25
  base = File.join(Spider::Messenger.path, 'backends')
28
26
  Dir.new(base).each do |type|
@@ -7,6 +7,11 @@ module Spider; module Messenger; module Backends; module Email
7
7
 
8
8
  def self.send_message(msg)
9
9
  Spider.logger.debug("Sending e-mail #{msg.ticket}")
10
+ if msg.to.blank?
11
+ Spider.logger.error("Message has no recipient, can't send:")
12
+ Spider.logger.error(msg)
13
+ raise "E-mail with no recipient"
14
+ end
10
15
  mail = prepare_mail(msg)
11
16
  mail.delivery_method :smtp, {
12
17
  :address => Spider.conf.get('messenger.smtp.address'),
@@ -23,7 +23,7 @@ module Spider
23
23
 
24
24
  def self.process_queues
25
25
  self.queues.each_key do |queue|
26
- self.process_queue(queue)
26
+ self.process_queue(queue) unless Spider.conf.get("messenger.#{queue}.backends").empty?
27
27
  end
28
28
  end
29
29
 
@@ -69,6 +69,19 @@ module Spider
69
69
  else
70
70
  backend_response = exc ? exc.to_s : res
71
71
  msg.add_failure(backend_response)
72
+ msg.attempts ||= 0
73
+ msg.attempts += 1
74
+ msg.last_try = now
75
+ if (exc)
76
+ msg.backend_response = exc.to_s
77
+ else
78
+ msg.backend_response = res
79
+ end
80
+ if (msg.attempts >= Spider.conf.get("messenger.#{queue}.retries"))
81
+ msg.next_try = nil
82
+ else
83
+ msg.next_try = msg.last_try.to_local_time + (msg.attempts * Spider.conf.get("messenger.#{queue}.retry_time") * 60)
84
+ end
72
85
  msg.save
73
86
  end
74
87
 
@@ -79,9 +79,10 @@ module Spider
79
79
  load @scripts_dir+'/'+script
80
80
  end
81
81
  end
82
- Spider::Worker.every("#{Spider.conf.get('worker.jobs_interval')}s") do
83
- Spider::Worker.run_jobs
84
- end
82
+ # TODO: remove worker jobs completely, they are a bad idea
83
+ #Spider::Worker.every("#{Spider.conf.get('worker.jobs_interval')}s") do
84
+ # Spider::Worker.run_jobs
85
+ #end
85
86
  Spider.apps.each do |name, mod|
86
87
  if File.directory?(mod.path+'/config/worker')
87
88
  Dir.glob(mod.path+'/config/worker/*.rb').each do |path|
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ self.instance_eval(Bundler.read_file('spider.gemfile'), 'spider.gemfile', 1) if File.exist?('spider.gemfile')
@@ -0,0 +1,30 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'fssm', :group => :devel
4
+
5
+ gem "mysql", :groups => [:db, :mysql]
6
+
7
+ gem "json", :platforms => [:mri_18, :mri_19]
8
+ gem "mongrel"
9
+ gem "ripl", :platforms => [:ruby, :mingw]
10
+ gem "ripl-irb", :platforms => [:ruby, :mingw]
11
+ gem "ripl-multi_line", :platforms => [:ruby, :mingw]
12
+ gem "cldr"
13
+ gem "ruby-debug", :group => :devel, :platforms => [:mri_18]
14
+ gem "ruby-debug19", :group => :devel, :platforms => [:mri_19], :require => 'ruby-debug'
15
+ gem "ruby-prof", :group => :devel
16
+ gem "rspec", :group => :test
17
+ gem "cucumber", '~> 0.10.0', :group => :test
18
+ gem "capybara", :group => :test
19
+ gem "yui-compressor", :group => :production
20
+
21
+ if RUBY_PLATFORM =~ /darwin/
22
+ gem "rb-fsevent", :group => :devel, :platforms => [:mri]
23
+ end
24
+ if RUBY_PLATFORM =~ /linux/
25
+ gem "rb-inotify", :group => :devel, :platforms => [:mri]
26
+ end
27
+
28
+ Dir.glob("apps/*/Gemfile") do |f|
29
+ self.instance_eval(Bundler.read_file(f), f, 1)
30
+ end
@@ -891,7 +891,7 @@ module Spider; module Model; module Mappers
891
891
  set.each do |set_obj|
892
892
  sub_task = MapperTask.new(set_obj, :save)
893
893
  set_obj.set_modified(element.reverse) if element.reverse
894
- if set_obj.class.attributes[:junction] && delete_ass
894
+ if set_obj.class.attributes[:sub_model] && delete_ass
895
895
  set_obj.class.primary_keys.each{ |pk| set_obj.set(pk, nil) }
896
896
  end
897
897
  if prev_task
@@ -295,14 +295,16 @@ module Spider; module Model
295
295
  vobj.set(:version_date, DateTime.now)
296
296
  # vobj.set(:version_comment, comment)
297
297
  object.mapper.do_update(object)
298
+ dup = false
298
299
  begin
299
300
  vobj.mapper.insert(vobj)
300
301
  #vobj.insert
301
302
  rescue Spider::Model::Storage::DuplicateKey
303
+ dup = true
302
304
  Spider.logger.error("Duplicate version for #{self}")
303
305
  end
304
306
  object.autoload(true)
305
- object.trigger(:version_saved)
307
+ object.trigger(:version_saved) unless dup
306
308
  end
307
309
 
308
310
  def save_junction_version(object)
@@ -556,4 +558,4 @@ module Spider; module Model
556
558
  end
557
559
  end
558
560
 
559
- end; end
561
+ end; end
@@ -7,6 +7,7 @@ module Spider
7
7
 
8
8
  def self.install(specs, home_path, options)
9
9
  options[:use_git] = true unless options[:use_git] == false
10
+ options[:home_path] = home_path
10
11
  specs = [specs] unless specs.is_a?(Array)
11
12
  pre_setup(specs, options)
12
13
  specs.each do |spec|
@@ -16,6 +17,7 @@ module Spider
16
17
  pack_install(spec, home_path, options)
17
18
  end
18
19
  end
20
+ post_setup(specs, options)
19
21
  end
20
22
 
21
23
  def self.git_install(spec, home_path, options={})
@@ -67,23 +69,19 @@ module Spider
67
69
  require 'rubygems/command.rb'
68
70
  require 'rubygems/dependency_installer.rb'
69
71
  unless options[:no_gems]
70
- gems = specs.map{ |s| s.gems }
71
- # unless options[:no_optional_gems]
72
- # gems += specs.map{ |s| s.gems_optional }
73
- # end
74
- gems = gems.flatten.uniq
75
- gems.reject!{ |g| Gem.available?(g) }
76
- unless gems.empty?
77
- puts _("Installing the following needed gems:")
78
- puts gems.inspect
72
+ unless Gem.available?('bundler')
73
+ puts _("Installing bundler gem")
79
74
  inst = Gem::DependencyInstaller.new
80
- gems.each do |g|
81
- inst.install g
82
- end
75
+ inst.install 'bundler'
83
76
  end
84
77
  end
85
78
  end
86
79
 
80
+ def self.post_setup(specs, options={})
81
+ require 'bundler'
82
+ Bundler::Installer.install(options[:home_path], Bundler.definitions, {})
83
+ end
84
+
87
85
  def self.update(specs, home_path, options)
88
86
  options[:use_git] = true unless options[:use_git] == false
89
87
  specs = [specs] unless specs.is_a?(Array)
@@ -4,7 +4,6 @@ require 'rubygems'
4
4
  require 'find'
5
5
  require 'fileutils'
6
6
  require 'pathname'
7
- require 'bundler/setup'
8
7
  require 'spiderfw/autoload'
9
8
  require 'spiderfw/requires'
10
9
 
@@ -67,6 +66,9 @@ module Spider
67
66
  $SPIDER_CONFIG_SETS.each{ |set| @configuration.include_set(set) }
68
67
  end
69
68
  init_file = File.join($SPIDER_RUN_PATH, 'init.rb')
69
+ ENV['BUNDLE_GEMFILE'] ||= File.join($SPIDER_RUN_PATH, 'Gemfile')
70
+ require 'bundler/setup' if File.exists? ENV['BUNDLE_GEMFILE']
71
+
70
72
  if File.exist?(init_file)
71
73
  @home.instance_eval(File.read(init_file), init_file)
72
74
  end
@@ -609,9 +611,8 @@ module Spider
609
611
  if Spider.conf.get('debugger.start') || File.exists?(File.join($SPIDER_RUN_PATH,'tmp', 'debug.txt'))
610
612
  init_debug
611
613
  end
612
- if (mode != 'production')
613
- Spider.paths[:var] = File.join(Spider.paths[:var], mode)
614
- end
614
+ Spider.paths[:var] = File.join(Spider.paths[:var], mode) if mode != 'production'
615
+ Bundler.require(:default, @runmode.to_sym) if defined?(Bundler)
615
616
  end
616
617
 
617
618
  def init_debug
@@ -214,7 +214,7 @@ module Spider
214
214
  dest = "#{pub_dest}/#{compiled_name}"
215
215
  File.cp(tmp_combined, combined)
216
216
  File.unlink(tmp_combined)
217
- compressor = YUI::JavaScriptCompressor.new("charset" => "UTF-8")
217
+ compressor = ::YUI::JavaScriptCompressor.new("charset" => "UTF-8")
218
218
  io = open(combined, 'r')
219
219
  cjs = compressor.compress(io)
220
220
  open(dest, 'w') do |f|
@@ -225,6 +225,7 @@ module Spider
225
225
  end
226
226
 
227
227
  def compress_css(cpr)
228
+ require 'yui/compressor'
228
229
 
229
230
  pub_dest = Spider::HomeController.pub_path+'/'+COMPILED_FOLDER
230
231
  name = cpr[:name]
@@ -319,7 +320,7 @@ module Spider
319
320
  dest = "#{pub_dest}/#{compiled_name}"
320
321
  File.cp(tmp_combined, combined)
321
322
  File.unlink(tmp_combined)
322
- compressor = YUI::CssCompressor.new("charset" => "UTF-8")
323
+ compressor = ::YUI::CssCompressor.new("charset" => "UTF-8")
323
324
  io = open(combined, 'r')
324
325
  cjs = compressor.compress(io)
325
326
  open(dest, 'w') do |f|
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spiderfw
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 0
10
- version: 0.6.0
9
+ - 1
10
+ version: 0.6.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ivan Pirlik
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-20 00:00:00 +02:00
18
+ date: 2011-05-02 00:00:00 +02:00
19
19
  default_executable: spider
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -872,6 +872,7 @@ files:
872
872
  - apps/messenger/controllers/messenger_controller.rb
873
873
  - apps/messenger/controllers/mixins/messenger_helper.rb
874
874
  - apps/messenger/data/locale/it/LC_MESSAGES/spider_messenger.mo
875
+ - apps/messenger/Gemfile
875
876
  - apps/messenger/lib/email_backend.rb
876
877
  - apps/messenger/lib/sms_backend.rb
877
878
  - apps/messenger/messenger.rb
@@ -940,7 +941,9 @@ files:
940
941
  - blueprints/app/views/__APP__.layout.shtml
941
942
  - blueprints/app/views/index.shtml
942
943
  - blueprints/home/config/config.yml
944
+ - blueprints/home/Gemfile
943
945
  - blueprints/home/init.rb
946
+ - blueprints/home/spider.gemfile
944
947
  - blueprints/install/config.ru
945
948
  - data/locale/it/LC_MESSAGES/spider.mo
946
949
  - data/locale/it/LC_MESSAGES/spider_auth.mo