gitpusshuten 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitpusshuten (0.0.1)
4
+ gitpusshuten (0.0.2)
5
5
  activesupport (~> 3.0.0)
6
6
  highline (~> 1.6.0)
7
7
  json (~> 1.4.0)
data/bin/heavenly CHANGED
File without changes
data/gitpusshuten.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |gem|
2
2
 
3
3
  gem.name = 'gitpusshuten'
4
- gem.version = '0.0.1'
4
+ gem.version = '0.0.2' #GitPusshuTen::VERSION
5
5
  gem.platform = Gem::Platform::RUBY
6
6
  gem.authors = 'Michael van Rooijen'
7
7
  gem.email = 'meskyanichi@gmail.com'
@@ -56,7 +56,7 @@ module GitPusshuTen
56
56
  ##
57
57
  # Wrapper for the command instance
58
58
  def command
59
- @command ||= "GitPusshuTen::Commands::#{cli.command.classify}".constantize.new(cli, configuration, hooks, environment)
59
+ @command ||= "GitPusshuTen::Commands::#{classify_with_plural(cli.command)}".constantize.new(cli, configuration, hooks, environment)
60
60
  end
61
61
 
62
62
  ##
@@ -134,7 +134,7 @@ module GitPusshuTen
134
134
  ##
135
135
  # Returns the constant of a command
136
136
  def get_constant_for(command)
137
- "GitPusshuTen::Commands::#{command.classify}".constantize
137
+ "GitPusshuTen::Commands::#{classify_with_plural(command)}".constantize
138
138
  end
139
139
 
140
140
  ##
@@ -143,5 +143,17 @@ module GitPusshuTen
143
143
  value.to_s.color(:yellow)
144
144
  end
145
145
 
146
+ ##
147
+ # Classifies the command, but re-pluralizes it in case
148
+ # it ended with the 's' character to ensure the correct
149
+ # command is being invoked
150
+ def classify_with_plural(word)
151
+ if word =~ /s$/
152
+ word.classify + 's'
153
+ else
154
+ word.classify
155
+ end
156
+ end
157
+
146
158
  end
147
159
  end
@@ -6,6 +6,8 @@ module GitPusshuTen
6
6
  example "heavenly push branch develop to staging # Pushes the specified branch to the staging environment."
7
7
  example "heavenly push tag 1.0.3 to staging # Pushes the specified tag to the staging environment."
8
8
  example "heavenly push ref 2dbec02aa0b8604b8512e2fcbb8aac582c7f6a73 to production # Pushes the specified ref to the production environment."
9
+ example "heavenly push production # Pushes the master branch to the production environment. (Conventional)"
10
+ example "heavenly push staging # Pushes the develop branch to the staging environment. (Conventional)"
9
11
 
10
12
  attr_accessor :type
11
13
 
@@ -49,6 +51,23 @@ module GitPusshuTen
49
51
  git.add_remote(e.name, "ssh://#{c.user}@#{c.ip}:#{c.port}/#{e.app_dir}")
50
52
  end
51
53
 
54
+ ##
55
+ # Conventional command actions
56
+
57
+ ##
58
+ # Pushes the master branch to the production environment.
59
+ def perform_production!
60
+ message "Pushing branch master to the production environment."
61
+ git.push(:branch, "master").to("production")
62
+ end
63
+
64
+ ##
65
+ # Pushes the master branch to the production environment.
66
+ def perform_stage!
67
+ message "Pushing branch develop to the stage environment."
68
+ git.push(:branch, "develop").to("staging")
69
+ end
70
+
52
71
  end
53
72
  end
54
73
  end
@@ -36,7 +36,7 @@ module GitPusshuTen
36
36
  if File.exist?(hooks_file)
37
37
  instance_eval(File.read(hooks_file))
38
38
  else
39
- GitPusshuTen::Log.warning "Could not locate the hooks.rb file in #{hooks_file}"
39
+ GitPusshuTen::Log.warning "Could not locate the hooks.rb file."
40
40
  end
41
41
  self
42
42
  end
@@ -0,0 +1,79 @@
1
+ # encoding: utf-8
2
+ module GitPusshuTen
3
+ module Commands
4
+ class Redis < GitPusshuTen::Commands::Base
5
+ description "[Module] Redis commands."
6
+ usage "redis <command> for <enviroment>"
7
+ example "heavenly redis install # Installs Redis (system wide) and downloads config template."
8
+ example "heavenly redis upload-configuration # Uploads the Redis configuration template to the server, will install Redis if not already present."
9
+
10
+ def initialize(*objects)
11
+ super
12
+
13
+ @command = cli.arguments.shift
14
+
15
+ help if command.nil? or e.name.nil?
16
+
17
+ @command = @command.underscore
18
+
19
+ ##
20
+ # Default Configuration
21
+ @installation_dir = "/etc/redis"
22
+ @configuration_dir = @installation_dir
23
+ @configuration_file = File.join(@configuration_dir, 'redis.conf')
24
+ @local_configuration_dir = File.join(local.gitpusshuten_dir, 'redis')
25
+ @local_configuration_file = File.join(@local_configuration_dir, "redis.conf")
26
+ end
27
+
28
+ def perform_install!
29
+ if e.installed?('redis-server')
30
+ error "Redis is already installed."
31
+ exit
32
+ end
33
+ message "Going to install Redis Key-Value store systemwide"
34
+ Spinner.return :message => "Installing #{y('Redis')}.." do
35
+ e.install!("redis-server")
36
+ g('Done!')
37
+ end
38
+
39
+ create_file = true
40
+ if File.exist?(@local_configuration_file)
41
+ warning "#{y( @local_configuration_file)} already exists, do you want to overwrite it?"
42
+ create_file = yes?
43
+ end
44
+ if create_file
45
+ download_redis_configuration_from_server!
46
+ message "The redis configuration has been downloaded to#{y( @local_configuration_file)}."
47
+ end
48
+ end
49
+
50
+ def perform_upload_configuration!
51
+ unless e.directory?(@installation_dir)
52
+ error "Could not find the Redis installation directory in #{y(@installation_dir)}"
53
+ perform_install!
54
+ exit
55
+ end
56
+
57
+ unless File.exist?(@local_configuration_file)
58
+ error "Could not find the local Redis configuration file in #{y(@local_configuration_file)}"
59
+ download_redis_configuration_from_server!
60
+ message "Redis configuration has been fetched from the server, edit it and upload it again."
61
+ exit
62
+ end
63
+ Spinner.return :message => "Uploading Redis configuration file #{y(@local_configuration_file)}.." do
64
+ e.scp_as_root(:upload, @local_configuration_file, @configuration_dir)
65
+ g('Done!')
66
+ end
67
+ end
68
+
69
+ def download_redis_configuration_from_server!
70
+ FileUtils.mkdir_p(@local_configuration_dir)
71
+ Spinner.return :message => "Downloading redis configuration from the server.." do
72
+ e.scp_as_root(:download, @configuration_file, "#{@local_configuration_file}")
73
+ g("Finished downloading!")
74
+ end
75
+ end
76
+
77
+ end
78
+ end
79
+ end
@@ -12,7 +12,7 @@ module GitPusshuTen
12
12
  example "heavenly rvm remove-ruby for production # Uninstalls and removes the Ruby's complete source from RVM."
13
13
  example "heavenly rvm set-default-ruby for production # Sets the system wide default Ruby."
14
14
  example " This is required if you want to change the Ruby version"
15
- example " for your Ruby applications running Passenger."
15
+ example " for your Ruby applications running Phusion Passenger."
16
16
 
17
17
  def initialize(*objects)
18
18
  super
data/lib/gitpusshuten.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'FileUtils'
1
2
  require 'open-uri'
2
3
  require 'yaml'
3
4
 
@@ -8,7 +9,7 @@ require 'net/ssh'
8
9
  require 'net/scp'
9
10
  require 'highline/import'
10
11
  require 'rainbow'
11
- require 'json'
12
+ require 'json'
12
13
 
13
14
  Dir[File.expand_path(File.join(File.dirname(__FILE__), 'gitpusshuten/**/*'))].each do |file|
14
15
  if not File.directory?(file) and not file =~ /\/modules\/.+\/hooks\.rb/
@@ -17,5 +18,5 @@ Dir[File.expand_path(File.join(File.dirname(__FILE__), 'gitpusshuten/**/*'))].ea
17
18
  end
18
19
 
19
20
  module GitPusshuTen
20
- VERSION = '0.0.1'
21
+ VERSION = '0.0.2'
21
22
  end
data/spec/hooks_spec.rb CHANGED
@@ -27,7 +27,7 @@ describe GitPusshuTen::Hooks do
27
27
 
28
28
  context "when the hooks file does not exist" do
29
29
  it "should issue a warning" do
30
- GitPusshuTen::Log.expects(:warning).with("Could not locate the hooks.rb file in /Users/Michael/Desktop/GitPusshuTen/spec/fixtures/hooks_not_exist.rb")
30
+ GitPusshuTen::Log.expects(:warning).with("Could not locate the hooks.rb file.")
31
31
  hooks_staging.should == hooks_staging.parse!(File.expand_path(File.dirname(__FILE__) + '/fixtures/hooks_not_exist.rb'))
32
32
  end
33
33
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael van Rooijen
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-19 00:00:00 +01:00
17
+ date: 2010-11-21 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -165,6 +165,7 @@ files:
165
165
  - lib/gitpusshuten/modules/nginx/command.rb
166
166
  - lib/gitpusshuten/modules/passenger/command.rb
167
167
  - lib/gitpusshuten/modules/passenger/hooks.rb
168
+ - lib/gitpusshuten/modules/redis/command.rb
168
169
  - lib/gitpusshuten/modules/rvm/command.rb
169
170
  - lib/templates/config.rb
170
171
  - lib/templates/hooks.rb