unidad 0.0.1.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 18e092529015146ccf806193891a80d5330270fa
4
+ data.tar.gz: 51d016dcda7be99a9e3f091ab8a9cd250199302c
5
+ SHA512:
6
+ metadata.gz: fe54afed6364b9a9fc4a551f7448fceb92dcab4aaa496f724aca41701c9284356fa75e623752c5916e31af5f7de8b2fe521c3cd09875a048ac4d38255cbd892f
7
+ data.tar.gz: e4d47298cce8a43440eabe55ed4716c5ce945eb9709b56ee10d3c96a9a925241beb08d67f6cc859bad124056f1922dd8b681d12e082ded47cd2f2b97e468aebe
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .env
11
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,39 @@
1
+ AllCops:
2
+ RunRailsCops: false
3
+ Exclude:
4
+ - spec/test_app/**
5
+ - bin/**
6
+
7
+ LineLength:
8
+ Max: 150
9
+
10
+ ClassLength:
11
+ CountComments: false # count full line comments?
12
+ Max: 175
13
+
14
+ MethodLength:
15
+ CountComments: false # count full line comments?
16
+ Max: 10
17
+
18
+ HashSyntax:
19
+ EnforcedStyle: hash_rockets
20
+
21
+ Documentation:
22
+ Enabled: false
23
+
24
+ DefaultScope:
25
+ Enabled: false
26
+
27
+ CollectionMethods:
28
+ PreferredMethods:
29
+ map: 'collect'
30
+ map!: 'collect!'
31
+ reduce: 'inject'
32
+ find: 'detect'
33
+ find_all: 'select'
34
+
35
+ Output:
36
+ Enabled: false
37
+
38
+ HasAndBelongsToMany:
39
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in unidad.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,12 @@
1
+ guard 'rspec', :cmd => 'bundle exec rspec --colour', :all_on_start => false, :all_after_pass => false do
2
+ watch('spec/spec_helper.rb') { 'spec' }
3
+ watch(/^spec\/.+_spec\.rb/)
4
+ watch(/^app\/(.+)\.rb/) { |m| "spec/app/#{m[1]}_spec.rb" }
5
+ watch(/^lib\/(.+)\.rb/) { |m| "spec/lib/#{m[1]}_spec.rb" }
6
+ end
7
+
8
+ guard :rubocop do
9
+ watch(/.+\.gemspec$/)
10
+ watch(/.+\.rb$/)
11
+ watch(/(?:.+\/)?\.rubocop\.yml$/) { |m| File.dirname(m[0]) }
12
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2015 PJ Kelly (Crush & Lovely)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Unidad
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/unidad`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'unidad'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install unidad
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/[my-github-username]/unidad/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "unidad"
5
+
6
+ require "pry"
7
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/bin/unidad ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "unidad"
5
+
6
+ Unidad::Cli::Root.start(ARGV)
data/config/unidad.yml ADDED
@@ -0,0 +1,12 @@
1
+ commands:
2
+ - "MIDDLEMAN_ENV=%{environment} middleman build"
3
+ - "s3_website push --config-dir ./config/deploy/%{environment}/"
4
+ messages:
5
+ deploy:
6
+ before: "*%{username}* has started deploying branch `%{branch}` of `%{repository}` to *%{environment}*."
7
+ after: "*%{username}* has finished deploying branch `%{branch}` of `%{repository}` to *%{environment}*."
8
+ failure: "*[ERROR]* *%{username}* failed to deploy branch `%{branch}` of `%{repository}` to *%{environment}*."
9
+ options:
10
+ deploy:
11
+ slack_username: crushbot
12
+ slack_icon: http://www.gravatar.com/avatar/39293a628644a33d2373c9c329330d49.png
@@ -0,0 +1,36 @@
1
+ module Unidad
2
+ module Cli
3
+ class Deploy < Thor::Group
4
+ include Thor::Actions
5
+
6
+ argument :environment, :desc => 'The environment you are deploying to',
7
+ :type => :string,
8
+ :required => true
9
+
10
+ def before
11
+ deployment.on(:before)
12
+ end
13
+
14
+ def deploy
15
+ Unidad::CommandBuilder.all(environment).each do |command|
16
+ run command
17
+ end
18
+ end
19
+
20
+ def after
21
+ deployment.on(:after)
22
+ end
23
+
24
+ private
25
+
26
+ def deployment
27
+ @deployment ||= Unidad::Messenger.new(:deploy).tap do |m|
28
+ m.environment = environment
29
+ m.username = ENV['CIRCLE_USERNAME'] || ENV['USER'] || ENV['USERNAME']
30
+ m.repository = File.basename(Dir.pwd)
31
+ m.branch = `git rev-parse --abbrev-ref HEAD`.strip
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,15 @@
1
+ require 'dotenv'
2
+ require 'thor'
3
+ require 'thor/group'
4
+
5
+ Dotenv.load
6
+
7
+ require 'unidad/cli/deploy'
8
+
9
+ module Unidad
10
+ module Cli
11
+ class Root < Thor
12
+ register Unidad::Cli::Deploy, 'deploy', 'deploy [ENVIRONMENT]', 'Deploy your application to the specified environment.'
13
+ end
14
+ end
15
+ end
data/lib/unidad/cli.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'unidad/cli/root'
2
+
3
+ module Unidad
4
+ module Cli
5
+ end
6
+ end
@@ -0,0 +1,18 @@
1
+ module Unidad
2
+ class CommandBuilder
3
+ attr_reader :command, :environment
4
+
5
+ def self.all(environment)
6
+ Unidad.config['commands'].collect { |command| new(command, environment).to_s }
7
+ end
8
+
9
+ def initialize(command, environment)
10
+ @command = command
11
+ @environment = environment
12
+ end
13
+
14
+ def to_s
15
+ command % { :environment => environment }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,51 @@
1
+ require 'net/http'
2
+ require 'multi_json'
3
+
4
+ module Unidad
5
+ class Messenger
6
+ attr_reader :command
7
+ attr_accessor :callback, :username, :repository, :branch, :environment
8
+
9
+ def initialize(command)
10
+ @command = command
11
+ end
12
+
13
+ def on(callback)
14
+ self.callback = callback
15
+ deliver_message
16
+ end
17
+
18
+ protected
19
+
20
+ def deliver_message
21
+ uri = URI(ENV['SLACK_WEBHOOK_URL'])
22
+ Net::HTTP.post_form(uri, build_params)
23
+ rescue => e
24
+ puts 'There was an error notifying Slack.'
25
+ puts e.inspect
26
+ end
27
+
28
+ def build_params
29
+ payload = {
30
+ :username => options['slack_username'],
31
+ :icon_url => options['slack_icon'],
32
+ :text => message
33
+ }
34
+
35
+ { 'payload' => MultiJson.dump(payload) }
36
+ end
37
+
38
+ def message
39
+ Unidad.config.messages[command][callback] % options
40
+ end
41
+
42
+ def options
43
+ @options ||= {
44
+ :username => username,
45
+ :repository => repository,
46
+ :branch => branch,
47
+ :environment => environment
48
+ }.merge(Unidad.config.options[command])
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ module Unidad
2
+ VERSION = '0.0.1.beta1'
3
+ end
data/lib/unidad.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'yaml'
2
+ require 'erb'
3
+ require 'hashie'
4
+
5
+ require 'unidad/version'
6
+ require 'unidad/command_builder'
7
+ require 'unidad/messenger'
8
+ require 'unidad/cli'
9
+
10
+ module Unidad
11
+ def self.config_path
12
+ Pathname.new(Dir.pwd).join('config/unidad.yml')
13
+ end
14
+
15
+ def self.config
16
+ Hashie::Mash.new(YAML.load(ERB.new(File.new(config_path).read).result))
17
+ end
18
+ end
data/unidad.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'unidad/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'unidad'
8
+ spec.version = Unidad::VERSION
9
+ spec.authors = ['PJ Kelly']
10
+ spec.email = ['pj@crushlovely.com']
11
+
12
+ spec.summary = 'A thin wrapper and notification layer around your deployment workflows.'
13
+ spec.description = 'A thin wrapper and notification layer around your deployment workflows.'
14
+ spec.homepage = 'https://github.com/crushlovely/unidad'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(/^(test|spec|features)\//) }
18
+ spec.bindir = 'bin'
19
+ spec.executables = ['unidad']
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'thor', '~> 0.18'
23
+ spec.add_dependency 'dotenv', '~> 1.0'
24
+ spec.add_dependency 'multi_json', '>= 1.7'
25
+ spec.add_dependency 'hashie', '>= 2.0'
26
+ spec.add_development_dependency 'bundler', '~> 1.9'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'pry', '~> 0.9'
29
+ spec.add_development_dependency('rspec')
30
+ spec.add_development_dependency('rubocop')
31
+ spec.add_development_dependency('guard')
32
+ spec.add_development_dependency('guard-rspec')
33
+ spec.add_development_dependency('guard-rubocop')
34
+ spec.add_development_dependency('codeclimate-test-reporter')
35
+ end
metadata ADDED
@@ -0,0 +1,248 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unidad
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.beta1
5
+ platform: ruby
6
+ authors:
7
+ - PJ Kelly
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.18'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.18'
27
+ - !ruby/object:Gem::Dependency
28
+ name: dotenv
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: multi_json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: hashie
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.9'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.9'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.9'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: guard
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: guard-rspec
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: guard-rubocop
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: codeclimate-test-reporter
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ description: A thin wrapper and notification layer around your deployment workflows.
196
+ email:
197
+ - pj@crushlovely.com
198
+ executables:
199
+ - unidad
200
+ extensions: []
201
+ extra_rdoc_files: []
202
+ files:
203
+ - ".gitignore"
204
+ - ".rspec"
205
+ - ".rubocop.yml"
206
+ - ".travis.yml"
207
+ - Gemfile
208
+ - Guardfile
209
+ - LICENSE
210
+ - README.md
211
+ - Rakefile
212
+ - bin/console
213
+ - bin/setup
214
+ - bin/unidad
215
+ - config/unidad.yml
216
+ - lib/unidad.rb
217
+ - lib/unidad/cli.rb
218
+ - lib/unidad/cli/deploy.rb
219
+ - lib/unidad/cli/root.rb
220
+ - lib/unidad/command_builder.rb
221
+ - lib/unidad/messenger.rb
222
+ - lib/unidad/version.rb
223
+ - unidad.gemspec
224
+ homepage: https://github.com/crushlovely/unidad
225
+ licenses:
226
+ - MIT
227
+ metadata: {}
228
+ post_install_message:
229
+ rdoc_options: []
230
+ require_paths:
231
+ - lib
232
+ required_ruby_version: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ required_rubygems_version: !ruby/object:Gem::Requirement
238
+ requirements:
239
+ - - ">"
240
+ - !ruby/object:Gem::Version
241
+ version: 1.3.1
242
+ requirements: []
243
+ rubyforge_project:
244
+ rubygems_version: 2.4.5
245
+ signing_key:
246
+ specification_version: 4
247
+ summary: A thin wrapper and notification layer around your deployment workflows.
248
+ test_files: []