hscm 0.0.1

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.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hscm.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 David L. Whitehurst
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Hscm
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'hscm'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install hscm
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/hscm/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'hscm/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hscm"
8
+ spec.version = Hscm::VERSION
9
+ spec.authors = ["David L. Whitehurst"]
10
+ spec.email = ["dlwhitehurst@me.com"]
11
+ spec.summary = %q{Record software and versions for unique server hosts.}
12
+ spec.description = %q{}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
@@ -0,0 +1,23 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="FacetManager">
4
+ <facet type="gem" name="Ruby Gem">
5
+ <configuration>
6
+ <option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
7
+ <option name="GEM_APP_TEST_PATH" value="$MODULE_DIR$/test" />
8
+ <option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
9
+ </configuration>
10
+ </facet>
11
+ </component>
12
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
13
+ <exclude-output />
14
+ <content url="file://$MODULE_DIR$">
15
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
16
+ <sourceFolder url="file://$MODULE_DIR$" isTestSource="true" />
17
+ </content>
18
+ <orderEntry type="inheritedJdk" />
19
+ <orderEntry type="sourceFolder" forTests="false" />
20
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.7.9, ruby-2.0.0-p481) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="rake (v10.4.2, ruby-2.0.0-p481) [gem]" level="application" />
22
+ </component>
23
+ </module>
@@ -0,0 +1,154 @@
1
+ require "hscm/version"
2
+ require "hscm/manpage"
3
+ require "hscm/configure"
4
+ require "hscm/utility"
5
+
6
+ module Hscm
7
+ #!/usr/bin/env ruby
8
+
9
+ require 'optparse'
10
+
11
+ options = {}
12
+
13
+ option_parser = OptionParser.new do |opts|
14
+
15
+ # Configure switch
16
+ opts.on("-c","--configure-datapath") do
17
+ options[:config] = true
18
+ end
19
+
20
+ # New switch
21
+ opts.on("-n","--new") do
22
+ options[:newrec] = true
23
+ end
24
+
25
+ # List switch
26
+ opts.on("-l","--list") do
27
+ options[:list]= true
28
+ end
29
+
30
+ # Help switch
31
+ opts.on("-h","--help") do
32
+ options[:help]= true
33
+ end
34
+
35
+ # Version switch
36
+ opts.on("-v","--version") do
37
+ options[:version]= true
38
+ end
39
+
40
+ # Set username
41
+ opts.on("-u USER") do |user|
42
+ options[:user] = user
43
+ end
44
+
45
+ # Set datafilepath
46
+ opts.on("-d DATAFILEPATH") do |datafilepath|
47
+ options[:datafilepath] = datafilepath
48
+ end
49
+
50
+ # Set hostname
51
+ opts.on("-h HOST") do |host|
52
+ options[:host]= host
53
+ end
54
+
55
+ # Set product
56
+ opts.on("-p PRODUCT") do |product|
57
+ options[:product]= product
58
+ end
59
+
60
+ # Set version
61
+ opts.on("-v VERSION") do |version|
62
+ options[:version]= version
63
+ end
64
+
65
+ end # end do opts
66
+
67
+ option_parser.parse!
68
+
69
+ # use switch
70
+
71
+ if options[:help] == true
72
+ puts manpage
73
+ end
74
+ if options[:version] == true
75
+ abort("hscm version " + :VERSION)
76
+ end
77
+
78
+ if options[:newrec] == true
79
+
80
+ if options[:user].nil?
81
+ puts("Usage: hscm -n -u username -h hostname -p product -v version (More info available with --help option)")
82
+ abort(" [WARN] - username (-u) option must be provided with -n or --new configuration")
83
+ end
84
+
85
+ if options[:host].nil?
86
+ puts("Usage: hscm -n -u username -h hostname -p product -v version (More info available with --help option)")
87
+ abort(" [WARN] - hostname (-h) option must be provided with -n or --new configuration")
88
+ end
89
+
90
+ if options[:product].nil?
91
+ puts("Usage: hscm -n -u username -h hostname -p product -v version (More info available with --help option)")
92
+ abort(" [WARN] - software product (-p <PRODUCT>) option must be provided")
93
+ end
94
+
95
+ if options[:version].nil?
96
+ puts("Usage: hscm -n -u username -h hostname -p product -v version (More info available with --help option)")
97
+ abort(" [WARN] - version (-v <VERSION>) option must be provided")
98
+ end
99
+
100
+ # all options loaded, now verify that configuration has been set up
101
+ # check configuration in place?
102
+ if validateConfiguration(options[:user]) != true
103
+ abort("First-time Usage: hscm -c [--configure] -d <dateFilePath> -u <username>")
104
+ end
105
+
106
+ # go time!
107
+ File.open("/Users/dlwhitehurst/Data/#{options[:host]}.txt",'a') do |file|
108
+ file.puts "#{options[:product]}, #{options[:version]}, #{Time.now}"
109
+ puts "Product and version added."
110
+ end
111
+
112
+ puts ("Created new host software configuration item")
113
+
114
+ end
115
+
116
+ if options[:config] == true
117
+ # First-time Usage: hscm -c [--configure] -d <dateFilePath> -u <username>
118
+ if options[:user].nil?
119
+ puts("Usage: hscm -c -d <dataFilePath> -u <username> (More info available with --help option)")
120
+ abort(" [WARN] - username (-u) option must be provided with -c or --configure-datapath configuration")
121
+ end
122
+
123
+ if options[:datafilepath].nil?
124
+ puts("Usage: hscm -c -d <dataFilePath> -u <username> (More info available with --help option)")
125
+ abort(" [WARN] - datafilepath (-d) option must be provided with -c or --configure-datapath configuration")
126
+ end
127
+
128
+ setupFilePath(options[:datafilepath],options[:user])
129
+ abort("data directory path has been configured for user home in file .hscm.")
130
+ end
131
+
132
+ if options[:list] == true
133
+ if options[:host].nil?
134
+ abort("hostname (-h) option must be provided with -l or --list configuration")
135
+ end
136
+
137
+ File.open("/Users/dlwhitehurst/Data/#{options[:host]}.txt",'r') do |file|
138
+ counter = 1
139
+ printf("#########################################################################################\n")
140
+ puts "Software Products for #{options[:host]}"
141
+ printf("#########################################################################################\n")
142
+ file.readlines.each do |line|
143
+ product, version, reviewed = line.chomp.split(/,/)
144
+ printf("Product: %-25s %20s %s\n", product, version, reviewed)
145
+ printf("_________________________________________________________________________________________\n")
146
+ counter += 1
147
+ end
148
+ end
149
+ end
150
+
151
+ if options == {}
152
+ puts manpage
153
+ end
154
+ end
@@ -0,0 +1,3 @@
1
+ module Hscm
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hscm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - David L. Whitehurst
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: ''
42
+ email:
43
+ - dlwhitehurst@me.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - .idea/.name
50
+ - .idea/compiler.xml
51
+ - .idea/copyright/profiles_settings.xml
52
+ - .idea/encodings.xml
53
+ - .idea/misc.xml
54
+ - .idea/modules.xml
55
+ - .idea/scopes/scope_settings.xml
56
+ - .idea/vcs.xml
57
+ - .idea/workspace.xml
58
+ - Gemfile
59
+ - LICENSE.txt
60
+ - README.md
61
+ - Rakefile
62
+ - hscm.gemspec
63
+ - hscm.iml
64
+ - lib/hscm.rb
65
+ - lib/hscm/version.rb
66
+ homepage: ''
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.4.5
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Record software and versions for unique server hosts.
90
+ test_files: []