esmdl 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ef6848bd1b390edc24b2fb8fe9d9ede3b53750f3
4
+ data.tar.gz: 8e2a91d269e4cb268e6470be2e7acf733d446496
5
+ SHA512:
6
+ metadata.gz: 8312249a1952205d8b4cf77da5c182d1b7d97924c03873a114dfa0340bcc837c0d39464f7052fda08de5a81f3340411ad46d3e451719ced6ca72f95a91805be9
7
+ data.tar.gz: 7d8807c8f082470454f9037d91986486ca3bbf6b8d25b1af97cfe761f4de728b991583840532276626e6e873e28effb8227d6ee454fd24cf6197fae741fc6660
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.12.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in esmdl.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # esmdl
2
+
3
+ esmdl is a Ruby gem that provides a command line interface that replicates (some of) the release download functionality of Ellucian Solutions Manager. It is not authored or supported by Ellucian and does not provide any of the installation of provisioning functionality of ESM.
4
+
5
+ It is intended to be used by licensed ellucian customers to download available releases without requiring the installation of ESM.
6
+
7
+ ## Installation
8
+
9
+ Install is simply:
10
+
11
+ ```
12
+ $ gem install esmdl
13
+ ```
14
+
15
+ ## Configuration
16
+
17
+ The only required configuration parameters are the `username` and `password` of an Ellucian Download Center account. This can either be supplied in the file `~/.esmdl`:
18
+ ```yaml
19
+ username: "myusername"
20
+ password: "!s3cr3t*"
21
+ ```
22
+ or via the command line arguments `--username` and `--password`. The other available configuration values are `esmversion` (defaults to 1.7), `stage_dir` (defaults to './'), and `base_url`. Command line parameters override any parameters from `~/.esmdl`.
23
+
24
+ ## Usage
25
+ Downloading a release, associated documentation, and ESM installation metadata:
26
+ ```
27
+ $ esmdl get --name=general-admin-9020020u.trz --docs --metadata
28
+ Starting download of general-admin-9020020u.trz...done! (201.44 MiB)
29
+ Starting download of general-admin-9020020d.trz...done! (1.35 MiB)
30
+ Starting download of general-admin-9020020u.zip...done! (2.66 KiB)
31
+ ```
32
+
33
+ Finding available releases is done through the `list` subcommand.
34
+
35
+ Listing available licensed products:
36
+ ```
37
+ $ esmdl list products
38
+ BMUI: BMUI Banner Multi Upgrade Installer
39
+ BNR_ADMCOM: Banner Admin Common
40
+ BNR_ADV: Banner Advancement
41
+ ...
42
+ ```
43
+
44
+ Filtering that list:
45
+ ```
46
+ $ esmdl list products --filter=student
47
+ BNR_STU: Banner Student
48
+ BNR_STUSS: Banner Student Self-Service
49
+ BXE_ETRANS: Banner Student eTranscript
50
+ ...
51
+ ```
52
+
53
+ Listing available releases for a given product:
54
+ ```
55
+ $ esmdl list releases --product=BNR_STU
56
+ Banner Student Upgrade 8.5.5 (stu80505u.trz) - BNR_STU -2012-11-15
57
+ Banner Student Upgrade 8.5.6 (stu80506u.trz) - BNR_STU -2013-02-15
58
+ Banner Student Upgrade 8.5.7 (stu80507u.trz) - BNR_STU -2013-05-31
59
+ ...
60
+ ```
61
+
62
+ Or by filter:
63
+ ```
64
+ $ esmdl list releases --filter=admin
65
+ Banner Admin Document Management 9.2.0.18 (extsol-admin-9020018u.trz) - BNR_DMS -2016-03-14
66
+ Banner Admin Finance 9.2.0.18 (finance-admin-9020018u.trz) - BNR_FIN -2016-03-14
67
+ Banner Admin Position Control 9.2.0.18 (posnctl-admin-9020018u.trz) - BNR_POSCTL -2016-03-14
68
+ Banner Admin Human Resources 9.2.0.18 (payroll-admin-9020018u.trz) - BNR_HRPAY -2016-03-15
69
+ ...
70
+ ```
71
+
72
+ ## Contributing
73
+
74
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ian-d/esmdl.
75
+
76
+ ## License
77
+
78
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "esmdl"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+ ESMDl.config
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start
data/bin/esmdl ADDED
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env ruby
2
+ require 'thor'
3
+ require 'esmdl'
4
+ require 'date'
5
+ require 'yaml'
6
+
7
+ module ESMRunner
8
+ class << self
9
+ def configure(options)
10
+ if File.exists?("#{Dir.home}/.esmdl") then
11
+ options = YAML.load(IO.read("#{Dir.home}/.esmdl")).merge options
12
+ end
13
+
14
+ options = options.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
15
+
16
+ unless options[:password] && options[:username]
17
+ puts "ERROR: Couldn't find .esmdl file and --username/--password not passed."
18
+ exit
19
+ end
20
+
21
+ ESMDl.configure do |config|
22
+ config.username = options[:username]
23
+ config.password = options[:password]
24
+ config.stage_dir = options[:stage_dir]
25
+ config.base_url = options[:base_url]
26
+ config.esmversion = options[:esmversion]
27
+ end
28
+
29
+ begin
30
+ ESMDl.fetch_metadata
31
+ rescue Exception => e
32
+ puts "There was an error fetching the ESM metadata. Double check your username and password?"
33
+ puts e.message
34
+ exit
35
+ end
36
+ end
37
+ end
38
+
39
+ class List < Thor
40
+ desc 'products', 'List licensed products and categories.'
41
+ option :filter, default: '.*', desc: 'A regex to apply to product names.'
42
+ def products
43
+ ESMRunner.configure parent_options
44
+ ESMDl.products.each do |k, v|
45
+ puts "#{k}: #{v}" if v =~ /#{options[:filter]}/i
46
+ end
47
+ end
48
+
49
+ desc 'releases', 'List available releases.'
50
+ option :product, desc: 'The product name (BNR_ADVSS, BXE_STUAPI, etc) to list.'
51
+ option :filter, default: '.', desc: 'A regex to apply to release names.'
52
+ def releases
53
+ ESMRunner.configure parent_options
54
+ rel_list = []
55
+ ESMDl.releases.each do |r|
56
+ rel_list << r if r['productId'] == options[:product] || options[:product].nil?
57
+ end
58
+ rel_list.keep_if{ |x| x['name'] =~ /#{options[:filter]}/i || x['rlsArtifactsFile'] =~ /#{options[:filter]}/i}
59
+ rel_list.sort! { |l, r| DateTime.parse(l['rlsDate']) <=> DateTime.parse(r['rlsDate']) }
60
+ rel_list.each do |r|
61
+ puts "#{r['name']} (#{r['rlsArtifactsFile']}) - #{r['productId']} -#{DateTime.parse(r['rlsDate']).to_date}"
62
+ end
63
+ end
64
+
65
+ desc 'info', 'List information about a single release.'
66
+ option :name, required: true, desc: 'The patch archive name (ex: twb80600u.trz, student-overall-90400u.trz).'
67
+ def info
68
+ ESMRunner.configure parent_options
69
+ rel = ESMDl.releases.find { |x| x['rlsArtifactsFile'] == options[:name] }
70
+ if !rel.nil?
71
+ say rel['name'], :green
72
+ puts "Product: #{rel['productId']}"
73
+ puts "Version: #{rel['version']}"
74
+ puts "Status: #{rel['status']}"
75
+ puts "Release Date: #{DateTime.parse(rel['rlsDate']).to_date}"
76
+ puts "Has Docs: #{rel['rlsDocFile'] != ''}"
77
+ else
78
+ say 'Could not find a release by that name.', :yellow
79
+ end
80
+ end
81
+ end
82
+
83
+ class ESMCli < Thor
84
+ default_task :help
85
+
86
+ class_option :username, type: :string
87
+ class_option :password, type: :string
88
+ class_option :stage_dir, type: :string, default: './'
89
+ class_option :base_url, type: :string, default: 'https://esmsvc.ellucian.com:8443'
90
+ class_option :esmversion, type: :string, default: '1.7'
91
+ #class_option :verbose, type: :boolean, default: false
92
+
93
+ desc 'list [products, releases, info]', 'list products, releases, or single release info'
94
+ subcommand 'list', List
95
+
96
+ desc 'get', 'Download patches, documentation, and release artifacts.'
97
+ option :name, required: true, desc: 'The patch archive name to download (ex: twb80600u.trz, student-overall-90400u.trz).'
98
+ option :docs, type: :boolean, default: true, desc: 'Download documentation if available.'
99
+ option :metadata, type: :boolean, default: false, desc: 'Download ESM installation metadata.'
100
+ def get
101
+ ESMRunner.configure options
102
+ rel = ESMDl.releases.find { |x| x['rlsArtifactsFile'] == options[:name] }
103
+ if !rel.nil? then
104
+ ESMDl::Download.new(rel, options[:docs], options[:metadata])
105
+ else
106
+ say 'Could not find a release by that name.', :yellow
107
+ end
108
+ end
109
+ end
110
+ end
111
+
112
+ ESMRunner::ESMCli.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/esmdl.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'esmdl/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "esmdl"
8
+ spec.version = Esmdl::VERSION
9
+ spec.authors = ["Ian Dillon"]
10
+ spec.email = ["dillon@etsu.edu"]
11
+
12
+ spec.description = %q{A simplified CLI interface for the download functionality of Ellucian Solution Manager}
13
+ spec.summary = spec.description
14
+ spec.homepage = "https://github.com/ian-d/esmdl"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "bin"
19
+ spec.executables = ["esmdl"]
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_runtime_dependency "thor", ">= 0.19.1"
23
+ spec.add_runtime_dependency "ruby-progressbar", ">= 1.8.1"
24
+ spec.add_runtime_dependency "filesize", ">= 0.1.1"
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.12"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+ end
@@ -0,0 +1,18 @@
1
+ module ESMDl
2
+ class Configuration
3
+ attr_accessor :username
4
+ attr_accessor :password
5
+ attr_accessor :stage_dir
6
+ attr_accessor :base_url
7
+ attr_accessor :verbosity
8
+ attr_accessor :esmversion
9
+
10
+ def initialize
11
+ @verbosity = :normal
12
+ end
13
+
14
+ def stage_dir=(dir)
15
+ @stage_dir = "#{dir}/" unless dir.end_with? '/'
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,43 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'filesize'
4
+
5
+ module ESMDl
6
+ class Download
7
+ def initialize(release, with_doc = true, with_metadata = false)
8
+ @release = release
9
+ fetch download_url(@release['rlsArtifactsPath'], @release['rlsArtifactsFile']), @release['rlsArtifactsFile']
10
+ fetch download_url(@release['rlsDocPath'], @release['rlsDocFile']), @release['rlsDocFile'] if with_doc
11
+ fetch download_url(@release['rlsMetadataPath'], @release['rlsMetadataFile']), @release['rlsMetadataFile'] if with_metadata
12
+ end
13
+
14
+ def download_url(filepath, filename)
15
+ url = "#{ESMDl.config.base_url}/releaseservices/Release?"
16
+ url << "login=#{ESMDl.config.username}&"
17
+ url << "productid=#{@release['productId']}&"
18
+ url << "rlsversion=#{@release['version']}&"
19
+ url << "esmversion=#{ESMDl.config.esmversion}&"
20
+ url << "filepath=#{URI.encode(filepath)}&"
21
+ url << "filename=#{filename}&"
22
+ end
23
+
24
+ def fetch(url, filename)
25
+ uri = URI(url)
26
+ full_path = "#{ESMDl.config.stage_dir}#{filename}"
27
+ print "Starting download of #{full_path}..."
28
+ Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
29
+ request = Net::HTTP::Get.new uri.request_uri
30
+ request.basic_auth ESMDl.config.username, ESMDl.config.password
31
+ http.request request do |response|
32
+ open full_path, 'w' do |io|
33
+ response.read_body do |chunk|
34
+ io.write chunk
35
+ end
36
+ end
37
+ end
38
+ end
39
+ filesize = File::size(full_path)
40
+ puts "done! (#{ Filesize.from("#{filesize} B").pretty})"
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ module Esmdl
2
+ VERSION = "0.1.0"
3
+ end
data/lib/esmdl.rb ADDED
@@ -0,0 +1,50 @@
1
+ require 'json'
2
+ require 'net/http'
3
+ require 'esmdl/version'
4
+ require 'esmdl/configuration'
5
+ require 'esmdl/download'
6
+
7
+ module ESMDl
8
+ class << self
9
+ attr_accessor :config
10
+ attr_accessor :products
11
+ attr_accessor :releases
12
+ attr_accessor :prodmap
13
+ attr_accessor :esmversion
14
+ end
15
+
16
+ def self.config
17
+ @config ||= Configuration.new
18
+ end
19
+
20
+ def self.configure
21
+ yield(config)
22
+ end
23
+
24
+ def self.fetch_metadata
25
+ uri = URI(config.base_url + "/releaseservices/AvailableReleases?esmversion=#{config.esmversion}")
26
+ r = nil
27
+
28
+ Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
29
+ request = Net::HTTP::Get.new uri.request_uri
30
+ request.basic_auth config.username, config.password
31
+ response = http.request request
32
+ if response.code != '200'
33
+ raise "Problem fetching ESM metadata: #{response.body}"
34
+ end
35
+ r = JSON.parse(response.body)
36
+ end
37
+ @products = {}
38
+ @codemap = {}
39
+ r['prodCodeMap'].split("\n").each do |line|
40
+ a = line.split(',')
41
+ @codemap[a[1]] = a[2]
42
+ end
43
+
44
+ r['clientLicensedProducts'].sort.each do |p|
45
+ @products[p] = @codemap[p]
46
+ end
47
+
48
+ @releases = r['available']
49
+ end
50
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: esmdl
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ian Dillon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.19.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.19.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: ruby-progressbar
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.8.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.8.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: filesize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.12'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.12'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ description: A simplified CLI interface for the download functionality of Ellucian
98
+ Solution Manager
99
+ email:
100
+ - dillon@etsu.edu
101
+ executables:
102
+ - esmdl
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".gitignore"
107
+ - ".rspec"
108
+ - ".travis.yml"
109
+ - Gemfile
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - bin/console
114
+ - bin/esmdl
115
+ - bin/setup
116
+ - esmdl.gemspec
117
+ - lib/esmdl.rb
118
+ - lib/esmdl/configuration.rb
119
+ - lib/esmdl/download.rb
120
+ - lib/esmdl/version.rb
121
+ homepage: https://github.com/ian-d/esmdl
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.5.1
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: A simplified CLI interface for the download functionality of Ellucian Solution
145
+ Manager
146
+ test_files: []