ruby-wmi 0.2.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/.gitignore +2 -0
  2. data/Gemfile +4 -0
  3. data/{README.txt → README.md} +21 -24
  4. data/Thorfile +86 -0
  5. data/lib/ruby-wmi.rb +85 -8
  6. data/lib/ruby-wmi/base.rb +355 -119
  7. data/lib/ruby-wmi/core_ext/time_ext.rb +8 -3
  8. data/lib/ruby-wmi/errors.rb +21 -0
  9. data/lib/ruby-wmi/{constants.rb → privilege.rb} +2 -2
  10. data/lib/ruby-wmi/version.rb +3 -0
  11. data/ruby-wmi.gemspec +21 -0
  12. data/spec/time_ext_spec.rb +19 -0
  13. data/spec/wql_spec.rb +80 -0
  14. data/web/public/css/active4d.css +114 -0
  15. data/web/public/css/all_hallows_eve.css +72 -0
  16. data/web/public/css/amy.css +147 -0
  17. data/web/public/css/blackboard.css +88 -0
  18. data/web/public/css/brilliance_black.css +605 -0
  19. data/web/public/css/brilliance_dull.css +599 -0
  20. data/web/public/css/cobalt.css +149 -0
  21. data/web/public/css/dawn.css +121 -0
  22. data/web/public/css/eiffel.css +121 -0
  23. data/web/public/css/espresso_libre.css +109 -0
  24. data/web/public/css/idle.css +62 -0
  25. data/web/public/css/iplastic.css +80 -0
  26. data/web/public/css/lazy.css +73 -0
  27. data/web/public/css/mac_classic.css +123 -0
  28. data/web/public/css/magicwb_amiga.css +104 -0
  29. data/web/public/css/pastels_on_dark.css +188 -0
  30. data/web/public/css/rspec.css +118 -0
  31. data/web/public/css/slush_poppies.css +85 -0
  32. data/web/public/css/spacecadet.css +51 -0
  33. data/web/public/css/sunburst.css +180 -0
  34. data/web/public/css/toader.css +285 -0
  35. data/web/public/css/twilight.css +137 -0
  36. data/web/public/css/zenburnesque.css +91 -0
  37. data/web/public/images/bg.gif +0 -0
  38. data/web/public/images/bullet.gif +0 -0
  39. data/web/public/images/footer_pic.gif +0 -0
  40. data/web/public/images/green_vr.gif +0 -0
  41. data/web/public/images/hr.gif +0 -0
  42. data/web/public/images/main.gif +0 -0
  43. data/web/public/images/nav_over.gif +0 -0
  44. data/web/public/images/nav_over_left.gif +0 -0
  45. data/web/public/images/nav_over_right.gif +0 -0
  46. data/web/public/images/nav_under.gif +0 -0
  47. data/web/public/images/your-face.gif +0 -0
  48. data/web/public/images/your-picture.gif +0 -0
  49. data/web/templates/index.html.erb +71 -0
  50. data/web/templates/template-1109.zip +0 -0
  51. metadata +109 -64
  52. data/History.txt +0 -25
  53. data/Manifest.txt +0 -14
  54. data/Rakefile +0 -62
  55. data/test/test_ruby-wmi.rb +0 -2
@@ -1,9 +1,14 @@
1
1
  class Time
2
+ class << self
3
+ def parse_swbem_date_time(string)
4
+ dt = /(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)\.(\d+)([+-]\d\d\d)/.match(string)
5
+ local($1,$2,$3,$4,$5,$6)
6
+ end
7
+ end
2
8
 
3
- def to_swebmDateTime
9
+ def to_swbem_date_time
4
10
  t = strftime("%Y%m%d%H%M%S")
5
11
  o = gmt_offset/60
6
12
  "#{t}.000000#{o}"
7
13
  end
8
-
9
- end
14
+ end
@@ -0,0 +1,21 @@
1
+ module RubyWMI
2
+ # Generic WMI exception class.
3
+ class WMIError < StandardError
4
+ end
5
+
6
+ # Invalid Class exception class.
7
+ class InvalidClass < WMIError
8
+ end
9
+
10
+ # Invalid Query exception class.
11
+ class InvalidQuery < WMIError
12
+ end
13
+
14
+ # Invalid NameSpace exception class.
15
+ class InvalidNameSpace < WMIError
16
+ end
17
+
18
+ # Read only exception class.
19
+ class ReadOnlyError < WMIError
20
+ end
21
+ end
@@ -1,4 +1,4 @@
1
- module WMI
1
+ module RubyWMI
2
2
  module Privilege
3
3
  # Required to create a primary token.
4
4
  CreateToken = 1
@@ -91,4 +91,4 @@ module WMI
91
91
  # Me/98/95: This privilege is not available.
92
92
  ManageVolume = 27
93
93
  end
94
- end
94
+ end
@@ -0,0 +1,3 @@
1
+ module RubyWMI
2
+ VERSION = '0.4.0'
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require 'ruby-wmi/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ruby-wmi"
7
+ s.version = RubyWMI::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Gordon Thiesfeld", "Jamie Winsor"]
10
+ s.email = ["gthiesfeld@gmail.com", "jwinsor@riotgames.com"]
11
+ s.homepage = "https://github.com/vertiginous/ruby-wmi"
12
+ s.summary = %q{ruby-wmi is an ActiveRecord style interface for Microsoft's Windows Management Instrumentation provider.}
13
+ s.description = s.summary
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_development_dependency 'rspec'
20
+ s.add_development_dependency 'thor'
21
+ end
@@ -0,0 +1,19 @@
1
+ require 'ruby-wmi'
2
+
3
+ describe Time do
4
+ let(:offset) { Time.local(2010).gmt_offset/60 }
5
+
6
+ describe "to_swbem_date_time" do
7
+ it "should return an SWbemDateTime string" do
8
+ t = Time.local(2010,2,1,10,22)
9
+ t.to_swbem_date_time.should eql("20100201102200.000000#{offset}")
10
+ end
11
+ end
12
+
13
+ describe "parse_swbem_date_time" do
14
+ it "should parse a swbemdatetime string" do
15
+ wbem = Time.parse_swbem_date_time("20100201102200.000000#{offset}")
16
+ wbem.to_s.should eql("2010-02-01 10:22:00 -0800")
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,80 @@
1
+ require 'ruby-wmi'
2
+
3
+ def get_wql(klass, options={})
4
+ klass.send(:construct_finder_sql, options)
5
+ end
6
+
7
+ class WmiSpec < WMI::Base
8
+ set_wmi_class_name "Win32_Something"
9
+ end
10
+
11
+ describe 'construct_finder_sql' do
12
+ it 'should return a sql string' do
13
+ wql = "SELECT * FROM Win32_Something"
14
+ get_wql(WmiSpec).should eql(wql)
15
+ end
16
+
17
+ it 'should return a sql string with conditions' do
18
+ wql = "SELECT * FROM Win32_Something WHERE DriveType = '3' AND Caption = 'C:'"
19
+ get_wql(WmiSpec, :conditions => {:drive_type => 3, :caption => 'C:'}).should eql(wql)
20
+ end
21
+
22
+ it 'should return a sql string with conditions' do
23
+ wql = "SELECT * FROM Win32_Something WHERE DriveType = '3'"
24
+ get_wql(WmiSpec, :conditions => {:drive_type => 3}).should eql(wql)
25
+ end
26
+
27
+ it 'should return a sql string with conditions' do
28
+ wql = "SELECT * FROM Win32_Something WHERE DriveType = '3'"
29
+ get_wql(WmiSpec, :conditions => ['DriveType = %s', 3]).should eql(wql)
30
+ end
31
+
32
+ it 'should return a sql string with conditions' do
33
+ wql = "SELECT * FROM Win32_Something WHERE DriveType = '3'"
34
+ get_wql(WmiSpec, :conditions => ['DriveType = ?', 3]).should eql(wql)
35
+ end
36
+
37
+ it 'should return a sql string with conditions' do
38
+ wql = "SELECT * FROM Win32_Something WHERE DriveType = '3' AND Caption = 'C:'"
39
+ get_wql(WmiSpec, :conditions => ['DriveType = ? AND Caption = ?', 3, "C:"]).should eql(wql)
40
+ end
41
+
42
+ it 'should return a sql string with conditions' do
43
+ wql = "SELECT * FROM Win32_Something WHERE FileSystem IS NULL"
44
+ get_wql(WmiSpec, :conditions => {:file_system => nil}).should eql(wql)
45
+ end
46
+
47
+ it 'should return a sql string with conditions' do
48
+ offset = Time.local(2010,4,10,9,12,37).gmt_offset/60
49
+ wql = "SELECT * FROM Win32_Something WHERE TimeWritten >= '20100403091237.000000#{offset}' AND TimeWritten < '20100410091237.000000#{offset}'"
50
+ date_range = Time.local(2010,4,3,9,12,37)...Time.local(2010,4,10,9,12,37)
51
+ get_wql(WmiSpec, :conditions => {:time_written => date_range}).should eql(wql)
52
+ end
53
+
54
+ it 'should return a sql string with conditions' do
55
+ offset = Time.local(2010,4,10,9,12,37).gmt_offset/60
56
+ wql = "SELECT * FROM Win32_Something WHERE TimeWritten >= '20100403091237.000000#{offset}' AND TimeWritten <= '20100410091237.000000#{offset}'"
57
+ date_range = Time.local(2010,4,3,9,12,37)..Time.local(2010,4,10,9,12,37)
58
+ get_wql(WmiSpec, :conditions => {:time_written => date_range}).should eql(wql)
59
+ end
60
+
61
+ it 'should return a sql string with conditions' do
62
+ wql = "SELECT * FROM Win32_Something WHERE Drivetype >= '3' AND Drivetype <= '5'"
63
+ get_wql(WmiSpec, :conditions => {:drivetype => 3..5}).should eql(wql)
64
+ end
65
+
66
+ it 'should return a sql string with conditions' do
67
+ wql = "SELECT * FROM Win32_Something WHERE Drivetype >= '3' AND Drivetype < '5'"
68
+ get_wql(WmiSpec, :conditions => {:drivetype => 3...5}).should eql(wql)
69
+ end
70
+
71
+ it 'should return a sql string with a select string' do
72
+ wql = "SELECT Name FROM Win32_Something"
73
+ get_wql(WmiSpec, :select => :name).should eql(wql)
74
+ end
75
+
76
+ it 'should return a sql string with a select array' do
77
+ wql = "SELECT Name, Caption FROM Win32_Something"
78
+ get_wql(WmiSpec, :select => [:name, :caption]).should eql(wql)
79
+ end
80
+ end
@@ -0,0 +1,114 @@
1
+ pre.active4d .DiffHeader {
2
+ background-color: #656565;
3
+ color: #FFFFFF;
4
+ }
5
+ pre.active4d .Operator {
6
+ }
7
+ pre.active4d .InheritedClass {
8
+ }
9
+ pre.active4d .TypeName {
10
+ color: #21439C;
11
+ }
12
+ pre.active4d .Number {
13
+ color: #A8017E;
14
+ }
15
+ pre.active4d .EmbeddedSource {
16
+ background-color: #ECF1FF;
17
+ }
18
+ pre.active4d {
19
+ background-color: #FFFFFF;
20
+ color: #000000;
21
+ }
22
+ pre.active4d .DiffInsertedLine {
23
+ background-color: #98FF9A;
24
+ color: #000000;
25
+ }
26
+ pre.active4d .LibraryVariable {
27
+ color: #A535AE;
28
+ }
29
+ pre.active4d .Storage {
30
+ color: #FF5600;
31
+ }
32
+ pre.active4d .InterpolatedEntity {
33
+ font-weight: bold;
34
+ color: #66CCFF;
35
+ }
36
+ pre.active4d .line-numbers {
37
+ background-color: #BAD6FD;
38
+ color: #000000;
39
+ }
40
+ pre.active4d .LocalVariable {
41
+ font-weight: bold;
42
+ color: #6392FF;
43
+ }
44
+ pre.active4d .DiffLineRange {
45
+ background-color: #1B63FF;
46
+ color: #FFFFFF;
47
+ }
48
+ pre.active4d .BlockComment {
49
+ color: #D33435;
50
+ }
51
+ pre.active4d .TagName {
52
+ color: #016CFF;
53
+ }
54
+ pre.active4d .FunctionArgument {
55
+ }
56
+ pre.active4d .BuiltInConstant {
57
+ color: #A535AE;
58
+ }
59
+ pre.active4d .LineComment {
60
+ color: #D33535;
61
+ }
62
+ pre.active4d .DiffDeletedLine {
63
+ background-color: #FF7880;
64
+ color: #000000;
65
+ }
66
+ pre.active4d .NamedConstant {
67
+ color: #B7734C;
68
+ }
69
+ pre.active4d .CommandMethod {
70
+ font-weight: bold;
71
+ color: #45AE34;
72
+ }
73
+ pre.active4d .TableField {
74
+ color: #0BB600;
75
+ }
76
+ pre.active4d .PlainXmlText {
77
+ color: #000000;
78
+ }
79
+ pre.active4d .Invalid {
80
+ background-color: #990000;
81
+ color: #FFFFFF;
82
+ }
83
+ pre.active4d .LibraryClassType {
84
+ color: #A535AE;
85
+ }
86
+ pre.active4d .TagAttribute {
87
+ color: #963DFF;
88
+ }
89
+ pre.active4d .Keyword {
90
+ font-weight: bold;
91
+ color: #006699;
92
+ }
93
+ pre.active4d .UserDefinedConstant {
94
+ }
95
+ pre.active4d .String {
96
+ color: #666666;
97
+ }
98
+ pre.active4d .DiffUnchangedLine {
99
+ color: #5E5E5E;
100
+ }
101
+ pre.active4d .TagContainer {
102
+ color: #7A7A7A;
103
+ }
104
+ pre.active4d .FunctionName {
105
+ color: #21439C;
106
+ }
107
+ pre.active4d .Variable {
108
+ font-weight: bold;
109
+ color: #0053FF;
110
+ }
111
+ pre.active4d .DateTimeLiteral {
112
+ font-weight: bold;
113
+ color: #66CCFF;
114
+ }
@@ -0,0 +1,72 @@
1
+ pre.all_hallows_eve .ClassInheritance {
2
+ font-style: italic;
3
+ }
4
+ pre.all_hallows_eve .Constant {
5
+ color: #3387CC;
6
+ }
7
+ pre.all_hallows_eve .TypeName {
8
+ text-decoration: underline;
9
+ }
10
+ pre.all_hallows_eve .TextBase {
11
+ background-color: #434242;
12
+ color: #FFFFFF;
13
+ }
14
+ pre.all_hallows_eve {
15
+ background-color: #000000;
16
+ color: #FFFFFF;
17
+ }
18
+ pre.all_hallows_eve .StringEscapesExecuted {
19
+ color: #555555;
20
+ }
21
+ pre.all_hallows_eve .line-numbers {
22
+ background-color: #73597E;
23
+ color: #FFFFFF;
24
+ }
25
+ pre.all_hallows_eve .StringExecuted {
26
+ background-color: #CCCC33;
27
+ color: #000000;
28
+ }
29
+ pre.all_hallows_eve .BlockComment {
30
+ background-color: #9B9B9B;
31
+ color: #FFFFFF;
32
+ }
33
+ pre.all_hallows_eve .TagName {
34
+ text-decoration: underline;
35
+ }
36
+ pre.all_hallows_eve .PreProcessorLine {
37
+ color: #D0D0FF;
38
+ }
39
+ pre.all_hallows_eve .SupportFunction {
40
+ color: #C83730;
41
+ }
42
+ pre.all_hallows_eve .FunctionArgument {
43
+ font-style: italic;
44
+ }
45
+ pre.all_hallows_eve .PreProcessorDirective {
46
+ }
47
+ pre.all_hallows_eve .StringEscapes {
48
+ color: #AAAAAA;
49
+ }
50
+ pre.all_hallows_eve .SourceBase {
51
+ background-color: #000000;
52
+ color: #FFFFFF;
53
+ }
54
+ pre.all_hallows_eve .TagAttribute {
55
+ }
56
+ pre.all_hallows_eve .StringLiteral {
57
+ color: #CCCC33;
58
+ }
59
+ pre.all_hallows_eve .String {
60
+ color: #66CC33;
61
+ }
62
+ pre.all_hallows_eve .Keyword {
63
+ color: #CC7833;
64
+ }
65
+ pre.all_hallows_eve .RegularExpression {
66
+ color: #CCCC33;
67
+ }
68
+ pre.all_hallows_eve .FunctionName {
69
+ }
70
+ pre.all_hallows_eve .Comment {
71
+ color: #9933CC;
72
+ }
@@ -0,0 +1,147 @@
1
+ pre.amy .PolymorphicVariants {
2
+ color: #60B0FF;
3
+ font-style: italic;
4
+ }
5
+ pre.amy .KeywordDecorator {
6
+ color: #D0D0FF;
7
+ }
8
+ pre.amy .Punctuation {
9
+ color: #805080;
10
+ }
11
+ pre.amy .InheritedClass {
12
+ }
13
+ pre.amy .InvalidDepricated {
14
+ background-color: #CC66FF;
15
+ color: #200020;
16
+ }
17
+ pre.amy .LibraryVariable {
18
+ }
19
+ pre.amy .TokenReferenceOcamlyacc {
20
+ color: #3CB0D0;
21
+ }
22
+ pre.amy .Storage {
23
+ color: #B0FFF0;
24
+ }
25
+ pre.amy .KeywordOperator {
26
+ color: #A0A0FF;
27
+ }
28
+ pre.amy .CharacterConstant {
29
+ color: #666666;
30
+ }
31
+ pre.amy .line-numbers {
32
+ background-color: #800000;
33
+ color: #000000;
34
+ }
35
+ pre.amy .ClassName {
36
+ color: #70E080;
37
+ }
38
+ pre.amy .Int64Constant {
39
+ font-style: italic;
40
+ }
41
+ pre.amy .NonTerminalReferenceOcamlyacc {
42
+ color: #C0F0F0;
43
+ }
44
+ pre.amy .TokenDefinitionOcamlyacc {
45
+ color: #3080A0;
46
+ }
47
+ pre.amy .ClassType {
48
+ color: #70E0A0;
49
+ }
50
+ pre.amy .ControlKeyword {
51
+ color: #80A0FF;
52
+ }
53
+ pre.amy .LineNumberDirectives {
54
+ text-decoration: underline;
55
+ color: #C080C0;
56
+ }
57
+ pre.amy .FloatingPointConstant {
58
+ text-decoration: underline;
59
+ }
60
+ pre.amy .Int32Constant {
61
+ font-weight: bold;
62
+ }
63
+ pre.amy .TagName {
64
+ color: #009090;
65
+ }
66
+ pre.amy .ModuleTypeDefinitions {
67
+ text-decoration: underline;
68
+ color: #B000B0;
69
+ }
70
+ pre.amy .Integer {
71
+ color: #7090B0;
72
+ }
73
+ pre.amy .Camlp4TempParser {
74
+ }
75
+ pre.amy .InvalidIllegal {
76
+ font-weight: bold;
77
+ background-color: #FFFF00;
78
+ color: #400080;
79
+ }
80
+ pre.amy .LibraryConstant {
81
+ background-color: #200020;
82
+ }
83
+ pre.amy .ModuleDefinitions {
84
+ color: #B000B0;
85
+ }
86
+ pre.amy .Variants {
87
+ color: #60B0FF;
88
+ }
89
+ pre.amy .CompilerDirectives {
90
+ color: #C080C0;
91
+ }
92
+ pre.amy .FloatingPointInfixOperator {
93
+ text-decoration: underline;
94
+ }
95
+ pre.amy .BuiltInConstant1 {
96
+ }
97
+ pre.amy {
98
+ background-color: #200020;
99
+ color: #D0D0FF;
100
+ }
101
+ pre.amy .FunctionArgument {
102
+ color: #80B0B0;
103
+ }
104
+ pre.amy .FloatingPointPrefixOperator {
105
+ text-decoration: underline;
106
+ }
107
+ pre.amy .NativeintConstant {
108
+ font-weight: bold;
109
+ }
110
+ pre.amy .BuiltInConstant {
111
+ color: #707090;
112
+ }
113
+ pre.amy .BooleanConstant {
114
+ color: #8080A0;
115
+ }
116
+ pre.amy .LibraryClassType {
117
+ }
118
+ pre.amy .TagAttribute {
119
+ }
120
+ pre.amy .Keyword {
121
+ color: #A080FF;
122
+ }
123
+ pre.amy .UserDefinedConstant {
124
+ }
125
+ pre.amy .String {
126
+ color: #999999;
127
+ }
128
+ pre.amy .Camlp4Code {
129
+ background-color: #350060;
130
+ }
131
+ pre.amy .NonTerminalDefinitionOcamlyacc {
132
+ color: #90E0E0;
133
+ }
134
+ pre.amy .FunctionName {
135
+ color: #50A0A0;
136
+ }
137
+ pre.amy .SupportModules {
138
+ color: #A00050;
139
+ }
140
+ pre.amy .Variable {
141
+ color: #008080;
142
+ }
143
+ pre.amy .Comment {
144
+ background-color: #200020;
145
+ color: #404080;
146
+ font-style: italic;
147
+ }