ruby-app 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c1015f458a6dedeba606b5c211980c43ea6a0ab
4
- data.tar.gz: 14c56ad549c565b7179e2cc4960a379691a4b2e1
3
+ metadata.gz: 551b2624fb71df85c598ccc3732de87a7288fd15
4
+ data.tar.gz: 12c273dceb8416005d0a5a4496bfe5885c3e3ac8
5
5
  SHA512:
6
- metadata.gz: c46d9b7d7e2c8180ccfb6596ce12409545febb2935b374f4276d3f167a44561835d3454d2c2abcf462906ddc7598639306b541c8a76aa454fec9fd36e2df7fba
7
- data.tar.gz: f6a90c892c52c1a1c1785778426d09a33031f0b754d2025434383d91d77f1675d5d4b6c98bbef2505e911237e79d3a89a328758357d328faf19e8bb6581545ee
6
+ metadata.gz: e157f4cdec6908ca3d5d9850d033361941691b559d3f95734ab366f14e44b610441ec1469930eb65a3b4878eb361fc3c2843570f6fbb91b79923f004148ed706
7
+ data.tar.gz: e7baafb4da948e8932637353721979173916a38fffcd3938fa0ff9dbab26437b25114e338e6979517618f3d3f4c0f5f55b1206551d961e76b8442de1ce8f9cb1
@@ -0,0 +1 @@
1
+ --color
@@ -1,5 +1,7 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
+ $app_started_at = Time.now
4
+
3
5
  module Application::Defaults
4
6
 
5
7
  def tmp_dir
@@ -60,10 +62,21 @@ module Application::Defaults
60
62
  def bundler_group
61
63
  end
62
64
 
65
+ def started_at
66
+ $app_started_at
67
+ end
68
+
63
69
  def error_mailer
64
70
  ErrorMailer
65
71
  end
66
72
 
73
+ def revision
74
+ @_revision ||= File.read(File.join(root, %w[REVISION]))[0..5] rescue nil
75
+ end
76
+
77
+ def hostname
78
+ @_hostname ||= `hostname`.chop
79
+ end
67
80
  end
68
81
 
69
82
  Application.extend(Application::Defaults)
@@ -1,5 +1,17 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
+ class RubyAppAddress
4
+ attr_accessor :host, :port
5
+ def initialize(host, port)
6
+ @host = host
7
+ @port = port
8
+ end
9
+
10
+ def to_s
11
+ "#{host}:#{port}"
12
+ end
13
+ end
14
+
3
15
  class CommonConfig
4
16
  @@configs = {}
5
17
 
@@ -42,8 +54,7 @@ class CommonConfig
42
54
 
43
55
  def method_missing(name, *params, &block)
44
56
  if name.to_s =~ /_address$/i
45
- require 'ostruct'
46
- @configs[name.to_sym] = block || OpenStruct.new(:host => params[0], :port => params[1].to_i)
57
+ @configs[name.to_sym] = block || RubyAppAddress.new(params[0], params[1].to_s)
47
58
  else
48
59
  params = params[0] if params.size == 1
49
60
  @configs[name.to_sym] = block || params
@@ -81,7 +81,3 @@ Dir["#{App.root}/app/models/*.rb"].each{ |x| require x }
81
81
  # later controllers app
82
82
  Dir["#{App.root}/app/controllers/*.rb"].each{ |x| require x }
83
83
 
84
- # later all app from app
85
- dirs.each do |dir|
86
- Dir["#{dir}/*.rb"].each{ |x| require x }
87
- end
@@ -4,27 +4,27 @@ class ErrorMailer
4
4
  end
5
5
 
6
6
  module ErrorMailer::BlankSlate
7
- def message(msg)
7
+ def message(msg, params = nil)
8
8
  end
9
9
 
10
- def exception(e)
10
+ def exception(e, params = nil)
11
11
  end
12
12
  end
13
13
 
14
14
  module ErrorMailer::Logger
15
- def message(msg)
15
+ def message(msg, params = nil)
16
16
  super
17
17
  App.logger.error { msg }
18
18
  end
19
19
 
20
- def exception(e)
20
+ def exception(e, params = nil)
21
21
  super
22
- App.logger.error{ "#{e.class}: #{e.message}\n#{e.backtrace*"\n"}" }
22
+ App.logger.error{ "#{e.class}: #{e.message}\n#{(e.backtrace || []) * "\n"}" }
23
23
  end
24
24
  end
25
25
 
26
26
  module ErrorMailer::ReraiseCtrlC
27
- def exception(e)
27
+ def exception(e, params = nil)
28
28
  if SignalException === e || SystemExit === e
29
29
  raise e
30
30
  end
@@ -38,19 +38,19 @@ class ErrorMailer
38
38
  include ErrorMailer::Logger
39
39
  include ErrorMailer::ReraiseCtrlC
40
40
 
41
- def mail_message(m)
41
+ def mail_message(m, params = nil)
42
42
  message(m)
43
43
  end
44
44
 
45
- def mail_exception(e)
46
- exception(e)
45
+ def mail_exception(e, params = nil)
46
+ exception(e, params)
47
47
  end
48
48
 
49
- def safe(&block)
49
+ def safe(params = nil, &block)
50
50
  yield
51
51
 
52
- rescue => ex
53
- self.mail_exception(ex)
52
+ rescue Object => ex
53
+ self.mail_exception(ex, params)
54
54
  end
55
55
  end
56
56
 
@@ -0,0 +1,51 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ begin
4
+ require 'hoptoad_notifier'
5
+
6
+ class ErrorMailer
7
+ end
8
+
9
+ HoptoadNotifier.configure do |config|
10
+ config.api_key = App.config.hoptoad_key
11
+ end
12
+
13
+ module ErrorMailer::Hoptoad
14
+ def defer
15
+ Thread.new{ yield }
16
+ rescue Object => ex
17
+ App.logger.error { "defer error '#{ex.message}', #{ex.backtrace.inspect}" }
18
+ end
19
+
20
+ def app_params(params = nil)
21
+ par = {:app_name => App.name, :rev => App.revision}
22
+ par.merge!(params) if params.is_a?(Hash)
23
+ { :parameters => par, :project_root => App.root }
24
+ end
25
+
26
+ def message(msg, params = nil)
27
+ super
28
+
29
+ defer do
30
+ HoptoadNotifier.notify(app_params(params).merge(:error_message => msg))
31
+ end
32
+ end
33
+
34
+ def exception(e, params = nil)
35
+ super
36
+
37
+ defer do
38
+ HoptoadNotifier.notify(e, app_params(params))
39
+ end
40
+ end
41
+ end
42
+
43
+ class ErrorMailer
44
+ class << self
45
+ include ErrorMailer::Hoptoad
46
+ end
47
+ end
48
+
49
+ rescue LoadError
50
+ App.logger.error { "Not found gem hoptoad_hotifier, add it to Gemfile" }
51
+ end
@@ -1,3 +1,3 @@
1
1
  module RubyApp
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.11"
3
3
  end
@@ -24,6 +24,6 @@ Gem::Specification.new do |s|
24
24
  s.add_dependency "bundler"
25
25
 
26
26
  s.add_development_dependency "rspec"
27
- s.add_development_dependency "rake"
27
+ #s.add_development_dependency "rake"
28
28
 
29
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Makarchev Konstantin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-10 00:00:00.000000000 Z
11
+ date: 2014-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - '>='
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '>='
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
83
  description: 'Ruby micro framework for easy create ruby applications (daemons, EventMachine-apps,
98
84
  db-apps, cli...). Features: bundler, environments, activesupport, rails dirs tree.
99
85
  Fast loading and low memory using.'
@@ -123,6 +109,7 @@ files:
123
109
  - generator/project/config/environments/production.rb
124
110
  - generator/project/config/environments/test.rb
125
111
  - generator/project/lib/application.rb.tt
112
+ - generator/project/spec/spec.opts
126
113
  - generator/project/spec/spec1_spec.rb.tt
127
114
  - generator/project/spec/spec_helper.rb
128
115
  - lib/ruby-app/application_defaults.rb
@@ -131,6 +118,7 @@ files:
131
118
  - lib/ruby-app/default_config.rb
132
119
  - lib/ruby-app/environment.rb
133
120
  - lib/ruby-app/error_mailer.rb
121
+ - lib/ruby-app/hoptoad.rb
134
122
  - lib/ruby-app/local_logger.rb
135
123
  - lib/ruby-app/tasks.rake
136
124
  - lib/ruby-app/tasks/rspec.rake
@@ -177,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
165
  version: '0'
178
166
  requirements: []
179
167
  rubyforge_project:
180
- rubygems_version: 2.0.2
168
+ rubygems_version: 2.1.4
181
169
  signing_key:
182
170
  specification_version: 4
183
171
  summary: Ruby application micro framework