rcmd 1.6.3 → 1.6.4

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: 80c6c434947313790ac40baa6f5907edc3f2558d
4
- data.tar.gz: bf1058baa67bf2508732a6df6342b891a86c8ee2
3
+ metadata.gz: ef2d6e4a0f3903338259d59c44d9b28ef9d3a2c6
4
+ data.tar.gz: f2fb6ce8e638474cec958d9b04f7043110d93524
5
5
  SHA512:
6
- metadata.gz: d7cf46fcecfd98d8d7fc9335d388d6d9e4a90a49519867e13626cd7b7ac3a36a27451f6f0265f85dd5f892b873c2638f5674e8aed601e5a688812e2b1f7e3ac9
7
- data.tar.gz: c185669cbd098bb165efc7b425679c82417592ae5d0378d61f6641df92de26dd7f011c8fc71b523f74c3bf50dc922cce6b3c5b70798a5a815791870bb768f159
6
+ metadata.gz: 57bf0fb42a1c513a49626d4415e57f0afd9a9834a90bd4c5a2a6a522bf4abbfadabbda77604abf4f1c6aed21f43e600e3ff0406f5986cebb3e40a0fe14f2f739
7
+ data.tar.gz: 5ff7aa09debaa9ad74ba5eadf733d79f543c8ebcbe212c8997d7a851cf11147268f5d64c6764b16f536affe05e2471373075fde65154f7d9f909d9a3a779bfd0
data/.gitignore CHANGED
@@ -1 +1,3 @@
1
1
  pkg/*
2
+ testdb
3
+ .rspec_status
@@ -1,9 +1,13 @@
1
- example_id | status | run_time |
2
- ------------------------ | ------ | --------------- |
3
- ./spec/rcmd_spec.rb[1:1] | passed | 0.00078 seconds |
4
- ./spec/rcmd_spec.rb[1:2] | passed | 0.00116 seconds |
5
- ./spec/rcmd_spec.rb[1:3] | passed | 0.00099 seconds |
6
- ./spec/rcmd_spec.rb[1:4] | passed | 0.00018 seconds |
7
- ./spec/rcmd_spec.rb[1:5] | passed | 0.00019 seconds |
8
- ./spec/rcmd_spec.rb[1:6] | passed | 0.00133 seconds |
9
- ./spec/rcmd_spec.rb[1:7] | passed | 0.00011 seconds |
1
+ example_id | status | run_time |
2
+ ------------------------- | ------ | --------------- |
3
+ ./spec/rcmd_spec.rb[1:1] | passed | 0.00067 seconds |
4
+ ./spec/rcmd_spec.rb[1:2] | passed | 0.00093 seconds |
5
+ ./spec/rcmd_spec.rb[1:3] | passed | 0.00077 seconds |
6
+ ./spec/rcmd_spec.rb[1:4] | passed | 0.00016 seconds |
7
+ ./spec/rcmd_spec.rb[1:5] | passed | 0.00014 seconds |
8
+ ./spec/rcmd_spec.rb[1:6] | passed | 0.00104 seconds |
9
+ ./spec/rcmd_spec.rb[1:7] | passed | 0.00011 seconds |
10
+ ./spec/rcmd_spec.rb[1:8] | passed | 0.01113 seconds |
11
+ ./spec/rcmd_spec.rb[1:9] | passed | 0.02283 seconds |
12
+ ./spec/rcmd_spec.rb[1:10] | passed | 0.00779 seconds |
13
+ ./spec/rcmd_spec.rb[1:11] | passed | 0.00637 seconds |
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rcmd (1.6.2)
4
+ rcmd (1.6.4)
5
5
  activerecord
6
6
  activesupport
7
7
  io-console
@@ -52,6 +52,7 @@ GEM
52
52
  diff-lcs (>= 1.2.0, < 2.0)
53
53
  rspec-support (~> 3.6.0)
54
54
  rspec-support (3.6.0)
55
+ sqlite3 (1.3.13)
55
56
  thread (0.2.2)
56
57
  thread_safe (0.3.6)
57
58
  timers (4.1.2)
@@ -78,6 +79,7 @@ DEPENDENCIES
78
79
  rake (~> 10.0)
79
80
  rcmd!
80
81
  rspec (~> 3.0, >= 2.0.0)
82
+ sqlite3
81
83
 
82
84
  BUNDLED WITH
83
85
  1.15.4
data/README.md CHANGED
@@ -11,6 +11,8 @@ thread and creating the ssh sessions in those threads.
11
11
  - Username can be specified. (Default is root. Requires valid ssh-key in ~/.ssh)
12
12
  - Output shows which host the output is from
13
13
  - Stdout can be suppressed, only allowing for stderr to be shown
14
+ - Usage of Regex for generating the host list
15
+ - Support for SQLite3, MySql/MariaDB and PostgreSQL queries for generating host list
14
16
 
15
17
  ## Installation
16
18
  rcmd is available as a gem and kan be installed with `gem install rcmd`
@@ -163,18 +165,20 @@ If you are wanting to modify the code by all means do so. If you clone this rep
163
165
  Available Rake tasks are:
164
166
 
165
167
  ```bash
166
- rake build # Build rcmd-1.5.5.gem into the pkg directory
168
+ rake build # Build rcmd-1.6.4.gem into the pkg directory
167
169
  rake clean # Remove any temporary products
168
170
  rake clobber # Remove any generated files
169
171
  rake clobber_rdoc # Remove RDoc HTML files
170
172
  rake console # Open an IRB console with this gem loaded
171
- rake install # Build and install rcmd-1.5.5.gem into system gems
172
- rake install:local # Build and install rcmd-1.5.5.gem into system gems without network access
173
+ rake install # Build and install rcmd-1.6.4.gem into system gems
174
+ rake install:local # Build and install rcmd-1.6.4.gem into system gems without network access
173
175
  rake rdoc # Build RDoc HTML files
174
176
  rake reinstall # Remove, build, and install gem
175
- rake release[remote] # Create tag v1.5.5 and build and push rcmd-1.5.5.gem to Rubygems
177
+ rake release[remote] # Create tag v1.6.4 and build and push rcmd-1.6.4.gem to Rubygems
176
178
  rake rerdoc # Rebuild RDoc HTML files
177
- rake spec # Run RSpec code examples
179
+ rake test:all # Run all RSpec tests
180
+ rake test:db # Test Database functionality (sqlite3 required)
181
+ rake test:mainlib # Test main rcmd lib
178
182
  ```
179
183
 
180
184
 
data/Rakefile CHANGED
@@ -1,11 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
2
  require 'rdoc/task'
4
- # require 'sqlite3'
5
3
 
6
- RSpec::Core::RakeTask.new(:spec)
4
+ task :default => ['test:all']
7
5
 
8
- task :default => :spec
9
6
 
10
7
  desc "Open an IRB console with this gem loaded"
11
8
  task :console do
@@ -16,6 +13,7 @@ task :console do
16
13
  IRB.start
17
14
  end
18
15
 
16
+
19
17
  desc "Remove, build, and install gem"
20
18
  task :reinstall do
21
19
  puts "Uninstalling #{`gem list rcmd`}"
@@ -24,8 +22,8 @@ task :reinstall do
24
22
  Rake::Task["install"].invoke
25
23
  end
26
24
 
27
- desc 'generate API documentation to doc/rdocs/index.html'
28
25
 
26
+ desc 'generate API documentation to doc/rdocs/index.html'
29
27
  Rake::RDocTask.new do |rd|
30
28
  rd.rdoc_dir = 'doc/rdocs'
31
29
  rd.main = 'README.md'
@@ -35,36 +33,38 @@ Rake::RDocTask.new do |rd|
35
33
  rd.options << '--all'
36
34
  end
37
35
 
38
- # desc 'generate and populate a test sqlite database'
39
- # task :testdb do
40
- # begin
41
- # db = SQLite3::Database.new "testdb"
42
- # db.execute "create table servers(id integer primary key autoincrement, hostname text not null, stype text not null, os_type text not null)"
43
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node1', 'dev', 'rhel6')"
44
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node2', 'dev', 'rhel6')"
45
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node3', 'dev', 'rhel6')"
46
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node4', 'dev', 'rhel7')"
47
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node5', 'dev', 'rhel6')"
48
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node6', 'web', 'rhel6')"
49
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node7', 'web', 'rhel6')"
50
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node8', 'web', 'rhel7')"
51
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node9', 'web', 'rhel7')"
52
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node10', 'admin', 'ubuntu-LTS')"
53
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node11', 'admin', 'ubuntu-LTS')"
54
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node12', 'admin', 'ubuntu')"
55
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node13', 'admin', 'ubuntu')"
56
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node14', 'compute', 'debiuan')"
57
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node15', 'compute', 'debiuan')"
58
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node16', 'compute', 'debiuan')"
59
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node17', 'compute', 'debiuan')"
60
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node18', 'db', 'slackware')"
61
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node19', 'db', 'slackware')"
62
- # db.execute "INSERT INTO servers (hostname, stype, os_type) VALUES ( 'node20', 'db', 'slackware')"
36
+ #
37
+ # RSpec tasks
38
+ #
39
+ begin
40
+ namespace :test do
41
+ require "rspec/core/rake_task"
42
+ require 'sqlite3'
63
43
 
64
- # rescue SQLite3::Exception => e
65
- # puts "Exception occurred"
66
- # puts e
67
- # ensure
68
- # db.close if db
69
- # end
70
- # end
44
+ desc 'Test Database functionality (sqlite3 required)'
45
+ RSpec::Core::RakeTask.new(:db) do |t|
46
+ t.rspec_opts = "--tag db"
47
+ end
48
+ end
49
+
50
+ namespace :test do
51
+ desc 'Test main rcmd lib'
52
+ RSpec::Core::RakeTask.new(:mainlib) do |t|
53
+ t.rspec_opts = "--tag mainlib"
54
+ end
55
+ end
56
+
57
+ namespace :test do
58
+ desc "Run all RSpec tests"
59
+ RSpec::Core::RakeTask.new(:all) do |t|
60
+ t.rspec_opts = "--tag mainlib --tag db"
61
+ end
62
+ end
63
+ rescue LoadError
64
+ desc 'RSpec rake task not available'
65
+ task :spec do
66
+ abort 'RSpec rake tasl is not available. Ensure rspec-core is installed'
67
+ end
68
+ ensure
69
+ File.delete("testdb") if File.exist?("testdb")
70
+ end
@@ -109,6 +109,11 @@ the node list.</p>
109
109
  <p>Output shows which host the output is from</p>
110
110
  </li><li>
111
111
  <p>Stdout can be suppressed, only allowing for stderr to be shown</p>
112
+ </li><li>
113
+ <p>Usage of Regex for generating the host list</p>
114
+ </li><li>
115
+ <p>Support for SQLite3, MySql/MariaDB and PostgreSQL queries for generating
116
+ host list</p>
112
117
  </li></ul>
113
118
 
114
119
  <h2 id="label-Installation">Installation<span><a href="#label-Installation">&para;</a> <a href="#top">&uarr;</a></span></h2>
@@ -1,5 +1,5 @@
1
- Sat, 07 Oct 2017 11:32:53 +0000
2
- README.md Sat, 07 Oct 2017 11:31:11 +0000
1
+ Tue, 10 Oct 2017 19:34:36 +0000
2
+ README.md Mon, 09 Oct 2017 13:39:20 +0000
3
3
  lib/rcmd.rb Fri, 06 Oct 2017 20:23:25 +0000
4
4
  lib/rcmd/db.rb Sat, 07 Oct 2017 11:16:26 +0000
5
5
  lib/rcmd/version.rb Sat, 07 Oct 2017 11:20:01 +0000
@@ -104,6 +104,11 @@ the node list.</p>
104
104
  <p>Output shows which host the output is from</p>
105
105
  </li><li>
106
106
  <p>Stdout can be suppressed, only allowing for stderr to be shown</p>
107
+ </li><li>
108
+ <p>Usage of Regex for generating the host list</p>
109
+ </li><li>
110
+ <p>Support for SQLite3, MySql/MariaDB and PostgreSQL queries for generating
111
+ host list</p>
107
112
  </li></ul>
108
113
 
109
114
  <h2 id="label-Installation">Installation<span><a href="#label-Installation">&para;</a> <a href="#top">&uarr;</a></span></h2>
Binary file
@@ -70,14 +70,13 @@ not implemented.
70
70
  @db_os_queries = true
71
71
 
72
72
  # Method for overiding the location and name of the default config
73
- # file
73
+ # file (Used by RSpec tests)
74
74
  def DB.override_config_file(path)
75
75
  @config_file = path
76
76
  end
77
77
 
78
78
  # Create a base config file
79
79
  def DB.create_config
80
- puts "Function: #{@config_dir}"
81
80
  unless File.directory?(@config_dir)
82
81
  FileUtils.mkdir_p(@config_dir)
83
82
  end
@@ -90,7 +89,7 @@ not implemented.
90
89
  end
91
90
 
92
91
  # Performs "LIKE" queries on the host_field (hostname)
93
- def DB.query_by_hostname(term)
92
+ def DB.query_by_hostname(term)
94
93
  return where("#{@conf[:host_field]} LIKE ?", term ).map { |r| r[@conf[:host_field]] }
95
94
  end
96
95
 
@@ -156,20 +155,24 @@ not implemented.
156
155
  # adapter and set the table_name variable of the class.
157
156
  def DB.db_connect
158
157
  self.load_config
159
-
160
- if @conf[:adapter].downcase == "sqlite3"
161
- ActiveRecord::Base.establish_connection(:adapter => @conf[:adapter].downcase,
162
- :database => @conf[:database])
163
- else
164
- ActiveRecord::Base.establish_connection(
165
- :adapter => @conf[:adapter].downcase,
166
- :host => @conf[:host],
167
- :username => @conf[:username],
168
- :password => @conf[:password],
169
- :database => @conf[:database] )
170
- end
171
158
 
172
- @table_name = @conf[:table]
159
+ begin
160
+ if @conf[:adapter].downcase == "sqlite3"
161
+ ActiveRecord::Base.establish_connection(:adapter => @conf[:adapter].downcase,
162
+ :database => @conf[:database])
163
+ else
164
+ ActiveRecord::Base.establish_connection(
165
+ :adapter => @conf[:adapter].downcase,
166
+ :host => @conf[:host],
167
+ :username => @conf[:username],
168
+ :password => @conf[:password],
169
+ :database => @conf[:database] )
170
+ end
171
+
172
+ @table_name = @conf[:table]
173
+ rescue RuntimeError, AdapterNotFound, ArgumentError => e
174
+ raise RuntimeError, "DB Error when configuring connection: #{e}"
175
+ end
173
176
  end
174
177
  end
175
178
  end
@@ -1,4 +1,4 @@
1
1
  module Rcmd # :notnew:
2
2
  # +VERSION+ - Version number string
3
- VERSION = "1.6.3"
3
+ VERSION = "1.6.4"
4
4
  end
@@ -39,6 +39,7 @@ Gem::Specification.new do |spec|
39
39
  spec.add_runtime_dependency('activesupport')
40
40
  spec.add_runtime_dependency('activerecord')
41
41
  spec.add_runtime_dependency('regexp-examples')
42
+ spec.add_development_dependency('sqlite3')
42
43
  spec.add_development_dependency('rspec', '~> 3.0', '>= 2.0.0')
43
44
  spec.add_development_dependency "bundler", ">= 1.0"
44
45
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcmd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.3
4
+ version: 1.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-07 00:00:00.000000000 Z
11
+ date: 2017-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: sqlite3
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: rspec
113
127
  requirement: !ruby/object:Gem::Requirement