noveku 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # Noveku
2
+
3
+ A collection of aliases we use when interacting with heroku.
4
+ This gem was inspired by [a collection of thoughtbot aliases](https://github.com/thoughtbot/dotfiles/commit/86494030441e88ef9c2e2ceaa00a4da82023e445).
5
+
6
+ ## Prerequisites
7
+
8
+ This gem depends on no other gems. However :
9
+
10
+ * the presence of the command `heroku` (either via the gem, or the toolbelt) is assumed;
11
+ * the `hrs` tool assumes there is a heroku git remote named `staging`;
12
+ * the `hrp` tool assumes there is a heroku git remove named `production`.
13
+
14
+ ## Installation
15
+
16
+ `gem install noveku`. Since it will not be part of your application, only of your workflow,
17
+ you should install it globally, not via bundler and your project's Gemfile.
18
+
19
+ ## Usage
20
+
21
+ This gem exposes two executables :
22
+
23
+ * `hrs` (heroku staging) : will execute the given commands for the `staging` remote
24
+ * `hrp` (heroku production) : will execute the given commands for the `production` remote
25
+
26
+ ## Commands
27
+
28
+ Supported commands and their equivalent :
29
+
30
+ * `console`: `heroku run console --remote ENV`
31
+ * `migrate`: `heroku run rake db:migrate --remote ENV && heroku restart --remote ENV`
32
+ * `tail`: `heroku logs --tail --remote ENV`
33
+
34
+ When giving a command that is not specifically supported, it will be passed to `heroku` : `heroku ARGS --remote ENV".
35
+ This makes several other commands available, such as `restart`, `releases`, ...
36
+
37
+ ## What's next
38
+
39
+ Commands that will be soon supported : `rake`, commands for dumping mongolab database.
40
+
41
+ ## Contributions
42
+
43
+ 1. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug. In the first case, please include a use-case.
44
+ 2. Fork the repository on Github, make a feature branch, work on this branch.
45
+ 3. If necessary, write a test which shows that the bug was fixed or that the feature works as expected.
46
+ 4. Send a pull request and annoy us until we notice it. :)
47
+
48
+ ## Changelog
49
+
50
+ * `0.1`: First version. Available commands : `console`, `restart`, `tail`
data/bin/hrp ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'noveku'
4
+
5
+ production = Noveku::Production.new(ARGV)
6
+ production.run
data/bin/hrs ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'noveku'
4
+
5
+ staging = Noveku::Staging.new(ARGV)
6
+ staging.run
@@ -0,0 +1,48 @@
1
+ module Noveku
2
+ # This exception will be raised if @environment is not present
3
+ class NotAValidEnvironment < StandardError
4
+ end
5
+
6
+ # Common functionnality
7
+ class Base
8
+ # Keep track of the given commands
9
+ def initialize(commands)
10
+ @commands = commands
11
+ @command = @commands.first
12
+ end
13
+
14
+ # Run the commands
15
+ def run
16
+ raise NotAValidEnvironment unless @environment
17
+
18
+ send "#{@command}_cmd"
19
+ end
20
+
21
+ # Open the console
22
+ def console_cmd
23
+ system "heroku run console --remote #{@environment}"
24
+ end
25
+
26
+ # Execute migrations & restart app
27
+ def migrate_cmd
28
+ system %{
29
+ heroku run rake db:migrate --remote #{@environment} &&
30
+ heroku restart --remote #{@environment}
31
+ }
32
+ end
33
+
34
+ # Tail logs
35
+ def tail_cmd
36
+ system "heroku logs --tail --remote #{@environment}"
37
+ end
38
+
39
+ def method_missing(name, *args, &block)
40
+ # If this is a command with no specific support, pass the raw arguments to `heroku` directly
41
+ if name.to_s.end_with?('_cmd')
42
+ system "heroku #{@commands.join(' ')} --remote #{@environment}"
43
+ else
44
+ super
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,8 @@
1
+ module Noveku
2
+ class Production < Base
3
+ def initialize(commands)
4
+ @environment = 'production'
5
+ super(commands)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Noveku
2
+ class Staging < Base
3
+ def initialize(commands)
4
+ @environment = 'staging'
5
+ super(commands)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module Noveku
2
+ VERSION = '0.1'
3
+ end
data/lib/noveku.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'noveku/base'
2
+ require 'noveku/production'
3
+ require 'noveku/staging'
4
+ require 'noveku/version'
data/noveku.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ $:.unshift File.expand_path('../lib', __FILE__)
2
+ require 'noveku/version'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "noveku"
6
+ s.version = Noveku::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Novelys"]
9
+ s.email = ["contact@novelys.com"]
10
+ s.homepage = "http://github.com/novelys/noveku"
11
+ s.summary = "Heroku shorcuts for commonly used commands at novelys"
12
+ s.description = "A set of heroku aliases meant to speed up heroku interaction when dealing with multilple heroku remotes."
13
+ s.rubyforge_project = s.name
14
+ s.required_rubygems_version = ">= 1.3.6"
15
+ s.files = `git ls-files`.split("\n")
16
+ s.executables << 'hrp'
17
+ s.executables << 'hrs'
18
+ s.require_path = 'lib'
19
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: noveku
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Novelys
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-13 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A set of heroku aliases meant to speed up heroku interaction when dealing
15
+ with multilple heroku remotes.
16
+ email:
17
+ - contact@novelys.com
18
+ executables:
19
+ - hrp
20
+ - hrs
21
+ extensions: []
22
+ extra_rdoc_files: []
23
+ files:
24
+ - README.md
25
+ - bin/hrp
26
+ - bin/hrs
27
+ - lib/noveku.rb
28
+ - lib/noveku/base.rb
29
+ - lib/noveku/production.rb
30
+ - lib/noveku/staging.rb
31
+ - lib/noveku/version.rb
32
+ - noveku.gemspec
33
+ homepage: http://github.com/novelys/noveku
34
+ licenses: []
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: 1.3.6
51
+ requirements: []
52
+ rubyforge_project: noveku
53
+ rubygems_version: 1.8.23
54
+ signing_key:
55
+ specification_version: 3
56
+ summary: Heroku shorcuts for commonly used commands at novelys
57
+ test_files: []