ramaze 2012.04.14 → 2012.12.08b

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.
Files changed (146) hide show
  1. data/.gems +28 -35
  2. data/.gitignore +4 -0
  3. data/.travis.yml +3 -3
  4. data/Gemfile +3 -0
  5. data/README.md +1 -5
  6. data/Rakefile +9 -20
  7. data/examples/app/blog/app.rb +5 -14
  8. data/examples/app/todolist/start.rb +1 -5
  9. data/guide/AUTHORS +8 -3
  10. data/guide/CHANGELOG +587 -0
  11. data/guide/general/cache.md +1 -0
  12. data/guide/general/configuration.md +2 -1
  13. data/guide/general/contributing.md +1 -0
  14. data/guide/general/controllers.md +105 -10
  15. data/guide/general/helpers.md +6 -7
  16. data/guide/general/installation.md +2 -1
  17. data/guide/general/logging.md +1 -4
  18. data/guide/general/middlewares.md +15 -23
  19. data/guide/general/models.md +1 -0
  20. data/guide/general/principles.md +1 -0
  21. data/guide/general/ramaze_command.md +9 -54
  22. data/guide/general/routes.md +1 -0
  23. data/guide/general/sessions.md +3 -2
  24. data/guide/general/special_thanks.md +1 -0
  25. data/guide/general/testing.md +1 -0
  26. data/guide/general/views.md +35 -22
  27. data/lib/proto/Gemfile +4 -0
  28. data/lib/proto/README.md +35 -0
  29. data/lib/proto/Rakefile +1 -0
  30. data/lib/proto/app.rb +2 -6
  31. data/lib/proto/spec/helper.rb +39 -0
  32. data/lib/proto/task/ramaze.rake +57 -0
  33. data/lib/ramaze.rb +12 -39
  34. data/lib/ramaze/bin/create.rb +1 -3
  35. data/lib/ramaze/bin/runner.rb +0 -14
  36. data/lib/ramaze/cache.rb +21 -0
  37. data/lib/ramaze/cache/memcache.rb +1 -3
  38. data/lib/ramaze/cache/redis.rb +2 -4
  39. data/lib/ramaze/cache/sequel.rb +4 -5
  40. data/lib/ramaze/controller.rb +10 -3
  41. data/lib/ramaze/default_middleware.rb +24 -0
  42. data/lib/ramaze/files.rb +5 -5
  43. data/lib/ramaze/gestalt.rb +10 -10
  44. data/lib/ramaze/helper/blue_form.rb +33 -6
  45. data/lib/ramaze/helper/csrf.rb +22 -30
  46. data/lib/ramaze/helper/flash.rb +1 -1
  47. data/lib/ramaze/helper/upload.rb +5 -3
  48. data/lib/ramaze/helper/user.rb +1 -0
  49. data/lib/ramaze/log.rb +0 -5
  50. data/lib/ramaze/log/informer.rb +3 -3
  51. data/lib/ramaze/log/logging.rb +4 -4
  52. data/lib/ramaze/log/syslog.rb +2 -2
  53. data/lib/ramaze/response.rb +1 -1
  54. data/lib/ramaze/snippets.rb +0 -20
  55. data/lib/ramaze/spec/bacon.rb +5 -13
  56. data/lib/ramaze/version.rb +1 -1
  57. data/lib/ramaze/view/erector.rb +1 -3
  58. data/lib/ramaze/view/erubis.rb +1 -3
  59. data/lib/ramaze/view/ezamar.rb +1 -3
  60. data/lib/ramaze/view/haml.rb +1 -4
  61. data/lib/ramaze/view/liquid.rb +1 -3
  62. data/lib/ramaze/view/lokar.rb +1 -3
  63. data/lib/ramaze/view/mustache.rb +1 -3
  64. data/lib/ramaze/view/nagoro.rb +1 -4
  65. data/lib/ramaze/view/remarkably.rb +1 -4
  66. data/lib/ramaze/view/sass.rb +2 -5
  67. data/lib/ramaze/view/slim.rb +1 -3
  68. data/lib/ramaze/view/slippers.rb +1 -3
  69. data/lib/ramaze/view/tagz.rb +1 -3
  70. data/lib/ramaze/view/tenjin.rb +1 -3
  71. data/ramaze.gemspec +45 -16
  72. data/spec/helper.rb +0 -1
  73. data/spec/ramaze/cache/localmemcache.rb +0 -4
  74. data/spec/ramaze/controller/mapping.rb +17 -0
  75. data/spec/ramaze/dispatcher/directory.rb +6 -5
  76. data/spec/ramaze/dispatcher/file.rb +7 -4
  77. data/spec/ramaze/files.rb +0 -2
  78. data/spec/ramaze/helper/csrf.rb +0 -26
  79. data/spec/ramaze/helper/upload.rb +1 -0
  80. data/spec/ramaze/helper/user.rb +12 -0
  81. data/spec/ramaze/log/syslog.rb +5 -1
  82. data/spec/ramaze/view/lokar.rb +1 -1
  83. data/spec/ramaze/view/nagoro.rb +1 -1
  84. data/tasks/bacon.rake +1 -1
  85. data/tasks/gems.rake +15 -0
  86. data/tasks/release.rake +37 -8
  87. metadata +106 -139
  88. data/guide/_static/ramaze_console.png +0 -0
  89. data/guide/tutorials/introduction.md +0 -263
  90. data/lib/proto/model/init.rb +0 -6
  91. data/lib/proto/public/.htaccess +0 -24
  92. data/lib/proto/public/dispatch.fcgi +0 -11
  93. data/lib/proto/spec/main.rb +0 -20
  94. data/lib/proto/start.rb +0 -20
  95. data/lib/ramaze/app_graph.rb +0 -105
  96. data/lib/ramaze/bin/console.rb +0 -87
  97. data/lib/ramaze/bin/helper.rb +0 -107
  98. data/lib/ramaze/bin/restart.rb +0 -95
  99. data/lib/ramaze/bin/start.rb +0 -221
  100. data/lib/ramaze/bin/status.rb +0 -152
  101. data/lib/ramaze/bin/stop.rb +0 -112
  102. data/lib/ramaze/dependencies.rb +0 -84
  103. data/lib/ramaze/helper/disqus.rb +0 -27
  104. data/lib/ramaze/helper/ultraviolet.rb +0 -49
  105. data/lib/ramaze/log/analogger.rb +0 -50
  106. data/lib/ramaze/log/growl.rb +0 -55
  107. data/lib/ramaze/log/knotify.rb +0 -31
  108. data/lib/ramaze/log/xosd.rb +0 -94
  109. data/lib/ramaze/middleware_compiler.rb +0 -36
  110. data/lib/ramaze/plugin.rb +0 -69
  111. data/lib/ramaze/setup.rb +0 -210
  112. data/lib/ramaze/snippets/array/put_within.rb +0 -38
  113. data/lib/ramaze/snippets/binding/locals.rb +0 -20
  114. data/lib/ramaze/snippets/fiber.rb +0 -41
  115. data/lib/ramaze/snippets/kernel/pretty_inspect.rb +0 -18
  116. data/lib/ramaze/snippets/metaid.rb +0 -17
  117. data/lib/ramaze/snippets/numeric/filesize_format.rb +0 -30
  118. data/lib/ramaze/snippets/numeric/time.rb +0 -59
  119. data/lib/ramaze/snippets/object/instance_variable_defined.rb +0 -16
  120. data/lib/ramaze/snippets/object/pretty.rb +0 -12
  121. data/lib/ramaze/snippets/object/scope.rb +0 -16
  122. data/lib/ramaze/snippets/ordered_set.rb +0 -51
  123. data/lib/ramaze/snippets/proc/locals.rb +0 -19
  124. data/lib/ramaze/snippets/ramaze/acquire.rb +0 -32
  125. data/lib/ramaze/snippets/ramaze/dictionary.rb +0 -400
  126. data/lib/ramaze/snippets/ramaze/fiber.rb +0 -24
  127. data/lib/ramaze/snippets/ramaze/struct.rb +0 -43
  128. data/lib/ramaze/snippets/string/end_with.rb +0 -17
  129. data/lib/ramaze/snippets/string/ord.rb +0 -16
  130. data/lib/ramaze/snippets/string/start_with.rb +0 -14
  131. data/lib/ramaze/snippets/thread/into.rb +0 -16
  132. data/lib/ramaze/spec.rb +0 -4
  133. data/spec/ramaze/bin/start.rb +0 -34
  134. data/spec/ramaze/log/growl.rb +0 -45
  135. data/spec/ramaze/struct.rb +0 -50
  136. data/spec/snippets/array/put_within.rb +0 -38
  137. data/spec/snippets/binding/locals.rb +0 -12
  138. data/spec/snippets/numeric/filesize_format.rb +0 -15
  139. data/spec/snippets/numeric/time.rb +0 -15
  140. data/spec/snippets/ordered_set.rb +0 -66
  141. data/spec/snippets/ramaze/acquire.rb +0 -80
  142. data/spec/snippets/ramaze/dictionary.rb +0 -113
  143. data/spec/snippets/ramaze/struct.rb +0 -15
  144. data/spec/snippets/thread/into.rb +0 -12
  145. data/tasks/gem.rake +0 -21
  146. data/tasks/setup.rake +0 -14
@@ -1,55 +0,0 @@
1
- # Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
2
- # All files in this distribution are subject to the terms of the MIT license.
3
-
4
- require 'ruby-growl'
5
-
6
- module Ramaze
7
- module Logger
8
- ##
9
- # Informer for the Growl notification system
10
- # Growl lets Mac OS X applications unintrusively tell you when things happen.
11
- #
12
- # Growl can be downloaded from the following website: http://growl.info/
13
- #
14
- class Growl < ::Growl
15
- include Innate::Traited
16
- include Logging
17
-
18
- trait :defaults => {
19
- :name => 'walrus' ,
20
- :host => 'localhost',
21
- :password => 'walrus' ,
22
- :all_notifies => %w[error warn debug info dev],
23
- :default_notifies => %w[error warn info]
24
- }
25
-
26
- ##
27
- # Takes the options from the default trait for merging.
28
- #
29
- # @param [Hash] options A hash containing extra options to use when
30
- # initializing the Growl logger.
31
- #
32
- def initialize(options = {})
33
- options = class_trait[:defaults].merge(options).values_at(
34
- :host, :name, :all_notifies, :default_notifies, :password
35
- )
36
-
37
- super(*options)
38
- end
39
-
40
- ##
41
- # Integration to Logging
42
- #
43
- # @param [String] tag
44
- # @param [Hash] args
45
- #
46
- def log(tag, *args)
47
- begin
48
- notify(tag.to_s, Time.now.strftime("%X"), args.join("\n")[0..100])
49
- rescue Errno::EMSGSIZE
50
- # Send size was to big (not really), ignore
51
- end
52
- end
53
- end # Growl
54
- end # Logger
55
- end # Ramaze
@@ -1,31 +0,0 @@
1
- # Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
2
- # All files in this distribution are subject to the terms of the MIT license.
3
-
4
- module Ramaze
5
- module Logger
6
- ##
7
- # Informer for the Knotify notfication system used on KDE.
8
- # Doesn't need any special libraries.
9
- #
10
- class Knotify
11
- include Logging
12
-
13
- trait :present => 16
14
-
15
- ##
16
- # Please see for more information on the API used here:
17
- # http://lukeplant.me.uk/articles.php?id=3
18
- #
19
- # @param [String] tag
20
- # @param [Hash] args
21
- #
22
- def log(tag, *messages)
23
- present = class_trait[:present]
24
- tag = tag.to_s.capitalize
25
- messages.flatten.each do |message|
26
- system(%{dcop knotify default notify Ramaze "#{tag}" "#{message}" '' '' #{present} 0})
27
- end
28
- end
29
- end # Knotify
30
- end # Logger
31
- end # Ramaze
@@ -1,94 +0,0 @@
1
- # Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
2
- # All files in this distribution are subject to the terms of the MIT license.
3
-
4
- Ramaze::Log.log( :warn, "Both xosd gems are currently known to be broken" )
5
- require 'xosd'
6
- require 'thread'
7
-
8
- module Ramaze
9
- module Logger
10
- ##
11
- # Informer for the XOSD notification system for X11.
12
- #
13
- # You can install the ruby-bindings with:
14
- #
15
- # gem install xosd.
16
- #
17
- class Xosd < ::Xosd
18
- attr_accessor :options
19
-
20
- include Logging
21
-
22
- DEFAULT = {
23
- :font_size => 20,
24
- :font => "-*-*-*-*-*-*-%d-*-*-*-*-*-*-*",
25
- :align => 'center',
26
- :color => '#FFFFFF',
27
- :lines => 3,
28
- :valign => 'top',
29
- :timeout => 3,
30
- :outline_color => "#000000",
31
- :outline_width => 1,
32
- :vertical_offset => 20,
33
- :colors => {
34
- :error => "#FF0000",
35
- :info => "#00FF00",
36
- :warn => "#EAA61E",
37
- :debug => "#FFFF00"
38
- },
39
- }
40
-
41
- # keys to ignore when setting the options to the instance.
42
- IGNORE = [:colors, :font_size, :lines]
43
-
44
- # Here new messages are pushed to eventually displaying them.
45
- QUEUE = Queue.new
46
-
47
- ##
48
- # Create a new instance, valid options are in DEFAULT.
49
- # In the background a new thread will be running that checks the QUEUE
50
- # and processes all messages that are being sent to it.
51
- # This is done to make output nicer and readable.
52
- #
53
- def initialize(options = {})
54
- @options = DEFAULT.merge(options)
55
-
56
- super(@options[:lines])
57
-
58
- @options.each do |key, value|
59
- next if IGNORE.include?(key)
60
- value %= @options[:font_size] if key == :font
61
- send("#{key}=", value)
62
- end
63
-
64
- Thread.new(self) do |xosd|
65
- loop do
66
- items = []
67
- lines = xosd.options[:lines]
68
- items << QUEUE.shift until QUEUE.empty? or items.size >= lines
69
-
70
- unless items.empty?
71
- # pad up with empty lines to avoid dragging around old messages.
72
- items << [:info, ' '] until items.size >= lines
73
-
74
- items.each_with_index do |(tag, message), i|
75
- xosd.color = xosd.options[:colors][tag.to_sym]
76
- xosd.display(message, i)
77
- end
78
- end
79
- sleep xosd.options[:timeout]
80
- end
81
- end
82
- end
83
-
84
- ##
85
- # Pushes all messages it gets on the QUEUE for further processing.
86
- #
87
- def log(tag, *messages)
88
- messages.each do |message|
89
- QUEUE << [tag, message]
90
- end
91
- end
92
- end # Xosd
93
- end # Logger
94
- end # Ramaze
@@ -1,36 +0,0 @@
1
- module Ramaze
2
- ##
3
- # @author Michael Fellinger
4
- # @since 14-03-2009
5
- # @see Innate::MiddelwareCompiler
6
- #
7
- class MiddlewareCompiler < Innate::MiddlewareCompiler
8
- ##
9
- # Adds the path as a static file.
10
- #
11
- # @author Michael Fellinger
12
- # @since 26-03-2009
13
- # @param [String] path The path to the static file to add.
14
- #
15
- def static(path)
16
- require 'rack/contrib'
17
- Rack::ETag.new(
18
- Rack::ConditionalGet.new(RackFileWrapper.new(path)), 'public'
19
- )
20
- end
21
-
22
- ##
23
- # Adds the path as a directory.
24
- #
25
- # @author Michael Fellinger
26
- # @since 26-03-2009
27
- # @param [String] path The path to the directory to add.
28
- #
29
- def directory(path)
30
- require 'rack/contrib'
31
- Rack::ETag.new(
32
- Rack::ConditionalGet.new(Rack::Directory.new(path)), 'public'
33
- )
34
- end
35
- end # MiddlewareCompiler
36
- end # Ramaze
@@ -1,69 +0,0 @@
1
- # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
2
- # All files in this distribution are subject to the terms of the MIT license.
3
-
4
- module Ramaze
5
- def self.plugin(name, options = {})
6
- Plugin.load(name, options)
7
- end
8
-
9
- module Plugin
10
- PLUGIN_LIST = Set.new
11
- EXTS = %w[rb so bundle]
12
- PATH = []
13
- POOL = []
14
-
15
- module_function
16
-
17
- Ramaze.options.setup << self
18
-
19
- def setup
20
- PLUGIN_LIST.each do |name, const, options|
21
- const.setup(options) if const.respond_to?(:setup)
22
- end
23
- end
24
-
25
- def teardown
26
- PLUGIN_LIST.each do |name, const, options|
27
- const.teardown if const.respond_to?(:teardown)
28
- end
29
- end
30
-
31
- def add_pool(pool)
32
- POOL.unshift(pool)
33
- POOL.uniq!
34
- end
35
-
36
- add_pool(self)
37
-
38
- def add_path(path)
39
- PATH.unshift(File.expand_path(path))
40
- PATH.uniq!
41
- end
42
-
43
- add_path(__DIR__)
44
- add_path('')
45
-
46
- def load(name, options)
47
- name = name.to_s
48
- try_require(name.snake_case)
49
- PLUGIN_LIST << [name, const_get(name.camel_case), options]
50
- rescue Exception => exception
51
- Log.error(exception)
52
- raise LoadError, "Plugin #{name} not found"
53
- end
54
-
55
- def try_require(name)
56
- found = Dir[glob(name)].first
57
- require(File.expand_path(found)) if found
58
- rescue LoadError
59
- end
60
-
61
- def glob(name = '*')
62
- "{#{paths.join(',')}}/plugin/#{name}.{#{EXTS.join(',')}}"
63
- end
64
-
65
- def paths
66
- PATH
67
- end
68
- end
69
- end
@@ -1,210 +0,0 @@
1
- module Ramaze
2
- ##
3
- # Convenient setup and activation of gems from different sources and specific
4
- # versions. It's almost like Kernel#gem but also installs automatically if a
5
- # gem is missing.
6
- #
7
- # @example
8
- # Ramaze.setup :verbose => true do
9
- # # gem and specific version
10
- # gem 'makura', '>=2009.01'
11
- #
12
- # # gem and name for require
13
- # gem 'aws-s3', :lib => 'aws/s3'
14
- #
15
- # # gem with specific version from rubyforge (default)
16
- # gem 'json', :version => '=1.1.3', :source => rubyforge
17
- # end
18
- #
19
- # @author manveru
20
- # @since 19-05-2009
21
- # @see GemSetup#initialize
22
- #
23
- def self.setup(options = {:verbose => true}, &block)
24
- GemSetup.new(options, &block)
25
- end
26
-
27
- ##
28
- # Class responsible for installing and loading all the gems.
29
- #
30
- # @author Michael Fellinger (manveru)
31
- # @since 19-05-2009
32
- #
33
- class GemSetup
34
- ##
35
- # Creates a new instance of the class and saves the parameters that were set.
36
- #
37
- # @author Michael Fellinger (manveru)
38
- # @since 19-05-2009
39
- # @param [Hash] options Hash containing various options to pass to the
40
- # GemSetup class.
41
- # @option options :verbose When set to true Ramaze will log
42
- # various actions such as messages about the installation process.
43
- # @yield block
44
- #
45
- def initialize(options = {}, &block)
46
- @gems = []
47
- @options = options.dup
48
- @verbose = @options.delete(:verbose)
49
-
50
- run(&block)
51
- end
52
-
53
- ##
54
- # Executes the data inside the block, loading all the gems and optionally
55
- # installing them.
56
- #
57
- # @author Michael Fellinger (manveru)
58
- # @since 19-05-2009
59
- # @param [Proc] block A block containing all the calls to gem().
60
- #
61
- def run(&block)
62
- return unless block_given?
63
- instance_eval(&block)
64
- setup
65
- end
66
-
67
- ##
68
- # Adds the given gem to the list of required gems.
69
- #
70
- # @example
71
- # gem('json', '>=1.5.1')
72
- #
73
- # @author Michael Fellinger (manveru)
74
- # @since 19-05-2009
75
- # @param [String] name The name of the gem to load.
76
- # @param [String] version The version of the gem.
77
- # @param [Hash] options Additional options to use when loading the gem.
78
- # @option options :lib The name to load the gem as.
79
- #
80
- def gem(name, version = nil, options = {})
81
- if version.respond_to?(:merge!)
82
- options = version
83
- else
84
- options[:version] = version
85
- end
86
-
87
- @gems << [name, options]
88
- end
89
-
90
- ##
91
- # Tries to install all the gems.
92
- #
93
- # @author Michael Fellinger (manveru)
94
- # @since 19-05-2009
95
- #
96
- def setup
97
- require 'rubygems'
98
- require 'rubygems/dependency_installer'
99
-
100
- @gems.each do |name, options|
101
- setup_gem(name, options)
102
- end
103
- end
104
-
105
- ##
106
- # First try to activate, install and try to activate again if activation
107
- # fails the first time.
108
- #
109
- # @author Michael Fellinger (manveru)
110
- # @since 19-05-2009
111
- # @param [String] name The name of the gem to activate.
112
- # @param [Hash] options The options from GemSetup#initialize.
113
- #
114
- def setup_gem(name, options)
115
- version = [options[:version]].compact
116
- lib_name = options[:lib] || name
117
-
118
- log "Activating gem #{name}"
119
-
120
- activate(name, lib_name, *version)
121
- # Gem not installed yet
122
- rescue Gem::LoadError
123
- install_gem(name, options)
124
- activate(name, lib_name, *version)
125
- end
126
-
127
- ##
128
- # Tell Rubygems to install a gem.
129
- #
130
- # @author Michael Fellinger (manveru)
131
- # @since 19-05-2009
132
- # @param [String] name The name of the gem to activate.
133
- # @param [Hash] options The options to use for installing the gem.
134
- #
135
- def install_gem(name, options)
136
- installer = Gem::DependencyInstaller.new(options)
137
-
138
- temp_argv(options[:extconf]) do
139
- log "Installing gem #{name}"
140
- installer.install(name, options[:version])
141
- end
142
- end
143
-
144
- ##
145
- # Prepare ARGV for rubygems installer
146
- #
147
- # @author Michael Fellinger (manveru)
148
- # @since 19-05-2009
149
- # @param [String] extconf
150
- #
151
- def temp_argv(extconf)
152
- if extconf ||= @options[:extconf]
153
- old_argv = ARGV.clone
154
- ARGV.replace(extconf.split(' '))
155
- end
156
-
157
- yield
158
-
159
- ensure
160
- ARGV.replace(old_argv) if extconf
161
- end
162
-
163
- private
164
-
165
- ##
166
- # Activates a gem and requires it.
167
- #
168
- # @author Yorick Peterse
169
- # @author Lee Jarvis
170
- # @since 20-08-2011
171
- # @param [String] name The name of the gem to activate.
172
- # @param [String] lib_name The name of the gem as it should be required.
173
- # @param [Array] requirements An array with additional requirements.
174
- #
175
- def activate(name, lib_name, *requirements)
176
- if Gem::Specification.respond_to?(:find_by_name)
177
- Gem::Specification.find_by_name(name, *requirements).activate
178
- else
179
- Gem.activate(name, *requirements)
180
- end
181
-
182
- require(lib_name)
183
- end
184
-
185
- ##
186
- # Writes the message to the logger.
187
- #
188
- # @author Michael Fellinger (manveru)
189
- # @since 19-05-2009
190
- # @param [String] msg The message to write to the logger.
191
- #
192
- def log(msg)
193
- return unless @verbose
194
-
195
- if defined?(Log)
196
- Log.info(msg)
197
- else
198
- puts(msg)
199
- end
200
- end
201
-
202
- ##
203
- # Installs a gem from Rubyforge.
204
- #
205
- # @author Michael Fellinger (manveru)
206
- # @since 19-05-2009
207
- #
208
- def rubyforge; 'http://gems.rubyforge.org/' end
209
- end # GemSetup
210
- end # Ramaze