aem-deploy 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ab22c76d3236da230581e43fe0a2ffd5a0fa6b3
4
- data.tar.gz: 70ca68c9afb7889ccc9d65e5a78b1b7957621fee
3
+ metadata.gz: e24cbb0c947811740e490fef9b1ca92239570334
4
+ data.tar.gz: 90095fbf276da04e461674c3e54fae59d0080739
5
5
  SHA512:
6
- metadata.gz: d102bdce92580b57ba324ef46a06e2d9c4ed95a051669f583d5f1f71b6f59526d4ad19d2de46af907eeb1b1d41d88750fe1b268a0c6e41009a08dee1661cd782
7
- data.tar.gz: ddcd24ee30d71e6a47c2d4450474004c39fb2459d9ce01d6af97a883acfb95768c026d6ad35f14750e454ae6bd2da89ecc7fa26fe4ea80318208c595b6f9d7e7
6
+ metadata.gz: 974ca1105f51a9fe3c098bf15e62b3c8627f40867875f334cf7641be732f3ab7e65d914667132585479d3c9a3f82569cdf950714b735d037f158904241bf2319
7
+ data.tar.gz: 6fd62c8b6478fe5942316248a23b0f6c050bc0547236c655dc5045404d7c14db277d02dc492e57fca43054f1c662427dc204816180cd433e18a8b482aaff1a4b
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # Aem::Deploy
2
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/aem/deploy`. 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
3
+ Simple Ruby wrapper for the docker compose cli
6
4
 
7
5
  ## Installation
8
6
 
7
+ You need to have the docker compose cli installed.
8
+
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
@@ -22,17 +22,29 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ Intialize the object (crx host, user, and pass are required )
26
26
 
27
- ## Development
27
+ $ client = Aem::Deploy.new({host: '192.168.0.1', user: 'admin', pass: 'admin'})
28
+
29
+ Easy Install to CRX (uploads and installs).
30
+
31
+ $ client.install_package('/Users/meaton/Desktop/centre.zip')
28
32
 
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
+ Upload a package to CRX.
30
34
 
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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
35
+ $ client.upload_package('/Users/meaton/Desktop/centre.zip')
36
+
37
+ Recompile JSP's
38
+
39
+ $ client.recompile_jsps
40
+
41
+
42
+ ## Development
32
43
 
44
+ This project is brand new. I plan to incorporate many other methods here.
33
45
  ## Contributing
34
46
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/aem-deploy.
47
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/docker_compose_ruby.
36
48
 
37
49
 
38
50
  ## License
data/lib/aem-deploy.rb CHANGED
@@ -4,8 +4,8 @@ require "aem/deploy/session"
4
4
  module Aem
5
5
  module Deploy
6
6
  # Create a new session with teh default options.
7
- def self.new(options = {})
8
- Session.new(options)
7
+ def self.new(params = {})
8
+ Session.new(params)
9
9
  end
10
10
  end
11
11
  end
@@ -7,28 +7,47 @@ require 'pry'
7
7
  module Aem::Deploy
8
8
 
9
9
  class Session
10
- attr_reader :host, :user, :pass, :retry
10
+ attr_reader :host, :user, :pass, :retry, :upload_path
11
11
 
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?
12
+ def initialize(params)
13
+ if [:host, :user, :pass].all? {|k| params.key?(k)}
14
+ @host = params.fetch(:host)
15
+ @user = params.fetch(:user)
16
+ @pass = CGI.escape(params.fetch(:pass))
17
+ @retry = params.fetch(:retry) unless params[:retry].nil?
18
18
  else
19
19
  raise 'Hostname, User and Password are required'
20
20
  end
21
21
  end
22
22
 
23
- # Install latest package to CMS
24
- def install_package(package_path)
23
+ #upload and install package
24
+ def easy_install(package_path)
25
+ upload_package(package_path)
26
+ install_package
27
+ end
28
+
29
+ # upload package
30
+ def upload_package(package_path)
25
31
  upload = RestClient.post("http://#{@user}:#{@pass}@#{@host}/crx/packmgr/service/.json", :cmd => 'upload', :package => File.new(package_path, 'rb'), :force => true, :timeout => 300)
26
32
  parse_response(upload)
27
- upload_path = URI.encode(JSON.parse(upload)["path"])
28
- install = RestClient.post("http://#{user}:#{pass}@#{host}/crx/packmgr/service/.json#{upload_path}", :cmd => 'install', :timeout => 300)
33
+ @upload_path = URI.encode(JSON.parse(upload)["path"])
34
+ rescue RestClient::RequestTimeout => error
35
+ {error: error.to_s}.to_json
36
+ if @retry
37
+ puts 'retrying installation as there was a problem'
38
+ retry unless (@retry -= 1).zero?
39
+ end
40
+ end
41
+
42
+ # Install package
43
+ def install_package(options = {})
44
+ if options[:path]
45
+ @upload_path = options[:path]
46
+ end
47
+ install = RestClient.post("http://#{user}:#{pass}@#{host}/crx/packmgr/service/.json#{@upload_path}", :cmd => 'install', :timeout => 300)
29
48
  parse_response(install)
30
49
  rescue RestClient::RequestTimeout => error
31
- {msg: error.to_s}.to_json
50
+ {error: error.to_s}.to_json
32
51
  if @retry
33
52
  puts 'retrying installation as there was a problem'
34
53
  retry unless (@retry -= 1).zero?
@@ -42,7 +61,7 @@ module Aem::Deploy
42
61
  rescue RestClient::Found => error
43
62
  return {msg: 'JSPs recompiled'}.to_json
44
63
  rescue RestClient::RequestTimeout => error
45
- {msg: error.to_s}.to_json
64
+ {error: error.to_s}.to_json
46
65
  if @retry
47
66
  puts 'retrying installation as there was a problem'
48
67
  retry unless (@retry -= 1).zero?
@@ -54,12 +73,10 @@ module Aem::Deploy
54
73
  def parse_response(message)
55
74
  if JSON.parse(message)['success'] == true
56
75
  return " #{message}"
57
- elsif JSON.parse(message)['msg'].include?("Package already exists")
58
- return " #{message}"
59
76
  elsif message.include? ("302 Found")
60
77
  return ' JSPs Recompiled'
61
78
  else
62
- raise " It looks there was a problem uploading/installing the package #{JSON.parse(message)}"
79
+ raise " #{JSON.parse(message)}"
63
80
  end
64
81
  end
65
82
  end
@@ -1,5 +1,5 @@
1
1
  module Aem
2
2
  module Deploy
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aem-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitch Eaton