esp-commons 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = EspCommons
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'EspCommons'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
25
+
26
+ Bundler::GemHelper.install_tasks
27
+
@@ -0,0 +1,10 @@
1
+ if Settings['errors.key'].present?
2
+ Airbrake.configure do |config|
3
+ config.api_key = Settings['errors.key']
4
+ URI.parse(Settings['errors.url']).tap do | url |
5
+ config.host = url.host
6
+ config.port = url.port
7
+ config.secure = url.scheme.inquiry.https?
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ begin
2
+ require 'rsolr'
3
+ class RSolr::Client
4
+ alias :build_request_without_utf8 :build_request
5
+ def build_request(path, opts)
6
+ opts = build_request_without_utf8(path,opts)
7
+ if opts[:headers].try(:[], 'Content-Type') == 'application/x-www-form-urlencoded'
8
+ opts[:headers]['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'
9
+ end
10
+ opts
11
+ end
12
+ end
13
+ rescue LoadError
14
+ end
@@ -0,0 +1,5 @@
1
+ begin
2
+ require 'sunspot'
3
+ Sunspot.config.solr.url = Settings['solr.url']
4
+ rescue LoadError
5
+ end
@@ -0,0 +1,4 @@
1
+ require 'esp-commons/engine'
2
+
3
+ module EspCommons
4
+ end
@@ -0,0 +1,42 @@
1
+ require 'configliere'
2
+ require 'airbrake'
3
+ require 'russian'
4
+
5
+ module EspCommons
6
+ class Engine < ::Rails::Engine
7
+ isolate_namespace EspCommons
8
+
9
+ config.before_configuration do
10
+ Settings.read(Rails.root.join('config', 'settings.yml')) if Rails.root.join('config', 'settings.yml').exist?
11
+ Settings.defaults Settings.extract!(Rails.env)[Rails.env] || {}
12
+ Settings.extract!(:test, :development, :production)
13
+ Settings.define 'app.secret', :env_var => 'APP_SECRET', :required => true
14
+ Settings.define 'errors.key', :env_var => 'ERRORS_KEY', :required => Rails.env.production?
15
+ Settings.define 'errors.url', :env_var => 'ERRORS_URL', :required => Rails.env.production?
16
+ Settings.define 'solr.url', :env_var => 'SOLR_URL'
17
+ Settings.define 'sso.url', :env_var => 'SSO_URL'
18
+ Settings.define 'sso_key', :env_var => 'SSO_KEY'
19
+ Settings.define 'sso_secret', :env_var => 'SSO_SECRET'
20
+ Settings.define 'cms.url', :env_var => 'CMS_URL'
21
+ Settings.define 'blue-pages.url', :env_var => 'BLUE_PAGES_URL'
22
+ Settings.define 'news.url', :env_var => 'NEWS_URL'
23
+ Settings.define 'vfs.url', :env_var => 'VFS_URL'
24
+ Settings.define 'appeals.url', :env_var => 'APPEALS_URL'
25
+ Settings.resolve!
26
+ end
27
+
28
+ config.before_configuration do
29
+ if Rails.env.production? && Settings['unicorn.prefix.logs']
30
+ Rails.application.config.logger = ActiveSupport::BufferedLogger.new("#{Settings['unicorn.prefix.logs']}/application.log")
31
+ end
32
+ end
33
+
34
+ config.after_initialize do
35
+ Rails.logger.level = ActiveSupport::BufferedLogger::Severity::WARN if Rails.env.production?
36
+ end
37
+
38
+ config.after_initialize do
39
+ Rails.application.config.secret_token = Settings['app.secret']
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,3 @@
1
+ module EspCommons
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+
3
+ source ~/.rvm/scripts/rvm
4
+ export LANG=ru_RU.UTF-8
5
+
6
+ bundle exec unicorn -c `dirname $0`/../config/unicorn.rb -E production -D
@@ -0,0 +1,5 @@
1
+ set :job_template, "/usr/local/bin/bash -l -c ':job'" if RUBY_PLATFORM =~ /freebsd/
2
+
3
+ every :day do
4
+ rake 'cron'
5
+ end
@@ -0,0 +1,34 @@
1
+ current_dir = File.expand_path('../..', __FILE__)
2
+
3
+ project = current_dir.split('/').last
4
+
5
+ settings = YAML.load_file "#{current_dir}/config/settings.yml"
6
+
7
+ settings['unicorn'] ||= {}
8
+ settings['unicorn']['workers'] ||= 2
9
+ settings['unicorn']['preload'] = true if settings['unicorn']['preload'] != false
10
+ settings['unicorn']['timeout'] ||= 300
11
+ settings['unicorn']['prefix'] ||= {}
12
+ settings['unicorn']['prefix']['pid'] ||= '/var/run/esp/'
13
+ settings['unicorn']['prefix']['logs'] ||= "/var/log/esp/#{project}/"
14
+ settings['unicorn']['prefix']['socket'] ||= '/tmp/esp-'
15
+ unless settings['unicorn']['prefix']['socket'].start_with? "/"
16
+ settings['unicorn']['prefix']['socket'] = "#{current_dir}/#{settings['unicorn']['prefix']['socket']}"
17
+ end
18
+
19
+ worker_processes settings['unicorn']['workers']
20
+ preload_app settings['unicorn']['preload']
21
+ timeout settings['unicorn']['timeout']
22
+ pid "#{settings['unicorn']['prefix']['pid']}#{project}.pid"
23
+ stderr_path "#{settings['unicorn']['prefix']['logs']}stderr.log"
24
+ stdout_path "#{settings['unicorn']['prefix']['logs']}stdout.log"
25
+ listen settings['unicorn']['listen'] if settings['unicorn']['listen']
26
+ listen "#{settings['unicorn']['prefix']['socket']}#{project}.sock", :backlog => 64
27
+
28
+ before_fork do |server, worker|
29
+ defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
30
+ end
31
+
32
+ after_fork do |server, worker|
33
+ defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
34
+ end
@@ -0,0 +1,16 @@
1
+ module EspCommons
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('..', __FILE__)
5
+
6
+ def create_binaries
7
+ template 'bin/start_site'
8
+ end
9
+
10
+ def create_configs
11
+ template 'config/unicorn.rb'
12
+ end
13
+ end
14
+ end
15
+ end
16
+
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: esp-commons
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - OpenTeam
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: airbrake
16
+ requirement: &11961780 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *11961780
25
+ - !ruby/object:Gem::Dependency
26
+ name: configliere
27
+ requirement: &11961000 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *11961000
36
+ - !ruby/object:Gem::Dependency
37
+ name: rails
38
+ requirement: &11960420 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *11960420
47
+ - !ruby/object:Gem::Dependency
48
+ name: russian
49
+ requirement: &11945520 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *11945520
58
+ - !ruby/object:Gem::Dependency
59
+ name: sqlite3
60
+ requirement: &11943320 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *11943320
69
+ description: Description of EspCommons.
70
+ email:
71
+ - mail@openteam.ru
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - config/initializers/rsolr_utf8_queries.rb
77
+ - config/initializers/errbit.rb
78
+ - config/initializers/sunspot.rb
79
+ - lib/generators/esp_commons/install/install_generator.rb
80
+ - lib/generators/esp_commons/install/bin/start_site
81
+ - lib/generators/esp_commons/install/config/schedule.rb
82
+ - lib/generators/esp_commons/install/config/unicorn.rb
83
+ - lib/esp-commons/engine.rb
84
+ - lib/esp-commons/version.rb
85
+ - lib/esp-commons.rb
86
+ - MIT-LICENSE
87
+ - Rakefile
88
+ - README.rdoc
89
+ homepage: http://github.com/openteam-esp/esp-commons
90
+ licenses: []
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ segments:
102
+ - 0
103
+ hash: -477438190588297153
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ segments:
111
+ - 0
112
+ hash: -477438190588297153
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 1.8.15
116
+ signing_key:
117
+ specification_version: 3
118
+ summary: Summary of EspCommons.
119
+ test_files: []