RubyApp 0.0.74 → 0.0.75

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,13 +3,11 @@
3
3
  .DS_Store
4
4
  .idea
5
5
  .sass-cache
6
- *.gem
7
- *.log
8
- *.pid
9
- failures_in.txt
10
- failures_out.txt
11
6
  lib/ruby_app/elements/pages/authentication/open_id/associations
12
7
  lib/ruby_app/elements/pages/authentication/open_id/nonces
13
8
  lib/ruby_app/elements/pages/authentication/open_id/temp
14
9
  log
15
10
  sandbox
11
+ *.gem
12
+ *.log
13
+ *.pid
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- RubyApp (0.0.74)
4
+ RubyApp (0.0.75)
5
5
  BlueCloth
6
6
  chronic
7
7
  chronic_duration
@@ -55,14 +55,12 @@ module RubyApp
55
55
  @@_application = nil
56
56
  end
57
57
 
58
- def self.create_cache(path, root, *formats)
59
- RubyApp::Application.destroy_cache(path)
58
+ def self.create_cache(path, root)
60
59
  RubyApp::Application.create!
61
60
  begin
62
61
  Dir.glob(File.join(path, %w[** *.rb])).each do |element_file|
63
62
  RubyApp::Request.create!
64
63
  begin
65
- RubyApp::Request.cache = true
66
64
  require element_file
67
65
  element_class = element_file.gsub(root, '')
68
66
  element_class = element_class.gsub(/^\//, '')
@@ -70,9 +68,9 @@ module RubyApp
70
68
  element_class = RubyApp::Application.upcode(element_class)
71
69
  begin
72
70
  element_class = eval(element_class)
73
- (formats.empty? ? [:css, :js] : formats).each do |format|
71
+ [:css, :js].each do |format|
74
72
  begin
75
- element_class.render(format)
73
+ element_class.render(format, true)
76
74
  rescue Exception => exception
77
75
  puts "#{element_class}.render(#{format.inspect}) exception=#{exception.message}"
78
76
  end
@@ -90,9 +88,8 @@ module RubyApp
90
88
  end
91
89
 
92
90
  def self.destroy_cache(path)
93
- Dir.glob(File.join(path, %w[** .cache *])).each do |file|
94
- puts "Removing #{file.inspect}"
95
- FileUtils.rm(file)
91
+ Dir.glob(File.join(path, %w[** .cache])).each do |directory|
92
+ FileUtils.rm_r(directory)
96
93
  end
97
94
  end
98
95
 
@@ -14,6 +14,21 @@
14
14
  :type => 'text/javascript'}
15
15
  %title
16
16
  = yield(:title) || self.translate.title
17
+ /
18
+ RubyApp::Session.data
19
+ %meta{:name => :session_id, :content => RubyApp::Session.session_id}
20
+ - RubyApp::Session.data.each do |name, value|
21
+ %meta{:name => name, :content => value}
22
+ /
23
+ RubyApp::Language
24
+ %meta{:name => :locale, :content => RubyApp::Language.locale.code}
25
+ /
26
+ RubyApp::Elements::Base::BasePage#data
27
+ - self.data.each do |name, value|
28
+ %meta{:name => name, :content => value}
29
+ /
30
+ (other)
31
+ %meta{:name => :event_error_message, :content => RubyApp::Elements::Base::BasePage.translate.event_error_message}
17
32
  %body
18
33
  %div.body
19
34
  = yield :body
@@ -2,10 +2,12 @@
2
2
  :plain
3
3
  // #{__FILE__}
4
4
  var RubyApp = new function() {
5
- this.translation = {code:'#{RubyApp::Language.locale.code}', title:'#{RubyApp::Language.locale.title}'},
6
- this.interval = #{self.interval * 1000},
7
5
  this._interval = 0,
8
6
  this._waitCount = 0,
7
+ this.getData = function(name, _default) {
8
+ var value = $('meta[name="' + name + '"]').attr('content');
9
+ return value == undefined ? _default : value;
10
+ },
9
11
  this.maximize = function(selector) {
10
12
  var element = $(selector);
11
13
  var _document = $(document);
@@ -39,7 +41,7 @@
39
41
  this.status = function(message) {
40
42
  },
41
43
  this.queueEvent = function(event, wait) {
42
- event.session_id = '#{RubyApp::Session.session_id}';
44
+ event.session_id = RubyApp.getData('session_id', null);
43
45
  event.now = new Date().toString();
44
46
  RubyApp.log('RubyApp.queueEvent ENQUEUE event.class=' + event._class + ' wait=' + wait);
45
47
  $(window).queue( function() {
@@ -54,8 +56,8 @@
54
56
  } )
55
57
  .error( function(request, message, exception) {
56
58
  RubyApp.log('RubyApp.queueEvent ERROR event.class=' + event._class + ' wait=' + wait);
57
- if (#{RubyApp::Session['show_event_error'] || 'false'} == true)
58
- RubyApp.confirm_refresh(#{RubyApp::Elements::Base::BasePage.translate.error.to_json});
59
+ if (RubyApp.getData('event_error', true) == true)
60
+ RubyApp.confirm_refresh(RubyApp.getData('event_error_message', null));
59
61
  } )
60
62
  .complete( function() {
61
63
  RubyApp.log('RubyApp.queueEvent COMPLETE event.class=' + event._class + ' wait=' + wait);
@@ -108,7 +110,7 @@
108
110
  RubyApp._waitCount --;
109
111
  },
110
112
  this.showDialog = function(id) {
111
- request = $.ajax({type:'GET', url:'/#{RubyApp::Language.locale.code}/elements/' + id + '.html', wait:true});
113
+ request = $.ajax({type:'GET', url:'/' + RubyApp.getData('locale', 'en') + '/elements/' + id + '.html', wait:true});
112
114
  request
113
115
  .success( function(dialog) {
114
116
  var overlay = $('body div.overlay');
@@ -133,7 +135,7 @@
133
135
  RubyApp.queueEvent({_class:'RubyApp::Elements::Dialog::HiddenEvent', source_id:id}, false);
134
136
  },
135
137
  this.updateElement = function(id) {
136
- request = $.ajax({type:'GET', url:'/#{RubyApp::Language.locale.code}/elements/' + id + '.html', wait:true});
138
+ request = $.ajax({type:'GET', url:'/' + RubyApp.getData('locale', 'en') + '/elements/' + id + '.html', wait:true});
137
139
  request
138
140
  .success( function(content) {
139
141
  $('#'+id).replaceWith(content);
@@ -170,15 +172,16 @@
170
172
 
171
173
  $(window).load(function() {
172
174
  RubyApp.queueEvent({_class:'RubyApp::Elements::Page::LoadedEvent', source_id:$('html').attr('id')}, false);
173
- if ( RubyApp.interval > 0 ) {
175
+ interval = parseInt(RubyApp.getData('interval', 0)) * 1000;
176
+ if ( interval > 0 ) {
174
177
  RubyApp._interval = window.setInterval(function() {
175
178
  RubyApp.queueEvent({_class:'RubyApp::Elements::Page::TriggeredEvent', source_id:$('html').attr('id')}, false);
176
- }, RubyApp.interval);
179
+ }, interval);
177
180
  }
178
181
  });
179
182
 
180
183
  $(window).unload(function() {
181
- if ( RubyApp.interval > 0 ) {
184
+ if ( RubyApp._interval != 0 ) {
182
185
  window.clearInterval(RubyApp._interval);
183
186
  $(window).clearQueue();
184
187
  }
@@ -10,8 +10,10 @@ module RubyApp
10
10
  module Base
11
11
  require 'ruby_app/element'
12
12
  require 'ruby_app/language'
13
+ require 'ruby_app/mixins/hash_mixin'
13
14
 
14
15
  class BasePage < RubyApp::Element
16
+ include RubyApp::Mixins::HashMixin
15
17
 
16
18
  class LoadedEvent < RubyApp::Element::Event
17
19
 
@@ -31,14 +33,30 @@ module RubyApp
31
33
 
32
34
  template_path(:all, File.dirname(__FILE__))
33
35
 
34
- attr_accessor :interval
36
+ attr_reader :data
35
37
 
36
38
  event :loaded
37
39
  event :triggered
38
40
 
39
41
  def initialize
40
42
  super
41
- @interval = 0
43
+ @data = {}
44
+ end
45
+
46
+ def [](key)
47
+ @data[key]
48
+ end
49
+
50
+ def []=(key, value)
51
+ @data[key] = value
52
+ end
53
+
54
+ def interval
55
+ return data[:interval]
56
+ end
57
+
58
+ def interval=(value)
59
+ data[:interval] = value
42
60
  end
43
61
 
44
62
  protected
@@ -22,7 +22,7 @@ module RubyApp
22
22
  RubyApp::Request.content_for(self, name, value, &block)
23
23
  end
24
24
 
25
- def render(format)
25
+ def render(format, write_cache = false)
26
26
  cache = self.is_a?(Class) ? self.get_cache(format) : self.class.get_cache(format)
27
27
  if File.exists?(cache)
28
28
  self.rendered?(cache) do
@@ -50,7 +50,7 @@ module RubyApp
50
50
  end
51
51
  RubyApp::Request.content_for(self, template, content)
52
52
  end
53
- if cache && RubyApp::Request.cache?
53
+ if cache && write_cache
54
54
  RubyApp::Log.debug("#{RubyApp::Log.prefix(self, __method__)} File.open(#{cache.inspect}, 'w')")
55
55
  cache_directory = File.dirname(cache)
56
56
  Dir.mkdir(cache_directory) unless File.exists?(cache_directory)
@@ -14,8 +14,6 @@ module RubyApp
14
14
  class Request < ::Rack::Request
15
15
  extend RubyApp::Mixins::DelegateMixin
16
16
 
17
- attr_accessor :cache
18
-
19
17
  def language
20
18
  self.fullpath =~ /^\/([^\/\?]+)/
21
19
  $1 || RubyApp::Application.options.default_language
@@ -29,10 +27,6 @@ module RubyApp
29
27
  self.params
30
28
  end
31
29
 
32
- def cache?
33
- return self.cache
34
- end
35
-
36
30
  def rendered?(template)
37
31
  @rendered.key?(template)
38
32
  end
@@ -3,6 +3,7 @@ module RubyApp
3
3
  require 'ruby_app/log'
4
4
  require 'ruby_app/mixins/configure_mixin'
5
5
  require 'ruby_app/mixins/delegate_mixin'
6
+ require 'ruby_app/mixins/hash_mixin'
6
7
  require 'ruby_app/mixins/translate_mixin'
7
8
  require 'ruby_app/request'
8
9
 
@@ -22,8 +23,8 @@ module RubyApp
22
23
 
23
24
  end
24
25
 
25
- attr_reader :session_id, :pages
26
- attr_accessor :identity, :data
26
+ attr_reader :session_id, :pages, :data
27
+ attr_accessor :identity
27
28
 
28
29
  def initialize(session_id, page = nil, data = {})
29
30
  require 'ruby_app/elements/pages/default_page'
@@ -24,6 +24,21 @@
24
24
  :type => 'text/javascript'}
25
25
  %title
26
26
  = yield(:title) || self.translate.title
27
+ /
28
+ RubyApp::Session.data
29
+ %meta{:name => :session_id, :content => RubyApp::Session.session_id}
30
+ - RubyApp::Session.data.each do |name, value|
31
+ %meta{:name => name, :content => value}
32
+ /
33
+ RubyApp::Language
34
+ %meta{:name => :locale, :content => RubyApp::Language.locale.code}
35
+ /
36
+ RubyApp::Elements::Base::BasePage#data
37
+ - self.data.each do |name, value|
38
+ %meta{:name => name, :content => value}
39
+ /
40
+ (other)
41
+ %meta{:name => :event_error_message, :content => RubyApp::Elements::Base::BasePage.translate.event_error_message}
27
42
  %body
28
43
  %div.body
29
44
  = yield :body
@@ -5,7 +5,7 @@ ruby_app:
5
5
  elements:
6
6
  base:
7
7
  base_page:
8
- error: An error occurred sending the event. The page will refresh so you can try again.
8
+ event_error_message: An error occurred sending the event. The page will refresh so you can try again.
9
9
  dialogs:
10
10
  base:
11
11
  base_ok_dialog:
@@ -1,4 +1,4 @@
1
1
  module RubyApp
2
- VERSION = "0.0.74"
2
+ VERSION = "0.0.75"
3
3
  ROOT = File.expand_path(File.dirname(__FILE__))
4
4
  end
data/rakefile CHANGED
@@ -15,7 +15,7 @@ namespace :ruby_app do
15
15
  end
16
16
 
17
17
  desc 'Run'
18
- task :run do |task|
18
+ task :run => ['ruby_app:cache:create'] do |task|
19
19
  system("cd ./lib/ruby_app && clear && bundle exec ../../bin/ruby_app run")
20
20
  end
21
21
 
@@ -25,7 +25,7 @@ namespace :ruby_app do
25
25
  end
26
26
 
27
27
  desc 'Push to master, release, and increment version'
28
- task :release do |task|
28
+ task :release => ['ruby_app:cache:create'] do |task|
29
29
  system "git push origin master && rake release"
30
30
  version_file = File.join(RubyApp::ROOT, %w[version.rb])
31
31
  RubyApp::VERSION =~ /(\d+)\.(\d+)\.(\d+)/
@@ -35,24 +35,9 @@ namespace :ruby_app do
35
35
 
36
36
  namespace :test do
37
37
 
38
- namespace :features do
39
-
40
- desc 'Run feature tests generating a failure file'
41
- task :all do |task|
42
- system("bundle exec cucumber --format rerun --tags ~@broken --require features --out failures_out.txt; cat failures_out.txt")
43
- end
44
-
45
- desc 'Rerun failed feature tests'
46
- task :failures do |task|
47
- system("mv failures_out.txt failures_in.txt; bundle exec cucumber --format rerun --tags ~@broken --require features --out failures_out.txt @failures_in.txt; cat failures_out.txt")
48
- end
49
-
50
- desc 'Run feature tests for the given feature file'
51
- task :one, :file do |task, arguments|
52
- system("bundle exec cucumber --format pretty --tags ~@broken --require features '#{arguments.file}'")
53
- end
54
-
55
- end
38
+ desc 'Run all tests'
39
+ task :all => ['test:specs',
40
+ 'test:features']
56
41
 
57
42
  desc 'Run RSpec tests'
58
43
  task :specs, :file, :line do |task, arguments|
@@ -67,17 +52,22 @@ namespace :ruby_app do
67
52
  end
68
53
  end
69
54
 
70
- desc 'Run all tests'
71
- task :all => ['ruby_app:test:specs',
72
- 'ruby_app:test:features:all']
55
+ desc 'Run feature tests for all features or the given feature file'
56
+ task :features, :file do |task, arguments|
57
+ unless arguments.file
58
+ system("bundle exec cucumber --format pretty --tags ~@broken --require features")
59
+ else
60
+ system("bundle exec cucumber --format pretty --tags ~@broken --require features '#{arguments.file}'")
61
+ end
62
+ end
73
63
 
74
64
  end
75
65
 
76
66
  namespace :cache do
77
67
 
78
68
  desc 'Create element cache'
79
- task :create do |task|
80
- RubyApp::Application.create_cache(File.join(File.dirname(__FILE__), %w[lib ruby_app elements]), File.join(File.dirname(__FILE__), %w[lib]))
69
+ task :create => ['ruby_app:cache:destroy'] do |task|
70
+ RubyApp::Application.create_cache(File.join(File.dirname(__FILE__), %w[lib ruby_app elements pages]), File.join(File.dirname(__FILE__), %w[lib]))
81
71
  end
82
72
 
83
73
  desc 'Delete element cache'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: RubyApp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 139
4
+ hash: 137
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 74
10
- version: 0.0.74
9
+ - 75
10
+ version: 0.0.75
11
11
  platform: ruby
12
12
  authors:
13
13
  - Frank G. Ficnar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-18 00:00:00 Z
18
+ date: 2012-01-20 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  prerelease: false