ruby-app 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,7 +2,7 @@ RubyApp
2
2
  =======
3
3
 
4
4
  Little ruby application template. For create light ruby apps (daemons, EventMachine-apps, ...).
5
- Supports bundler, environments, rails dirs tree.
5
+ Supports bundler, environments, activesupport, rails dirs tree. Fast loading and low memory using.
6
6
 
7
7
  $ gem install ruby-app
8
8
 
@@ -2,10 +2,10 @@
2
2
 
3
3
  class Application
4
4
  class << self
5
-
5
+
6
6
  def name
7
7
  "<%= base_name %>"
8
8
  end
9
- end
10
-
9
+
10
+ end
11
11
  end
@@ -0,0 +1,67 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ module Application::Defaults
4
+
5
+ def tmp_dir
6
+ @gem_tmp_dir ||= File.join(root, %w{tmp})
7
+ end
8
+
9
+ def logger_dir
10
+ @gem_logger_dir ||= File.join(root, %w{log})
11
+ end
12
+
13
+ def env
14
+ @gem_env ||= begin
15
+ env = ENV['APP_ENV'] || ENV['RAILS_ENV']
16
+
17
+ # if not specify env, try find file with env config/environment.current
18
+ # which created this file by a capistrano, by example
19
+ unless env
20
+ path = File.join(root, %w{ config environment.current })
21
+ if File.exists?(path)
22
+ env = File.read(path)
23
+ env.strip!
24
+ end
25
+ end
26
+
27
+ env = 'development' unless env
28
+
29
+ env
30
+ end
31
+ end
32
+
33
+ alias :environment :env
34
+
35
+ def logger
36
+ @gem_logger ||= begin
37
+ file = env.to_s['test'] ? File.open(File.join(logger_dir, "#{name rescue 'ruby-app'}.log"), "a") : STDERR
38
+ LocalLogger.new(file).tap do |l|
39
+ l.level = App.config.log_level
40
+ end
41
+ end
42
+ end
43
+
44
+ def config
45
+ CommonConfig
46
+ end
47
+
48
+ def identifier
49
+ "ruby-app"
50
+ end
51
+
52
+ def rake_paths
53
+ @gem_rake_paths ||= []
54
+ end
55
+
56
+ def initializer_paths
57
+ @gem_initializer_paths ||= []
58
+ end
59
+
60
+ def bundler_group
61
+ end
62
+
63
+ end
64
+
65
+ Application.extend(Application::Defaults)
66
+
67
+ App = Application unless defined?(App)
@@ -2,7 +2,11 @@ $KCODE='u' if RUBY_VERSION < '1.9'
2
2
 
3
3
  local_root = File.dirname(__FILE__)
4
4
 
5
+ # define class if undefined
6
+ class Application
7
+ end
8
+
5
9
  # app from gem
6
- require File.join(local_root, 'application')
10
+ require File.join(local_root, 'application_defaults')
7
11
 
8
12
  $:.unshift(File.join(App.root, %w{ lib }))
@@ -5,6 +5,9 @@ local_root = File.dirname(__FILE__)
5
5
  # app from gem
6
6
  require File.join(local_root, 'boot')
7
7
 
8
+ # error mailer
9
+ require File.join(local_root, 'error_mailer')
10
+
8
11
  # config from gem
9
12
  require File.join(local_root, 'common_config')
10
13
 
@@ -0,0 +1,57 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ class ErrorMailer
4
+ end
5
+
6
+ module ErrorMailer::BlankSlate
7
+ def message(msg)
8
+ end
9
+
10
+ def exception(e)
11
+ end
12
+ end
13
+
14
+ module ErrorMailer::Logger
15
+ def message(msg)
16
+ super
17
+ App.logger.error { msg }
18
+ end
19
+
20
+ def exception(e)
21
+ super
22
+ App.logger.error{ "#{e.class}: #{e.message}\n#{e.backtrace*"\n"}" }
23
+ end
24
+ end
25
+
26
+ module ErrorMailer::ReraiseCtrlC
27
+ def exception(e)
28
+ if SignalException === e || SystemExit === e
29
+ raise e
30
+ end
31
+ super
32
+ end
33
+ end
34
+
35
+ class ErrorMailer
36
+ class << self
37
+ include ErrorMailer::BlankSlate
38
+ include ErrorMailer::Logger
39
+ include ErrorMailer::ReraiseCtrlC
40
+
41
+ def mail_message(m)
42
+ message(m)
43
+ end
44
+
45
+ def mail_exception(e)
46
+ exception(e)
47
+ end
48
+
49
+ def safe(&block)
50
+ yield
51
+
52
+ rescue => ex
53
+ self.mail_exception(ex)
54
+ end
55
+ end
56
+
57
+ end
@@ -1,3 +1,3 @@
1
1
  module RubyApp
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
 
8
8
  s.authors = ["Makarchev Konstantin"]
9
9
 
10
- s.description = %q{Little ruby application template. For creates light ruby apps (daemons, EventMachine-apps, ...). Supports bundler, environments, rails dirs tree.}
10
+ s.description = %q{Little ruby application template. For create light ruby apps (daemons, EventMachine-apps, ...). Supports bundler, environments, activesupport, rails dirs tree. Fast loading and low memory using.}
11
11
  s.summary = %q{Ruby application template}
12
12
 
13
13
  s.email = %q{kostya27@gmail.com}
@@ -48,6 +48,9 @@ describe "RubyApp" do
48
48
  App.config.bla.should == 12
49
49
  end
50
50
 
51
+ it "ErrorMailer should wrap raise" do
52
+ Model.new.raised_method # should not raise
53
+ end
51
54
  end
52
55
 
53
56
  end
@@ -0,0 +1,9 @@
1
+ class Model
2
+
3
+ def raised_method
4
+ ErrorMailer.safe do
5
+ raise "hah"
6
+ end
7
+ end
8
+
9
+ end
metadata CHANGED
@@ -1,120 +1,116 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ruby-app
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.7
3
+ version: !ruby/object:Gem::Version
4
+ hash: 11
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 8
10
+ version: 0.1.8
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Makarchev Konstantin
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-06-30 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: activesupport
16
- requirement: !ruby/object:Gem::Requirement
17
+
18
+ date: 2012-07-22 00:00:00 +04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
17
23
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
23
31
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
32
+ type: :runtime
33
+ requirement: *id001
34
+ name: activesupport
35
+ - !ruby/object:Gem::Dependency
36
+ version_requirements: &id002 !ruby/object:Gem::Requirement
25
37
  none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ hash: 3
42
+ segments:
43
+ - 0
44
+ version: "0"
45
+ prerelease: false
46
+ type: :runtime
47
+ requirement: *id002
31
48
  name: rake
32
- requirement: !ruby/object:Gem::Requirement
49
+ - !ruby/object:Gem::Dependency
50
+ version_requirements: &id003 !ruby/object:Gem::Requirement
33
51
  none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :runtime
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
39
59
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
60
+ type: :runtime
61
+ requirement: *id003
47
62
  name: thor
48
- requirement: !ruby/object:Gem::Requirement
63
+ - !ruby/object:Gem::Dependency
64
+ version_requirements: &id004 !ruby/object:Gem::Requirement
49
65
  none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :runtime
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
72
+ version: "0"
55
73
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- - !ruby/object:Gem::Dependency
74
+ type: :runtime
75
+ requirement: *id004
63
76
  name: bundler
64
- requirement: !ruby/object:Gem::Requirement
77
+ - !ruby/object:Gem::Dependency
78
+ version_requirements: &id005 !ruby/object:Gem::Requirement
65
79
  none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :runtime
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
86
+ version: "0"
71
87
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
88
+ type: :development
89
+ requirement: *id005
79
90
  name: rspec
80
- requirement: !ruby/object:Gem::Requirement
91
+ - !ruby/object:Gem::Dependency
92
+ version_requirements: &id006 !ruby/object:Gem::Requirement
81
93
  none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- type: :development
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ hash: 3
98
+ segments:
99
+ - 0
100
+ version: "0"
87
101
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: rake
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
102
102
  type: :development
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- description: Little ruby application template. For creates light ruby apps (daemons,
111
- EventMachine-apps, ...). Supports bundler, environments, rails dirs tree.
103
+ requirement: *id006
104
+ name: rake
105
+ description: Little ruby application template. For create light ruby apps (daemons, EventMachine-apps, ...). Supports bundler, environments, activesupport, rails dirs tree. Fast loading and low memory using.
112
106
  email: kostya27@gmail.com
113
- executables:
107
+ executables:
114
108
  - ruby-app
115
109
  extensions: []
110
+
116
111
  extra_rdoc_files: []
117
- files:
112
+
113
+ files:
118
114
  - .gitignore
119
115
  - Gemfile
120
116
  - LICENSE
@@ -140,11 +136,12 @@ files:
140
136
  - generator/project/lib/rake_tasks/.gitkeep
141
137
  - generator/project/spec/spec1_spec.rb.tt
142
138
  - generator/project/spec/spec_helper.rb
143
- - lib/ruby-app/application.rb
139
+ - lib/ruby-app/application_defaults.rb
144
140
  - lib/ruby-app/boot.rb
145
141
  - lib/ruby-app/common_config.rb
146
142
  - lib/ruby-app/default_config.rb
147
143
  - lib/ruby-app/environment.rb
144
+ - lib/ruby-app/error_mailer.rb
148
145
  - lib/ruby-app/local_logger.rb
149
146
  - lib/ruby-app/tasks.rake
150
147
  - lib/ruby-app/tasks/rspec.rake
@@ -157,6 +154,7 @@ files:
157
154
  - spec/test_app/app/models/.gitkeep
158
155
  - spec/test_app/app/models/2.rb
159
156
  - spec/test_app/app/models/3.rb
157
+ - spec/test_app/app/models/model.rb
160
158
  - spec/test_app/bin/.gitkeep
161
159
  - spec/test_app/config/boot.rb
162
160
  - spec/test_app/config/config.rb
@@ -171,34 +169,39 @@ files:
171
169
  - spec/test_app/config/initializers/2.rb
172
170
  - spec/test_app/lib/4.rb
173
171
  - spec/test_app/lib/application.rb
172
+ has_rdoc: true
174
173
  homepage: http://github.com/kostya/ruby-app
175
174
  licenses: []
175
+
176
176
  post_install_message:
177
177
  rdoc_options: []
178
- require_paths:
178
+
179
+ require_paths:
179
180
  - lib
180
- required_ruby_version: !ruby/object:Gem::Requirement
181
+ required_ruby_version: !ruby/object:Gem::Requirement
181
182
  none: false
182
- requirements:
183
- - - ! '>='
184
- - !ruby/object:Gem::Version
185
- version: '0'
186
- segments:
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ hash: 3
187
+ segments:
187
188
  - 0
188
- hash: -590066895
189
- required_rubygems_version: !ruby/object:Gem::Requirement
189
+ version: "0"
190
+ required_rubygems_version: !ruby/object:Gem::Requirement
190
191
  none: false
191
- requirements:
192
- - - ! '>='
193
- - !ruby/object:Gem::Version
194
- version: '0'
195
- segments:
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ hash: 3
196
+ segments:
196
197
  - 0
197
- hash: -590066895
198
+ version: "0"
198
199
  requirements: []
200
+
199
201
  rubyforge_project:
200
- rubygems_version: 1.8.24
202
+ rubygems_version: 1.4.2
201
203
  signing_key:
202
204
  specification_version: 3
203
205
  summary: Ruby application template
204
206
  test_files: []
207
+
@@ -1,68 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- class Application
4
-
5
- class << self
6
-
7
- def tmp_dir
8
- @tmp_dir ||= File.join(root, %w{tmp})
9
- end
10
-
11
- def logger_dir
12
- @logger_dir ||= File.join(root, %w{log})
13
- end
14
-
15
- def env
16
- @env ||= begin
17
- env = ENV['APP_ENV'] || ENV['RAILS_ENV']
18
-
19
- # if not specify env, try find file with env config/environment.current
20
- # which created this file by a capistrano, by example
21
- unless env
22
- path = File.join(root, %w{ config environment.current })
23
- if File.exists?(path)
24
- env = File.read(path)
25
- env.strip!
26
- end
27
- end
28
-
29
- env = 'development' unless env
30
-
31
- env
32
- end
33
- end
34
-
35
- alias :environment :env
36
-
37
- def logger
38
- @logger ||= begin
39
- file = (env == 'test') ? File.open(File.join(logger_dir, 'ruby-app.log'), "a") : STDERR
40
- LocalLogger.new(file).tap do |l|
41
- l.level = App.config.log_level
42
- end
43
- end
44
- end
45
-
46
- def config
47
- CommonConfig
48
- end
49
-
50
- def identifier
51
- "ruby-app"
52
- end
53
-
54
- def rake_paths
55
- @rake_paths ||= []
56
- end
57
-
58
- def initializer_paths
59
- @initializer_paths ||= []
60
- end
61
-
62
- def bundler_group
63
- end
64
-
65
- end
66
- end
67
-
68
- App = Application unless defined?(App)