aem-deploy 0.1.0 → 0.1.5

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: 5db0c00645694b1c63d5a1a9ebcc601693902ca1
4
- data.tar.gz: 2f4b681572c95156d4aee401ad9884d329b78ff4
3
+ metadata.gz: 1ab22c76d3236da230581e43fe0a2ffd5a0fa6b3
4
+ data.tar.gz: 70ca68c9afb7889ccc9d65e5a78b1b7957621fee
5
5
  SHA512:
6
- metadata.gz: f1bee69599c757fee1e6615c3cc6c275e2fc1032afdf6b6478020b4ba41296c891f3b7de4072926b1ace65745f50fc95a725628b6a7c93ccb3778a2dc515e01f
7
- data.tar.gz: 75cb4139630cf28410a914615b21bd6a3b35b4814f44a273dc6203c3a2662478b2b8de8bb06f22f06f6b8fa6f1734cfbd1794f3273ef2d1d0617c3da7dc7e0a5
6
+ metadata.gz: d102bdce92580b57ba324ef46a06e2d9c4ed95a051669f583d5f1f71b6f59526d4ad19d2de46af907eeb1b1d41d88750fe1b268a0c6e41009a08dee1661cd782
7
+ data.tar.gz: ddcd24ee30d71e6a47c2d4450474004c39fb2459d9ce01d6af97a883acfb95768c026d6ad35f14750e454ae6bd2da89ecc7fa26fe4ea80318208c595b6f9d7e7
Binary file
data/Gemfile CHANGED
@@ -2,4 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'pry-nav', '~> 0.2.4'
4
4
  gem 'rest-client'
5
- gemspec
5
+ gemspec :name => 'aem-deploy'
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  # delete this section to allow pushing this gem to any host.
19
19
 
20
20
 
21
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ spec.files = ["lib/aem-deploy.rb",`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }]
22
22
  spec.bindir = "exe"
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib"]
Binary file
@@ -0,0 +1,13 @@
1
+ require "aem/deploy/version"
2
+ require "aem/deploy/session"
3
+
4
+ module Aem
5
+ module Deploy
6
+ # Create a new session with teh default options.
7
+ def self.new(options = {})
8
+ Session.new(options)
9
+ end
10
+ end
11
+ end
12
+
13
+
Binary file
@@ -1,11 +1 @@
1
- require "aem/deploy/version"
2
- require "aem/deploy/session"
3
-
4
- module Aem
5
- module Deploy
6
- # Create a new session with teh default options.
7
- def self.new
8
- Session.new
9
- end
10
- end
11
- end
1
+ require File.dirname(__FILE__) + '/aem'
@@ -2,62 +2,64 @@ require 'rest_client'
2
2
  require 'open-uri'
3
3
  require 'uri'
4
4
  require 'cgi'
5
- require 'yaml'
6
- require 'rake'
7
- require 'erb'
8
5
  require 'json'
9
-
6
+ require 'pry'
10
7
  module Aem::Deploy
11
8
 
12
-
13
9
  class Session
14
10
  attr_reader :host, :user, :pass, :retry
15
11
 
16
- def initialize(host,user,pass, options = {})
17
- @host = host
18
- @user = user
19
- @password = CGI.escape(pass)
20
- @retry ||= options[:retry]
12
+ def initialize(options)
13
+ if [:host, :user, :pass].all? {|k| options.key?(k)}
14
+ @host = options.fetch(:host)
15
+ @user = options.fetch(:user)
16
+ @pass = CGI.escape(options.fetch(:pass))
17
+ @retry = options.fetch(:retry) unless options[:retry].nil?
18
+ else
19
+ raise 'Hostname, User and Password are required'
20
+ end
21
21
  end
22
22
 
23
23
  # Install latest package to CMS
24
24
  def install_package(package_path)
25
- binding.pry
26
- upload = RestClient.post("http://#{@user}:#{@pass}@#{@host}/crx/packmgr/service/.json", :cmd => 'upload', :package => File.new(package_path, 'rb'), :timeout => 300)
25
+ upload = RestClient.post("http://#{@user}:#{@pass}@#{@host}/crx/packmgr/service/.json", :cmd => 'upload', :package => File.new(package_path, 'rb'), :force => true, :timeout => 300)
27
26
  parse_response(upload)
28
- upload_path = JSON.parse(upload)["path"]
27
+ upload_path = URI.encode(JSON.parse(upload)["path"])
29
28
  install = RestClient.post("http://#{user}:#{pass}@#{host}/crx/packmgr/service/.json#{upload_path}", :cmd => 'install', :timeout => 300)
30
29
  parse_response(install)
31
30
  rescue RestClient::RequestTimeout => error
32
- if @tries?
33
- retry unless (@tries -= 1).zero?
31
+ {msg: error.to_s}.to_json
32
+ if @retry
33
+ puts 'retrying installation as there was a problem'
34
+ retry unless (@retry -= 1).zero?
34
35
  end
35
- return {msg: error.to_s}.to_json
36
36
  end
37
37
 
38
38
  # Recompiles JSPs on CMS
39
- def recompile_jsps(host,user,pass)
39
+ def recompile_jsps
40
40
  begin
41
- RestClient.post "http://#{user}:#{encoded_pass}@#{host}/system/console/slingjsp", :cmd => 'recompile', :timeout => 120
41
+ RestClient.post "http://#{@user}:#{@pass}@#{@host}/system/console/slingjsp", :cmd => 'recompile', :timeout => 120
42
42
  rescue RestClient::Found => error
43
- return {msg: error.to_s}.to_json
43
+ return {msg: 'JSPs recompiled'}.to_json
44
44
  rescue RestClient::RequestTimeout => error
45
- puts 'We had to retry recompiling JSPs. Might want to check it out'
46
- retry unless (tries -= 1).zero?
47
- return {msg: error.to_s}.to_json
45
+ {msg: error.to_s}.to_json
46
+ if @retry
47
+ puts 'retrying installation as there was a problem'
48
+ retry unless (@retry -= 1).zero?
49
+ end
48
50
  end
49
51
  end
50
52
 
51
53
  # Checks response of any request to CMS. Breaks script if unexpected response.
52
54
  def parse_response(message)
53
55
  if JSON.parse(message)['success'] == true
54
- puts " #{message}"
56
+ return " #{message}"
55
57
  elsif JSON.parse(message)['msg'].include?("Package already exists")
56
- puts " #{message}"
58
+ return " #{message}"
57
59
  elsif message.include? ("302 Found")
58
- puts ' JSPs Recompiled'
60
+ return ' JSPs Recompiled'
59
61
  else
60
- puts " Something is wroning the script with response of #{JSON.parse(message)}"
62
+ raise " It looks there was a problem uploading/installing the package #{JSON.parse(message)}"
61
63
  end
62
64
  end
63
65
  end
@@ -1,5 +1,5 @@
1
1
  module Aem
2
2
  module Deploy
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aem-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitch Eaton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-16 00:00:00.000000000 Z
11
+ date: 2016-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -45,6 +45,7 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - ".DS_Store"
48
49
  - ".gitignore"
49
50
  - Gemfile
50
51
  - LICENSE.txt
@@ -53,6 +54,9 @@ files:
53
54
  - aem-deploy.gemspec
54
55
  - bin/console
55
56
  - bin/setup
57
+ - lib/.DS_Store
58
+ - lib/aem-deploy.rb
59
+ - lib/aem/.DS_Store
56
60
  - lib/aem/deploy.rb
57
61
  - lib/aem/deploy/session.rb
58
62
  - lib/aem/deploy/version.rb
@@ -76,9 +80,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
80
  version: '0'
77
81
  requirements: []
78
82
  rubyforge_project:
79
- rubygems_version: 2.4.5.1
83
+ rubygems_version: 2.5.1
80
84
  signing_key:
81
85
  specification_version: 4
82
86
  summary: A gem to wrap deployments to Adobe Experience Manager
83
87
  test_files: []
84
- has_rdoc: