punt 0.0.4 → 0.0.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85662d179b096c017a378b0b34fea547c5da584f
4
- data.tar.gz: 06f3732c176a5c0f7e681c7c00f5598388ec3d80
3
+ metadata.gz: a0d53d651e4708507fc26cb28fb7254d7878c90f
4
+ data.tar.gz: 9c72338d9a5424e6c3eecd52069bf60e2dcac111
5
5
  SHA512:
6
- metadata.gz: 6805ab861ee0fb061e4df7f7f23124b3b3720740066e2c6c31f50a72556b2a0476c54f8789c3fdb521c087d2aed339d7e8963834049d9644070f19f338aeec15
7
- data.tar.gz: dead02ac41701114854d8ebec2091a19a09e8ea0ef538e1f5842862009495652ff2c677b88ae082d26d0e062cb747789b0867b1e64529566254fb6bd6d7ef168
6
+ metadata.gz: 616c7f75dff897ac978bd5c07cbaa383e8e305cbfc407f7d2866f06573a93218e8244b6810508c88ccef52d425a7700ef588bcc8d27cd4f142d4bad1136ec03a
7
+ data.tar.gz: 239305264e44ad2fb1032e187324adf6d8d41da09ab80c2c7ef09438d560e0d6116596563973829a81f91e4a5584a57fb42c9b515dc8fdba6b59910f8cc155f5
@@ -1,10 +1,11 @@
1
1
  staging:
2
- mode: scp
3
2
  repo: git
4
- ssh_key:
5
- host:
6
- username: ubuntu
7
- remote_base: ~/
3
+ mode: scp
4
+ scp:
5
+ ssh_key:
6
+ user:
7
+ host:
8
+ remote_base: ~/
8
9
  files:
9
- LICENSE: LICENSE
10
- example-dir: example-dir
10
+ example-file: example-file
11
+ example-directory: example-directory
data/lib/punt.rb CHANGED
@@ -9,6 +9,7 @@ require 'punt/helper/mode_helper'
9
9
  require 'punt/helper/repo_helper'
10
10
 
11
11
  require 'punt/deploy'
12
+ require 'punt/remote'
12
13
 
13
14
  require 'punt/cmd/cmd'
14
15
  require 'punt/cmd/cmd_init'
@@ -8,97 +8,7 @@ class CmdRemote < Cmd
8
8
 
9
9
  def run(argv)
10
10
  env = argv.shift
11
- env = puntfile.first.first unless env
12
11
 
13
- environment = puntfile[env] if env
14
-
15
- if (!environment)
16
- raise "No environment #{env} was found in the puntfile"
17
- end
18
-
19
- mode = environment["mode"]
20
-
21
- if mode != "scp"
22
- raise "No mode available for the given mode '#{mode}'"
23
- end
24
-
25
- puts "Fetching Version for #{env}"
26
- puts ""
27
-
28
- # Upload Version File
29
- start_version = scp_fetch_versionfile("start", environment)
30
- success_version = scp_fetch_versionfile("success", environment)
31
-
32
- if (success_version == start_version)
33
- puts "Currently deployed version: #{success_version}"
34
- else
35
- puts "An aborted deployement was detected!"
36
- puts "\tLast Success: #{success_version}"
37
- puts "\tLast Attempt: #{start_version}"
38
- end
39
- end
40
-
41
- private
42
-
43
- def scp_fetch_versionfile(version_name, environment)
44
- versionfile = Tempfile.new('foo')
45
-
46
- scp_download(versionfile.path, ".punt_#{version_name}", environment)
47
-
48
- version = versionfile.read
49
-
50
- versionfile.unlink
51
-
52
- return version.strip
53
- end
54
-
55
- def scp_versionfile(ref, version_name, environment, dry_run: false)
56
-
57
- if (!dry_run)
58
- versionfile = Tempfile.new('foo')
59
- versionfile.write("#{ref}")
60
-
61
- scp_upload(versionfile.path, ".punt_#{version_name}", environment, dry_run: dry_run)
62
-
63
- versionfile.unlink
64
- end
65
- end
66
-
67
- def scp_download(local_file, remote, environment, dry_run: false)
68
- scp_args = ["scp"]
69
- scp = scp_opts(environment, scp_args)
70
-
71
- if (File.directory?(local_file))
72
- scp << "-r"
73
- end
74
-
75
- scp << scp_remote_file(remote, environment)
76
- scp << local_file
77
-
78
- scp_command = scp.join(" ")
79
-
80
- `#{scp_command}` unless dry_run
81
- end
82
-
83
- def scp_opts(environment, scp_args)
84
- if (environment["ssh_key"])
85
- scp_args << "-i"
86
- scp_args << environment["ssh_key"]
87
- end
88
- end
89
-
90
- def scp_remote_file(remote, environment)
91
- if !remote.start_with?("/") && !remote.start_with?("~")
92
- remote = File.join(environment["remote_base"], remote)
93
- end
94
-
95
- return "#{scp_host(environment)}#{remote}"
96
- end
97
-
98
- def scp_host(environment)
99
- arg = "#{environment["host"]}:"
100
- arg = "#{environment["username"]}@#{arg}" if environment["username"]
101
-
102
- return arg
12
+ Remote.new.remote(env: env)
103
13
  end
104
14
  end
data/lib/punt/deploy.rb CHANGED
@@ -10,10 +10,10 @@ class Deploy
10
10
  environment = punt_environment(env: env)
11
11
 
12
12
  mode = get_mode(environment)
13
+ mode_opts = mode.mode_opts(environment)
13
14
  repo = get_repo(environment)
14
15
 
15
16
  repo_state = repo.save_state()
16
- mode_opts = mode.mode_opts(environment)
17
17
 
18
18
  starting_revision = repo.current_revision_name(short: true)
19
19
 
@@ -43,7 +43,7 @@ class Deploy
43
43
  # Upload Files
44
44
  if environment["files"]
45
45
  environment["files"].each do |key, value|
46
- mode.upload(key, value, mode_opts: mode_opts, dry_run: dry_run, verbose: true)
46
+ mode.transfer(key, value, mode_opts: mode_opts, dry_run: dry_run, verbose: true)
47
47
  end
48
48
  end
49
49
 
@@ -12,6 +12,6 @@ module AssetHelper
12
12
  end
13
13
 
14
14
  def asset_path(*path)
15
- return File.join(File.dirname(__FILE__), "..", "..", "assets", path)
15
+ return File.join(File.dirname(__FILE__), "..", "..", "..", "assets", path)
16
16
  end
17
17
  end
@@ -4,7 +4,7 @@ class ModeScp
4
4
  return environment["scp"]
5
5
  end
6
6
 
7
- def upload(local_path, remote_path, mode_opts: nil, dry_run: false, verbose: true)
7
+ def transfer(local_path, remote_path, mode_opts: nil, dry_run: false, verbose: true)
8
8
  scp_args = ["scp"]
9
9
  scp_common_options(mode_opts, scp_args)
10
10
 
@@ -21,6 +21,23 @@ class ModeScp
21
21
  `#{scp_command}` unless dry_run
22
22
  end
23
23
 
24
+ def download(local_path, remote_path, mode_opts: nil, dry_run: false, verbose: true)
25
+ scp_args = ["scp"]
26
+ scp_common_options(mode_opts, scp_args)
27
+
28
+ if (File.directory?(local_path))
29
+ scp_args << "-r"
30
+ end
31
+
32
+ scp_args << scp_remote_file(remote_path, mode_opts)
33
+ scp_args << local_path
34
+
35
+ scp_command = scp_args.join(" ")
36
+
37
+ puts scp_command if verbose
38
+ `#{scp_command}` unless dry_run
39
+ end
40
+
24
41
  def upload_versionfile(version, deploystage, mode_opts: nil)
25
42
  filename = ".punt_#{deploystage}"
26
43
 
@@ -28,11 +45,25 @@ class ModeScp
28
45
  versionfile.write("#{version}")
29
46
  versionfile.close()
30
47
 
31
- upload(versionfile.path, filename, mode_opts: mode_opts)
48
+ transfer(versionfile.path, filename, mode_opts: mode_opts)
32
49
 
33
50
  versionfile.unlink
34
51
  end
35
52
 
53
+ def download_versionfile(deploystage, mode_opts: nil)
54
+ filename = ".punt_#{deploystage}"
55
+
56
+ versionfile = Tempfile.new(filename)
57
+
58
+ download(versionfile.path, filename, mode_opts: mode_opts, verbose: false)
59
+
60
+ version = versionfile.read
61
+
62
+ versionfile.unlink
63
+
64
+ return version
65
+ end
66
+
36
67
  private
37
68
 
38
69
  def scp_common_options(scp_opts, scp_args)
@@ -0,0 +1,27 @@
1
+ class Remote
2
+ include PuntfileHelper
3
+ include ModeHelper
4
+
5
+ def remote(env: nil)
6
+
7
+
8
+ environment = punt_environment(env: env)
9
+
10
+ mode = get_mode(environment)
11
+ mode_opts = mode.mode_opts(environment)
12
+
13
+ puts "Fetching Version for #{env}"
14
+ puts ""
15
+
16
+ start_version = mode.download_versionfile("start", mode_opts: mode_opts)
17
+ success_version = mode.download_versionfile("success", mode_opts: mode_opts)
18
+
19
+ if (success_version == start_version)
20
+ puts "Currently deployed version: #{success_version}"
21
+ else
22
+ puts "An aborted deployement was detected!"
23
+ puts "\tLast Success: #{success_version}"
24
+ puts "\tLast Attempt: #{start_version}"
25
+ end
26
+ end
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: punt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Callaway
@@ -31,6 +31,7 @@ files:
31
31
  - lib/punt/helper/puntfile_helper.rb
32
32
  - lib/punt/helper/repo_helper.rb
33
33
  - lib/punt/mode/mode_scp.rb
34
+ - lib/punt/remote.rb
34
35
  - lib/punt/repo/repo_git.rb
35
36
  homepage: http://rubygems.org/gems/punt
36
37
  licenses: