codebase_san 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :gemcutter
2
+
3
+ # Specify your gem's dependencies in codebase_san.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Neil Middleton
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.md ADDED
@@ -0,0 +1,27 @@
1
+ codebase_san
2
+ ============
3
+
4
+ codebase_san is an integration between the heroku_san gem and [CodebaseHQ](http://url.com/ "CodebaseHQ.com")
5
+
6
+ If you are using the heroku_san gem to deploy to [heroku](http://heroku.com) then adding this gem to your applications manifest
7
+ will add deployment notifications to your Codebase projects.
8
+
9
+ Installation
10
+ ------------
11
+
12
+ Add the following to your Gemfile:
13
+
14
+ `group :development do
15
+ gem 'codebase_san'
16
+ end`
17
+
18
+ This gem must only be used in applications that use Heroku, CodebaseHQ and Git. You may be asked to configure the codebase gem on first use.
19
+
20
+ Note on Patches/Pull Requests
21
+ -----------------------------
22
+
23
+ * Fork the project.
24
+ * Make your feature addition or bug fix.
25
+ * Add tests for it. This is important so I don’t break it in a future version unintentionally.
26
+ * Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
27
+ * Send me a pull request. Bonus points for topic branches.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path("../lib/codebase_san/version", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "codebase_san"
6
+ s.version = CodebaseSan::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = "Neil Middleton"
9
+ s.email = "neil.middleton@gmail.com"
10
+ s.homepage = "http://rubygems.org/gems/codebase_san"
11
+ s.summary = "Integration between heroku_san and CodebaseHQ.com"
12
+ s.description = "Provides notifications of heroku deployments to CodebaseHQ.com"
13
+
14
+ s.required_rubygems_version = ">= 1.3.6"
15
+ s.rubyforge_project = "codebase_san"
16
+
17
+ s.add_development_dependency "bundler", ">= 1.0.0"
18
+ s.add_dependency "heroku_san", "1.0.1"
19
+ s.add_dependency "codebase", "4.0.4"
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
23
+ s.require_path = 'lib'
24
+ end
@@ -0,0 +1,9 @@
1
+ require 'rails'
2
+
3
+ module CodebaseSan
4
+ class Railtie < Rails::Railtie
5
+ rake_tasks do
6
+ load File.join(File.dirname(__FILE__), 'tasks.rb')
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,94 @@
1
+ desc 'After_deploy callback'
2
+
3
+ task :before_deploy => :environment do |t, args|
4
+ username = `git config codebase.username`.chomp.strip
5
+ api_key = `git config codebase.apikey`.chomp.strip
6
+
7
+ if username == '' || api_key == ''
8
+ puts " * Codebase is not configured on your computer. Bundle the codebase gem and run 'codebase setup' to auto configure it."
9
+ puts " * Deployments will not be tracked."
10
+ next
11
+ end
12
+ end
13
+
14
+ task :after_deploy => :environment do |t, args|
15
+ username = `git config codebase.username`.chomp.strip
16
+ api_key = `git config codebase.apikey`.chomp.strip
17
+ branch = `git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'`.chomp.strip
18
+ log_entry = `git log -n 1 --no-color --no-decorate`
19
+ commit_match = log_entry.match(/commit (.*)/)
20
+ real_revision = commit_match[1]
21
+
22
+ if username == '' || api_key == ''
23
+ puts " * Codebase is not configured on your computer. Bundle the codebase gem and run 'codebase setup' to auto configure it."
24
+ puts " * Deployments will not be tracked."
25
+ next
26
+ end
27
+
28
+ origin_name = (git_config_variable(:remote) || 'origin')
29
+ remote_url = git_config_variable("remote.#{origin_name}.url")
30
+ if remote_url =~ /git\@(gitbase|codebasehq|cbhqdev)\.com:(.*)\/(.*)\/(.*)\.git/
31
+ domain = $1
32
+ account = $2
33
+ project = $3
34
+ repository = $4
35
+ else
36
+ raise Codebase::Error, "Invalid Codebase repository (#{remote_url})"
37
+ end
38
+
39
+ regex = /git\@(gitbase|codebasehq)\.com:(.*)\/(.*)\/(.*)\.git/
40
+ unless m = remote_url.match(regex)
41
+ puts " * \e[31mYour repository URL does not a match a valid CodebaseHQ Clone URL (#{remote_url})\e[0m"
42
+ else
43
+ url = "#{m[2]}.codebasehq.com"
44
+ project = m[3]
45
+ repository = m[4]
46
+
47
+ xml = []
48
+ xml << "<deployment>"
49
+ xml << "<servers>Heroku</servers>"
50
+ xml << "<revision>#{real_revision}</revision>"
51
+ xml << "<environment>#{@heroku_apps}</environment>"
52
+ xml << "<branch>#{branch}</branch>"
53
+ xml << "</deployment>"
54
+
55
+ require 'net/http'
56
+ require 'uri'
57
+
58
+ real_url = "http://#{url}/#{project}/#{repository}/deployments"
59
+ # puts " - URL..........: #{real_url}"
60
+
61
+ url = URI.parse(real_url)
62
+
63
+ req = Net::HTTP::Post.new(url.path)
64
+ req.basic_auth(username, api_key)
65
+ req.add_field('Content-type', 'application/xml')
66
+ req.add_field('Accept', 'application/xml')
67
+ res = Net::HTTP.new(url.host, url.port).start { |http| http.request(req, xml.join) }
68
+ case res
69
+ when Net::HTTPCreated then puts " * \e[32mAdded deployment to Codebase\e[0m"
70
+ else
71
+ puts " * \e[31mSorry, your deployment was not logged in Codebase - please check your config above.\e[0m"
72
+ puts " * \e[31m#{res.to_yaml}\e[0m"
73
+ end
74
+ end
75
+ end
76
+
77
+ def git_config_variable(name)
78
+ if name.is_a?(Symbol)
79
+ r = `git config codebase.#{name.to_s}`.chomp
80
+ else
81
+ r = `git config #{name.to_s}`.chomp
82
+ end
83
+ r.empty? ? nil : r
84
+ end
85
+
86
+ HEROKU_CONFIG_FILE = Rails.root.join('config', 'heroku.yml')
87
+
88
+ def heroku_settings
89
+ if File.exists?(HEROKU_CONFIG_FILE)
90
+ YAML.load_file(HEROKU_CONFIG_FILE)
91
+ else
92
+ {}
93
+ end
94
+ end
@@ -0,0 +1,3 @@
1
+ module CodebaseSan
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1 @@
1
+ require 'codebase_san/railtie' if defined?(Rails)
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: codebase_san
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Neil Middleton
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-15 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: bundler
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 23
30
+ segments:
31
+ - 1
32
+ - 0
33
+ - 0
34
+ version: 1.0.0
35
+ type: :development
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: heroku_san
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - "="
44
+ - !ruby/object:Gem::Version
45
+ hash: 21
46
+ segments:
47
+ - 1
48
+ - 0
49
+ - 1
50
+ version: 1.0.1
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: codebase
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - "="
60
+ - !ruby/object:Gem::Version
61
+ hash: 55
62
+ segments:
63
+ - 4
64
+ - 0
65
+ - 4
66
+ version: 4.0.4
67
+ type: :runtime
68
+ version_requirements: *id003
69
+ description: Provides notifications of heroku deployments to CodebaseHQ.com
70
+ email: neil.middleton@gmail.com
71
+ executables: []
72
+
73
+ extensions: []
74
+
75
+ extra_rdoc_files: []
76
+
77
+ files:
78
+ - .gitignore
79
+ - Gemfile
80
+ - LICENSE
81
+ - README.md
82
+ - Rakefile
83
+ - codebase_san.gemspec
84
+ - lib/codebase_san.rb
85
+ - lib/codebase_san/railtie.rb
86
+ - lib/codebase_san/tasks.rb
87
+ - lib/codebase_san/version.rb
88
+ has_rdoc: true
89
+ homepage: http://rubygems.org/gems/codebase_san
90
+ licenses: []
91
+
92
+ post_install_message:
93
+ rdoc_options: []
94
+
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
105
+ version: "0"
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ hash: 23
112
+ segments:
113
+ - 1
114
+ - 3
115
+ - 6
116
+ version: 1.3.6
117
+ requirements: []
118
+
119
+ rubyforge_project: codebase_san
120
+ rubygems_version: 1.3.7
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: Integration between heroku_san and CodebaseHQ.com
124
+ test_files: []
125
+