monkey_notification 0.0.4

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/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 [name of plugin creator]
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 ADDED
@@ -0,0 +1,7 @@
1
+ Monkey Notification
2
+ =====
3
+
4
+ Notify about deployment the monkey (skype bot).
5
+
6
+
7
+ Copyright (c) 2011 leopard, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,51 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+ require 'rake/gempackagetask'
5
+
6
+
7
+ desc 'Default: run unit tests.'
8
+ task :default => :test
9
+
10
+ desc 'Test the monkey_notification plugin.'
11
+ Rake::TestTask.new(:test) do |t|
12
+ t.libs << 'lib'
13
+ t.libs << 'test'
14
+ t.pattern = 'test/**/*_test.rb'
15
+ t.verbose = true
16
+ end
17
+
18
+ desc 'Generate documentation for the monkey_notification plugin.'
19
+ Rake::RDocTask.new(:rdoc) do |rdoc|
20
+ rdoc.rdoc_dir = 'rdoc'
21
+ rdoc.title = 'MonkeyNotification'
22
+ rdoc.options << '--line-numbers' << '--inline-source'
23
+ rdoc.rdoc_files.include('README')
24
+ rdoc.rdoc_files.include('lib/**/*.rb')
25
+ end
26
+
27
+ PKG_FILES = FileList[
28
+ '[a-zA-Z]*',
29
+ 'lib/**/*.rb'
30
+ ]
31
+
32
+ spec = Gem::Specification.new do |s|
33
+ s.name = "monkey_notification"
34
+ s.version = "0.0.4"
35
+ s.author = "Alexey Vasileiv"
36
+ s.email = "alexey.vasiliev@railsware.com"
37
+ s.homepage = "http://railsware.com/"
38
+ s.platform = Gem::Platform::RUBY
39
+ s.summary = "Monkey Notification on Deployment"
40
+ s.description = "Railsware Monkey Notification Gem"
41
+ s.files = PKG_FILES.to_a
42
+ s.require_path = "lib"
43
+ s.has_rdoc = false
44
+ s.extra_rdoc_files = ["README"]
45
+ s.add_runtime_dependency("activesupport")
46
+ end
47
+
48
+ desc 'Turn this plugin into a gem.'
49
+ Rake::GemPackageTask.new(spec) do |pkg|
50
+ pkg.gem_spec = spec
51
+ end
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'monkey_notification'
data/install.rb ADDED
File without changes
@@ -0,0 +1,39 @@
1
+ class MonkeyNotificationGenerator < Rails::Generators::Base
2
+
3
+ class_option :api_url, :aliases => "-k", :type => :string, :desc => "Your Monkey Url"
4
+
5
+ source_root File.expand_path("../templates", __FILE__)
6
+
7
+ def install
8
+ ensure_api_url_was_configured
9
+ append_capistrano_hook
10
+ generate_initializer
11
+ end
12
+
13
+ private
14
+
15
+ def ensure_api_url_was_configured
16
+ if !options[:api_url]
17
+ puts "Must pass --api-url"
18
+ exit
19
+ end
20
+ end
21
+
22
+ def append_capistrano_hook
23
+ if File.exists?('config/deploy.rb') && File.exists?('Capfile')
24
+ append_file('config/deploy.rb', <<-HOOK)
25
+
26
+ require 'monkey_notification/capistrano'
27
+ HOOK
28
+ end
29
+ end
30
+
31
+ def api_url_expression
32
+ "'#{options[:api_url]}'"
33
+ end
34
+
35
+ def generate_initializer
36
+ template 'initializer.rb', 'config/initializers/monkey_notification.rb'
37
+ end
38
+
39
+ end
@@ -0,0 +1,5 @@
1
+ Dir[File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'monkey_notification-*')].each do |vendored_notifier|
2
+ $: << File.join(vendored_notifier, 'lib')
3
+ end
4
+
5
+ require 'monkey_notification/capistrano'
@@ -0,0 +1,6 @@
1
+ <% if Rails::VERSION::MAJOR < 3 && Rails::VERSION::MINOR < 2 -%>
2
+ require 'monkey_notification'
3
+ <% end -%>
4
+ MonkeyNotification.configure do |config|
5
+ config.api_url = <%= api_url_expression %>
6
+ end
@@ -0,0 +1,39 @@
1
+ require 'net/http'
2
+ require 'net/https'
3
+ require 'rubygems'
4
+ begin
5
+ require 'active_support'
6
+ rescue LoadError
7
+ require 'activesupport'
8
+ end
9
+
10
+ require 'monkey_notification_tasks'
11
+
12
+ require 'monkey_notification/configuration'
13
+
14
+ require 'monkey_notification/railtie' if defined?(Rails::Railtie)
15
+
16
+ module MonkeyNotification
17
+
18
+ def self.initialize
19
+ MonkeyNotification.configure do |config|
20
+ config.environment_name = RAILS_ENV if defined?(RAILS_ENV)
21
+ config.project_root = RAILS_ROOT if defined?(RAILS_ROOT)
22
+ config.framework = "Rails: #{::Rails::VERSION::STRING}" if defined?(::Rails::VERSION)
23
+ end
24
+ end
25
+
26
+ class << self
27
+
28
+ attr_accessor :configuration
29
+
30
+ def configure
31
+ self.configuration ||= Configuration.new
32
+ yield(configuration)
33
+ end
34
+
35
+ end
36
+
37
+ end
38
+
39
+ MonkeyNotification.initialize
@@ -0,0 +1,23 @@
1
+ # Defines deploy:monkey_notification:notify which will send information about the deploy to Monkey.
2
+
3
+ Capistrano::Configuration.instance(:must_exist).load do
4
+ after "deploy", "deploy:monkey_notification:notify"
5
+
6
+ namespace :deploy do
7
+ namespace :monkey_notification do
8
+ desc "Notify Monkey of the deployment"
9
+ task :notify, :except => { :no_release => true } do
10
+ rails_env = fetch(:rails_env, "production")
11
+ branch = fetch(:branch, "HEAD")
12
+ main_server = fetch(:main_server, "N/A")
13
+ local_user = ENV['USER'] || ENV['USERNAME']
14
+ executable = RUBY_PLATFORM.downcase.include?('mswin') ? 'rake.bat' : 'rake'
15
+ notify_command = "#{executable} monkey_notification:deploy TO=#{rails_env} REVISION=#{current_revision} REPO=#{repository} USER=#{local_user} BRANCH=#{branch} MAIN_SERVER=#{main_server}"
16
+ notify_command << " API_URL=#{ENV['API_URL']}" if ENV['API_URL']
17
+ puts "Notifying Monkey of Deploy (#{notify_command})"
18
+ `#{notify_command}`
19
+ puts "Monkey Notification Complete."
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ module MonkeyNotification
2
+ # Used to set up and modify settings for the notifier.
3
+ class Configuration
4
+
5
+ OPTIONS = [:api_url, :environment_name, :project_root, :framework, :proxy_host, :proxy_port, :proxy_user, :proxy_pass].freeze
6
+
7
+ # The API url for your project, found on the project edit form.
8
+ attr_accessor :api_url
9
+
10
+ attr_accessor :environment_name
11
+
12
+ attr_accessor :project_root
13
+
14
+ attr_accessor :framework
15
+
16
+ attr_accessor :proxy_host
17
+ attr_accessor :proxy_port
18
+ attr_accessor :proxy_user
19
+ attr_accessor :proxy_pass
20
+
21
+ end
22
+ end
@@ -0,0 +1,19 @@
1
+ require 'monkey_notification'
2
+ require 'rails'
3
+
4
+ module MonkeyNotification
5
+ class Railtie < Rails::Railtie
6
+ rake_tasks do
7
+ require 'monkey_notification/tasks'
8
+ end
9
+
10
+ config.after_initialize do
11
+ MonkeyNotification.configure do |config|
12
+ config.environment_name ||= Rails.env
13
+ config.project_root ||= Rails.root
14
+ config.framework = "Rails: #{::Rails::VERSION::STRING}"
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ namespace :monkey_notification do
2
+ desc "Notify Monkey about a new deploy."
3
+ task :deploy => :environment do
4
+ require 'monkey_notification_tasks'
5
+ MonkeyNotificationTasks.deploy(:rails_env => ENV['TO'],
6
+ :scm_revision => ENV['REVISION'],
7
+ :scm_repository => ENV['REPO'],
8
+ :local_username => ENV['USER'],
9
+ :branch => ENV['BRANCH'],
10
+ :main_server => ENV['MAIN_SERVER'],
11
+ :api_url => ENV['API_URL'])
12
+ end
13
+ end
@@ -0,0 +1,34 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'active_support'
4
+
5
+ module MonkeyNotificationTasks
6
+ def self.deploy(opts = {})
7
+ if MonkeyNotification.configuration.api_url.blank?
8
+ puts "I don't seem to be configured with an Url. Please check your configuration."
9
+ return false
10
+ end
11
+
12
+ if opts[:rails_env].blank?
13
+ puts "I don't know to which Rails environment you are deploying (use the TO=production option)."
14
+ return false
15
+ end
16
+
17
+ api_url = opts.delete(:api_url) || MonkeyNotification.configuration.api_url
18
+
19
+ params = {}
20
+ opts.each {|k,v| params["deploy[#{k}]"] = v }
21
+
22
+ url = URI.parse(api_url)
23
+
24
+ proxy = Net::HTTP.Proxy(MonkeyNotification.configuration.proxy_host,
25
+ MonkeyNotification.configuration.proxy_port,
26
+ MonkeyNotification.configuration.proxy_user,
27
+ MonkeyNotification.configuration.proxy_pass)
28
+
29
+ response = proxy.post_form(url, params)
30
+
31
+ puts response.body
32
+ return Net::HTTPSuccess === response
33
+ end
34
+ end
data/uninstall.rb ADDED
File without changes
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: monkey_notification
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 4
10
+ version: 0.0.4
11
+ platform: ruby
12
+ authors:
13
+ - Alexey Vasileiv
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-01-13 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: activesupport
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: Railsware Monkey Notification Gem
36
+ email: alexey.vasiliev@railsware.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - README
43
+ files:
44
+ - install.rb
45
+ - init.rb
46
+ - README
47
+ - MIT-LICENSE
48
+ - Rakefile
49
+ - uninstall.rb
50
+ - lib/monkey_notification/tasks.rb
51
+ - lib/monkey_notification/configuration.rb
52
+ - lib/monkey_notification/capistrano.rb
53
+ - lib/monkey_notification/railtie.rb
54
+ - lib/monkey_notification.rb
55
+ - lib/generators/monkey_notification_generator.rb
56
+ - lib/generators/templates/capistrano_hook.rb
57
+ - lib/generators/templates/initializer.rb
58
+ - lib/monkey_notification_tasks.rb
59
+ has_rdoc: true
60
+ homepage: http://railsware.com/
61
+ licenses: []
62
+
63
+ post_install_message:
64
+ rdoc_options: []
65
+
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ requirements: []
87
+
88
+ rubyforge_project:
89
+ rubygems_version: 1.4.2
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: Monkey Notification on Deployment
93
+ test_files: []
94
+