RubyApp 0.0.91 → 0.2.0
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/.gitignore +0 -1
- data/.rvmrc +56 -1
- data/Gemfile.lock +22 -22
- data/bin/console.rb +9 -1
- data/bin/ruby_app +2 -24
- data/features/default.feature +1 -0
- data/features/elements/input.feature +2 -0
- data/features/elements/page.feature +0 -9
- data/features/step_definitions/default_macros.rb +1 -4
- data/features/step_definitions/default_steps.rb +1 -1
- data/lib/ruby_app.rb +8 -1
- data/lib/ruby_app/application.rb +5 -67
- data/lib/ruby_app/configuration.rb +2 -3
- data/lib/ruby_app/configuration.ru +32 -0
- data/lib/ruby_app/configuration.yml +28 -0
- data/lib/ruby_app/element.rb +12 -6
- data/lib/ruby_app/elements.rb +50 -0
- data/lib/ruby_app/elements/base/base_mail.rb +2 -2
- data/lib/ruby_app/elements/base/base_page.html.haml +1 -1
- data/lib/ruby_app/elements/base/base_page.js.haml +3 -3
- data/lib/ruby_app/elements/base/base_page.rb +2 -2
- data/lib/ruby_app/elements/dialogs/base/base_ok_dialog.rb +0 -1
- data/lib/ruby_app/elements/dialogs/blank_dialog.rb +1 -1
- data/lib/ruby_app/elements/dialogs/exception_dialog.rb +1 -2
- data/lib/ruby_app/elements/navigation/back_button.rb +1 -1
- data/lib/ruby_app/elements/navigation/base/base_breadcrumbs.rb +1 -0
- data/lib/ruby_app/elements/navigation/page_link.rb +1 -0
- data/lib/ruby_app/elements/pages/authentication/open_id/ax_authentication_page.rb +1 -1
- data/lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb +1 -3
- data/lib/ruby_app/elements/pages/authentication/open_id/email_authentication_page.rb +1 -1
- data/lib/ruby_app/elements/pages/authentication/open_id/sreg_authentication_page.rb +1 -1
- data/lib/ruby_app/elements/pages/base/base_blank_page.rb +0 -1
- data/lib/ruby_app/elements/pages/default_page.rb +2 -1
- data/lib/ruby_app/elements/pages/quit_page.html.haml +0 -3
- data/lib/ruby_app/elements/pages/quit_page.rb +0 -2
- data/lib/ruby_app/elements/pages/settings_page.rb +2 -1
- data/lib/ruby_app/elements/pages/test_pages.rb +9 -0
- data/lib/ruby_app/elements/pages/test_pages/button_test_page.rb +3 -5
- data/lib/ruby_app/elements/pages/test_pages/default_test_page.rb +10 -15
- data/lib/ruby_app/elements/pages/test_pages/dialog_test_page.rb +2 -8
- data/lib/ruby_app/elements/pages/test_pages/input_test_page.rb +2 -9
- data/lib/ruby_app/elements/pages/test_pages/link_test_page.rb +3 -5
- data/lib/ruby_app/elements/pages/test_pages/linked_test_page.rb +1 -2
- data/lib/ruby_app/elements/pages/test_pages/list_test_page.rb +4 -8
- data/lib/ruby_app/elements/pages/test_pages/markdown_test_page.rb +3 -4
- data/lib/ruby_app/elements/pages/test_pages/test_page.rb +3 -8
- data/lib/ruby_app/exceptions.rb +2 -0
- data/lib/ruby_app/exceptions/base/base_exception.rb +1 -1
- data/lib/ruby_app/language.rb +9 -15
- data/lib/ruby_app/log.rb +32 -28
- data/lib/ruby_app/mixins.rb +7 -0
- data/lib/ruby_app/mixins/configuration_mixin.rb +1 -1
- data/lib/ruby_app/mixins/delegate_mixin.rb +1 -1
- data/lib/ruby_app/mixins/hash_mixin.rb +1 -1
- data/lib/ruby_app/mixins/render_mixin.rb +37 -39
- data/lib/ruby_app/mixins/route_mixin.rb +1 -5
- data/lib/ruby_app/mixins/template_mixin.rb +4 -12
- data/lib/ruby_app/mixins/translate_mixin.rb +2 -2
- data/lib/ruby_app/rack.rb +8 -0
- data/lib/ruby_app/rack/application.rb +9 -5
- data/lib/ruby_app/rack/duration.rb +22 -0
- data/lib/ruby_app/rack/language.rb +26 -0
- data/lib/ruby_app/rack/memory.rb +22 -0
- data/lib/ruby_app/rack/request.rb +27 -0
- data/lib/ruby_app/rack/response.rb +26 -0
- data/lib/ruby_app/rack/route.rb +24 -87
- data/lib/ruby_app/rack/session.rb +31 -0
- data/lib/ruby_app/request.rb +4 -55
- data/lib/ruby_app/response.rb +58 -0
- data/lib/ruby_app/session.rb +102 -35
- data/lib/ruby_app/templates/application/Rakefile +1 -1
- data/lib/ruby_app/templates/application/configuration.ru +41 -0
- data/lib/ruby_app/templates/application/configuration.yml +16 -0
- data/lib/ruby_app/templates/application/console.rb +15 -10
- data/lib/ruby_app/templates/application/lib/_APPLICATION_DOWNCODE_.rb +3 -0
- data/lib/ruby_app/templates/application/lib/_APPLICATION_DOWNCODE_/application.rb +3 -3
- data/lib/ruby_app/templates/application/lib/_APPLICATION_DOWNCODE_/elements/pages/default_page.rb +1 -1
- data/lib/ruby_app/templates/application/lib/_APPLICATION_DOWNCODE_/session.rb +3 -3
- data/lib/ruby_app/templates/application/spec/application_spec.rb +17 -0
- data/lib/ruby_app/templates/application/spec/request_spec.rb +18 -0
- data/lib/ruby_app/templates/application/spec/support/shared.rb +34 -9
- data/lib/ruby_app/themes/mobile.rb +1 -17
- data/lib/ruby_app/themes/mobile/base/base_page.html.haml +1 -1
- data/lib/ruby_app/translations/en.yml +133 -144
- data/lib/ruby_app/version.rb +1 -1
- data/rakefile +1 -16
- data/spec/application_spec.rb +5 -13
- data/spec/elements/base_element.html.haml +5 -0
- data/spec/elements/container_element.html.haml +6 -0
- data/spec/elements/derived_element.html.haml +5 -0
- data/spec/elements/element_spec.rb +101 -0
- data/spec/request_spec.rb +6 -13
- data/spec/support/shared.rb +14 -6
- metadata +95 -125
- data/features/elements/pages/quit_page.feature +0 -8
- data/lib/ruby_app/config.ru +0 -25
- data/lib/ruby_app/config.yml +0 -16
- data/lib/ruby_app/elements/pages/test_pages/select_test_page.rb +0 -44
- data/lib/ruby_app/templates/application/config.ru +0 -40
- data/lib/ruby_app/templates/application/config.yml +0 -1
- data/lib/ruby_app/templates/page/_PAGE_DOWNCODE_.css.haml +0 -3
- data/lib/ruby_app/templates/page/_PAGE_DOWNCODE_.html.haml +0 -4
- data/lib/ruby_app/templates/page/_PAGE_DOWNCODE_.js.haml +0 -3
- data/lib/ruby_app/templates/page/_PAGE_DOWNCODE_.rb +0 -14
- data/spec/configuration_spec.rb +0 -25
- data/spec/element_spec.rb +0 -72
- data/spec/elements/navigation/breadcrumbs_spec.rb +0 -62
- data/spec/elements/page_spec.rb +0 -20
- data/spec/language_spec.rb +0 -25
- data/spec/log_spec.rb +0 -25
- data/spec/mixins/configuration_mixin_spec.rb +0 -24
- data/spec/mixins/delegate_mixin_spec.rb +0 -28
- data/spec/mixins/hash_mixin_spec.rb +0 -39
- data/spec/mixins/render_mixin_spec.rb +0 -127
- data/spec/mixins/route_mixin_spec.rb +0 -60
- data/spec/mixins/template_mixin_spec.rb +0 -78
- data/spec/mixins/test_a.css.haml +0 -4
- data/spec/mixins/test_a.html.haml +0 -2
- data/spec/mixins/test_a.js.haml +0 -4
- data/spec/mixins/test_b.css.haml +0 -4
- data/spec/mixins/test_b.html.haml +0 -3
- data/spec/mixins/test_b.js.haml +0 -4
- data/spec/mixins/test_c.css.haml +0 -4
- data/spec/mixins/test_c.html.haml +0 -2
- data/spec/mixins/test_c.js.haml +0 -4
- data/spec/mixins/translate_mixin_spec.rb +0 -25
- data/spec/session_spec.rb +0 -39
data/.gitignore
CHANGED
data/.rvmrc
CHANGED
|
@@ -1 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
|
4
|
+
# development environment upon cd'ing into the directory
|
|
5
|
+
|
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
|
|
7
|
+
# environment_id="ruby-1.9.3-p125@RubyApp"
|
|
8
|
+
environment_id="ruby-1.8.7-p352@RubyApp"
|
|
9
|
+
|
|
10
|
+
#
|
|
11
|
+
# Uncomment following line if you want options to be set only for given project.
|
|
12
|
+
#
|
|
13
|
+
# PROJECT_JRUBY_OPTS=( --1.9 )
|
|
14
|
+
|
|
15
|
+
#
|
|
16
|
+
# First we attempt to load the desired environment directly from the environment
|
|
17
|
+
# file. This is very fast and efficient compared to running through the entire
|
|
18
|
+
# CLI and selector. If you want feedback on which environment was used then
|
|
19
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
|
20
|
+
#
|
|
21
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
|
|
22
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
|
23
|
+
then
|
|
24
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
|
25
|
+
|
|
26
|
+
if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
|
|
27
|
+
then
|
|
28
|
+
. "${rvm_path:-$HOME/.rvm}/hooks/after_use"
|
|
29
|
+
fi
|
|
30
|
+
else
|
|
31
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
|
32
|
+
if ! rvm --create "$environment_id"
|
|
33
|
+
then
|
|
34
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
|
35
|
+
exit 1
|
|
36
|
+
fi
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
#
|
|
40
|
+
# If you use an RVM gemset file to install a list of gems (*.gems), you can have
|
|
41
|
+
# it be automatically loaded. Uncomment the following and adjust the filename if
|
|
42
|
+
# necessary.
|
|
43
|
+
#
|
|
44
|
+
# filename=".gems"
|
|
45
|
+
# if [[ -s "$filename" ]]
|
|
46
|
+
# then
|
|
47
|
+
# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
|
|
48
|
+
# fi
|
|
49
|
+
|
|
50
|
+
# If you use bundler, this might be useful to you:
|
|
51
|
+
# if command -v bundle && [[ -s Gemfile ]]
|
|
52
|
+
# then
|
|
53
|
+
# bundle install
|
|
54
|
+
# fi
|
|
55
|
+
|
|
56
|
+
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
RubyApp (0.0
|
|
4
|
+
RubyApp (0.2.0)
|
|
5
5
|
BlueCloth
|
|
6
6
|
chronic
|
|
7
7
|
chronic_duration
|
|
@@ -22,7 +22,7 @@ GEM
|
|
|
22
22
|
remote: http://rubygems.org/
|
|
23
23
|
specs:
|
|
24
24
|
BlueCloth (1.0.1)
|
|
25
|
-
addressable (2.2.
|
|
25
|
+
addressable (2.2.7)
|
|
26
26
|
builder (3.0.0)
|
|
27
27
|
capybara (1.1.2)
|
|
28
28
|
mime-types (>= 1.16)
|
|
@@ -31,15 +31,15 @@ GEM
|
|
|
31
31
|
rack-test (>= 0.5.4)
|
|
32
32
|
selenium-webdriver (~> 2.0)
|
|
33
33
|
xpath (~> 0.1.4)
|
|
34
|
-
childprocess (0.3.
|
|
34
|
+
childprocess (0.3.1)
|
|
35
35
|
ffi (~> 1.0.6)
|
|
36
36
|
chronic (0.6.7)
|
|
37
37
|
chronic_duration (0.9.6)
|
|
38
38
|
numerizer (~> 0.1.1)
|
|
39
|
-
cucumber (1.1.
|
|
39
|
+
cucumber (1.1.9)
|
|
40
40
|
builder (>= 2.1.2)
|
|
41
41
|
diff-lcs (>= 1.1.2)
|
|
42
|
-
gherkin (~> 2.
|
|
42
|
+
gherkin (~> 2.9.0)
|
|
43
43
|
json (>= 1.4.6)
|
|
44
44
|
term-ansicolor (>= 1.0.6)
|
|
45
45
|
diff-lcs (1.1.3)
|
|
@@ -47,15 +47,15 @@ GEM
|
|
|
47
47
|
ffi (1.0.11)
|
|
48
48
|
fileutils (0.7)
|
|
49
49
|
rmagick (>= 2.13.1)
|
|
50
|
-
gherkin (2.
|
|
50
|
+
gherkin (2.9.1)
|
|
51
51
|
json (>= 1.4.6)
|
|
52
52
|
haml (3.1.4)
|
|
53
53
|
json (1.6.5)
|
|
54
|
-
launchy (2.0
|
|
54
|
+
launchy (2.1.0)
|
|
55
55
|
addressable (~> 2.2.6)
|
|
56
56
|
mime-types (1.17.2)
|
|
57
|
-
multi_json (1.0
|
|
58
|
-
nokogiri (1.5.
|
|
57
|
+
multi_json (1.1.0)
|
|
58
|
+
nokogiri (1.5.2)
|
|
59
59
|
numerizer (0.1.1)
|
|
60
60
|
r18n-core (0.4.14)
|
|
61
61
|
rack (1.4.1)
|
|
@@ -63,22 +63,22 @@ GEM
|
|
|
63
63
|
rack (>= 1.0)
|
|
64
64
|
rake (0.9.2.2)
|
|
65
65
|
rmagick (2.13.1)
|
|
66
|
-
rspec (2.
|
|
67
|
-
rspec-core (~> 2.
|
|
68
|
-
rspec-expectations (~> 2.
|
|
69
|
-
rspec-mocks (~> 2.
|
|
70
|
-
rspec-core (2.
|
|
71
|
-
rspec-expectations (2.
|
|
72
|
-
diff-lcs (~> 1.1.
|
|
73
|
-
rspec-mocks (2.
|
|
66
|
+
rspec (2.9.0)
|
|
67
|
+
rspec-core (~> 2.9.0)
|
|
68
|
+
rspec-expectations (~> 2.9.0)
|
|
69
|
+
rspec-mocks (~> 2.9.0)
|
|
70
|
+
rspec-core (2.9.0)
|
|
71
|
+
rspec-expectations (2.9.0)
|
|
72
|
+
diff-lcs (~> 1.1.3)
|
|
73
|
+
rspec-mocks (2.9.0)
|
|
74
74
|
ruby-event (1.0.0)
|
|
75
75
|
ruby-openid (2.1.8)
|
|
76
|
-
rubyzip (0.9.
|
|
77
|
-
sass (3.1.
|
|
78
|
-
selenium-webdriver (2.
|
|
76
|
+
rubyzip (0.9.6.1)
|
|
77
|
+
sass (3.1.15)
|
|
78
|
+
selenium-webdriver (2.20.0)
|
|
79
79
|
childprocess (>= 0.2.5)
|
|
80
|
-
ffi (~> 1.0
|
|
81
|
-
multi_json (~> 1.0
|
|
80
|
+
ffi (~> 1.0)
|
|
81
|
+
multi_json (~> 1.0)
|
|
82
82
|
rubyzip
|
|
83
83
|
term-ansicolor (1.0.7)
|
|
84
84
|
xpath (0.1.4)
|
data/bin/console.rb
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
require 'rubygems'
|
|
2
2
|
require 'bundler/setup'
|
|
3
3
|
|
|
4
|
-
require 'ruby_app
|
|
4
|
+
require 'ruby_app'
|
|
5
5
|
|
|
6
6
|
puts "Running #{__FILE__.inspect}"
|
|
7
7
|
|
|
8
|
+
RubyApp::Configuration.load!([File.join(RubyApp::ROOT, %w[configuration.yml])])
|
|
9
|
+
RubyApp::Log.open!
|
|
8
10
|
RubyApp::Application.create!
|
|
11
|
+
|
|
12
|
+
at_exit do
|
|
13
|
+
RubyApp::Application.destroy!
|
|
14
|
+
RubyApp::Log.close!
|
|
15
|
+
RubyApp::Configuration.unload!
|
|
16
|
+
end
|
data/bin/ruby_app
CHANGED
|
@@ -17,9 +17,8 @@ usage: ruby_app <command> <arguments>
|
|
|
17
17
|
|
|
18
18
|
Available commands include:
|
|
19
19
|
create application Create a basic application in the current folder named <arguments>.
|
|
20
|
-
create page DISABLED: Create a baisc page consisting of .rb, .html, .css. and .js files (not implemented)
|
|
21
20
|
console Open an interactive console
|
|
22
|
-
run Run the application identified by the
|
|
21
|
+
run Run the application identified by the configuration.ru in <arguments>
|
|
23
22
|
|
|
24
23
|
USAGE
|
|
25
24
|
end
|
|
@@ -101,25 +100,6 @@ def create_application
|
|
|
101
100
|
copy_folder(source, full_folder, replacements)
|
|
102
101
|
end
|
|
103
102
|
|
|
104
|
-
#def create_page
|
|
105
|
-
# argument = $*[2]
|
|
106
|
-
# folder = File.dirname(File.join(File.join(FileUtils.pwd, %w[elements arguments]), downcode(argument).split('/')))
|
|
107
|
-
# namespace_class = "#{upcode(File.basename(FileUtils.pwd))}::Elements::Pages::#{upcode(argument)}"
|
|
108
|
-
# _class = namespace_class.split('::').last
|
|
109
|
-
# replacements = [
|
|
110
|
-
# {
|
|
111
|
-
# :pattern => /_PAGE_DOWNCODE_/,
|
|
112
|
-
# :text => downcode(_class)
|
|
113
|
-
# },
|
|
114
|
-
# {
|
|
115
|
-
# :pattern => /_PAGE_UPCODE_/,
|
|
116
|
-
# :text => _class
|
|
117
|
-
# }
|
|
118
|
-
# ]
|
|
119
|
-
# source = File.join(File.dirname(__FILE__), %w[.. lib ruby_app templates argument])
|
|
120
|
-
# copy_folder(source, folder, replacements)
|
|
121
|
-
#end
|
|
122
|
-
|
|
123
103
|
def console
|
|
124
104
|
argument = $*[1]
|
|
125
105
|
system("irb --back-trace-limit 100 -r #{argument || ( File.exists?(File.join(FileUtils.pwd, %w[console.rb])) ? File.join(FileUtils.pwd, %w[console.rb]) : File.join(File.dirname(__FILE__), %w[console.rb]) )}")
|
|
@@ -127,7 +107,7 @@ end
|
|
|
127
107
|
|
|
128
108
|
def run
|
|
129
109
|
argument = $*[1]
|
|
130
|
-
Rack::Server.start(:config => argument || File.join(FileUtils.pwd, %w[
|
|
110
|
+
Rack::Server.start(:config => argument || File.join(FileUtils.pwd, %w[configuration.ru]))
|
|
131
111
|
end
|
|
132
112
|
|
|
133
113
|
def downcode(value)
|
|
@@ -151,8 +131,6 @@ else
|
|
|
151
131
|
case $*[1].downcase
|
|
152
132
|
when 'application'
|
|
153
133
|
create_application
|
|
154
|
-
# when 'page'
|
|
155
|
-
# create_page
|
|
156
134
|
else
|
|
157
135
|
puts "Blank or unrecognized command '#{$*[1].downcase}'"
|
|
158
136
|
puts usage
|
data/features/default.feature
CHANGED
|
@@ -21,12 +21,3 @@ Feature: A page
|
|
|
21
21
|
And I click "_TestPage"
|
|
22
22
|
Then I should see "The cookie value is 'value'."
|
|
23
23
|
Then I quit
|
|
24
|
-
|
|
25
|
-
Scenario Outline: Loading the home page
|
|
26
|
-
Given I am viewing "/"
|
|
27
|
-
And I should see "Loaded"
|
|
28
|
-
|
|
29
|
-
Scenarios: Count
|
|
30
|
-
| count |
|
|
31
|
-
| X |
|
|
32
|
-
| X |
|
data/lib/ruby_app.rb
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'ruby_app/application'
|
|
2
|
+
require 'ruby_app/configuration'
|
|
3
|
+
require 'ruby_app/language'
|
|
4
|
+
require 'ruby_app/log'
|
|
5
|
+
require 'ruby_app/request'
|
|
6
|
+
require 'ruby_app/response'
|
|
7
|
+
require 'ruby_app/session'
|
|
8
|
+
require 'ruby_app/version'
|
data/lib/ruby_app/application.rb
CHANGED
|
@@ -4,22 +4,15 @@ require 'bundler/setup'
|
|
|
4
4
|
require 'fileutils'
|
|
5
5
|
|
|
6
6
|
module RubyApp
|
|
7
|
-
require 'ruby_app/
|
|
8
|
-
require 'ruby_app/log'
|
|
9
|
-
require 'ruby_app/mixins/configuration_mixin'
|
|
10
|
-
require 'ruby_app/mixins/delegate_mixin'
|
|
11
|
-
require 'ruby_app/mixins/hash_mixin'
|
|
12
|
-
require 'ruby_app/session'
|
|
13
|
-
require 'ruby_app/version'
|
|
7
|
+
require 'ruby_app/mixins'
|
|
14
8
|
|
|
15
9
|
class Application
|
|
10
|
+
extend RubyApp::Mixins::ConfigurationMixin
|
|
16
11
|
extend RubyApp::Mixins::DelegateMixin
|
|
17
|
-
include RubyApp::Mixins::ConfigurationMixin
|
|
18
12
|
|
|
19
13
|
attr_reader :options, :environment
|
|
20
14
|
|
|
21
|
-
def initialize
|
|
22
|
-
@options = options
|
|
15
|
+
def initialize
|
|
23
16
|
@environment = {}
|
|
24
17
|
end
|
|
25
18
|
|
|
@@ -27,69 +20,14 @@ module RubyApp
|
|
|
27
20
|
@@_application ||= nil
|
|
28
21
|
end
|
|
29
22
|
|
|
30
|
-
def self.create!
|
|
31
|
-
|
|
32
|
-
:session_class => RubyApp::Session,
|
|
33
|
-
:log_path => File.join(RubyApp::ROOT, %w[process log application.log]),
|
|
34
|
-
:configuration_paths => [],
|
|
35
|
-
:default_language => :en,
|
|
36
|
-
:translations_paths => [] }.merge(options)
|
|
37
|
-
_options[:configuration_paths] = [File.join(RubyApp::ROOT, %w[config.yml])] + ( _options[:configuration_paths].is_a?(Array) ? _options[:configuration_paths] : [_options[:configuration_paths]] )
|
|
38
|
-
_options[:translations_paths] = [File.join(RubyApp::ROOT, %w[translations])] + ( _options[:translations_paths].is_a?(Array) ? _options[:translations_paths] : [_options[:translations_paths]] )
|
|
39
|
-
RubyApp::Log.open!(_options[:log_path])
|
|
40
|
-
RubyApp::Configuration.load!(_options[:configuration_paths])
|
|
41
|
-
@@_application = _options[:application_class].new(_options)
|
|
23
|
+
def self.create!
|
|
24
|
+
@@_application = ( Kernel.eval(RubyApp::Application.configuration._class) ).new
|
|
42
25
|
end
|
|
43
26
|
|
|
44
27
|
def self.destroy!
|
|
45
|
-
RubyApp::Configuration.unload!
|
|
46
|
-
RubyApp::Log.close!
|
|
47
28
|
@@_application = nil
|
|
48
29
|
end
|
|
49
30
|
|
|
50
|
-
def self.create_cache(path, root)
|
|
51
|
-
RubyApp::Application.create!
|
|
52
|
-
begin
|
|
53
|
-
Dir.glob(File.join(path, %w[** *.rb])).each do |element_file|
|
|
54
|
-
RubyApp::Request.create!
|
|
55
|
-
begin
|
|
56
|
-
require element_file
|
|
57
|
-
element_class = element_file.gsub(root, '')
|
|
58
|
-
element_class = element_class.gsub(/^\//, '')
|
|
59
|
-
element_class = element_class.gsub(/\.rb$/, '')
|
|
60
|
-
element_class = RubyApp::Application.upcode(element_class)
|
|
61
|
-
begin
|
|
62
|
-
element_class = eval(element_class)
|
|
63
|
-
[:css, :js].each do |format|
|
|
64
|
-
begin
|
|
65
|
-
element_class.render(format, true)
|
|
66
|
-
rescue Exception => exception
|
|
67
|
-
puts "#{element_class}.render(#{format.inspect}) exception=#{exception.message}"
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
rescue Exception => exception
|
|
71
|
-
puts exception.message
|
|
72
|
-
end
|
|
73
|
-
ensure
|
|
74
|
-
RubyApp::Request.destroy!
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
ensure
|
|
78
|
-
RubyApp::Application.destroy!
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def self.destroy_cache(path)
|
|
83
|
-
Dir.glob(File.join(path, %w[** .cache])).each do |directory|
|
|
84
|
-
FileUtils.rm_r(directory)
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def self.upcode(value)
|
|
89
|
-
value = value.gsub(/\/(.?)/) { "::#{$1.upcase}" }
|
|
90
|
-
value.gsub(/(?:^|_)(.)/) { $1.upcase }
|
|
91
|
-
end
|
|
92
|
-
|
|
93
31
|
end
|
|
94
32
|
|
|
95
33
|
end
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
require 'yaml'
|
|
2
2
|
|
|
3
3
|
module RubyApp
|
|
4
|
-
require 'ruby_app/mixins
|
|
5
|
-
require 'ruby_app/mixins/hash_mixin'
|
|
4
|
+
require 'ruby_app/mixins'
|
|
6
5
|
|
|
7
6
|
class Configuration
|
|
8
7
|
extend RubyApp::Mixins::DelegateMixin
|
|
@@ -10,7 +9,7 @@ module RubyApp
|
|
|
10
9
|
attr_reader :document
|
|
11
10
|
|
|
12
11
|
def self.get
|
|
13
|
-
@@_configuration
|
|
12
|
+
@@_configuration ||= nil
|
|
14
13
|
end
|
|
15
14
|
|
|
16
15
|
def self.load!(paths)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#\ --warn --port 8008 --pid ./rack.pid --debug true
|
|
2
|
+
require 'rubygems'
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
|
|
5
|
+
require 'rack'
|
|
6
|
+
|
|
7
|
+
require 'ruby_app'
|
|
8
|
+
require 'ruby_app/rack'
|
|
9
|
+
|
|
10
|
+
use Rack::ShowExceptions
|
|
11
|
+
use Rack::Reloader
|
|
12
|
+
|
|
13
|
+
#use RubyApp::Rack::Duration
|
|
14
|
+
#use RubyApp::Rack::Memory
|
|
15
|
+
|
|
16
|
+
use RubyApp::Rack::Application, :configuration_paths => [File.join(RubyApp::ROOT, %w[configuration.yml])]
|
|
17
|
+
|
|
18
|
+
map '/ruby_app/resources' do
|
|
19
|
+
run Rack::File.new(File.join(RubyApp::ROOT, %w[resources]))
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
map '/favicon.ico' do
|
|
23
|
+
run Rack::File.new(File.join(RubyApp::ROOT, %w[resources favicon.ico]))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
map '/' do
|
|
27
|
+
use RubyApp::Rack::Request
|
|
28
|
+
use RubyApp::Rack::Response
|
|
29
|
+
use RubyApp::Rack::Language
|
|
30
|
+
use RubyApp::Rack::Session
|
|
31
|
+
run RubyApp::Rack::Route.new
|
|
32
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
default:
|
|
2
|
+
ruby_app:
|
|
3
|
+
application:
|
|
4
|
+
_class: "RubyApp::Application"
|
|
5
|
+
language:
|
|
6
|
+
default: "en"
|
|
7
|
+
paths:
|
|
8
|
+
- "#{RubyApp::ROOT}/translations"
|
|
9
|
+
log:
|
|
10
|
+
path: "#{RubyApp::ROOT}/process/log/application.log"
|
|
11
|
+
session:
|
|
12
|
+
_class: "RubyApp::Session"
|
|
13
|
+
expires: 60
|
|
14
|
+
interval: 15
|
|
15
|
+
elements:
|
|
16
|
+
pages:
|
|
17
|
+
authentication:
|
|
18
|
+
open_id:
|
|
19
|
+
google_authentication_page:
|
|
20
|
+
attributes:
|
|
21
|
+
email: "http://schema.openid.net/contact/email"
|
|
22
|
+
identifier: "https://www.google.com/accounts/o8/id"
|
|
23
|
+
my_open_id_authentication_page:
|
|
24
|
+
identifier: "http://myopenid.com"
|
|
25
|
+
yahoo_authentication_page:
|
|
26
|
+
attributes:
|
|
27
|
+
email: "http://axschema.org/contact/email"
|
|
28
|
+
identifier: "https://www.yahoo.com"
|