tryouts 2.1.0 → 2.1.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.
Files changed (5) hide show
  1. data/Rakefile +1 -0
  2. data/VERSION.yml +1 -1
  3. data/tryouts.gemspec +12 -11
  4. metadata +38 -31
  5. data/lib/sysinfo.rb +0 -278
data/Rakefile CHANGED
@@ -25,6 +25,7 @@ begin
25
25
  gem.email = "delano@solutious.com"
26
26
  gem.homepage = "http://github.com/delano/tryouts"
27
27
  gem.authors = ["Delano Mandelbaum"]
28
+ gem.add_dependency("sysinfo", ">= 0.7.3")
28
29
  end
29
30
  Jeweler::GemcutterTasks.new
30
31
  rescue LoadError
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :MAJOR: 2
3
3
  :MINOR: 1
4
- :PATCH: 0
4
+ :PATCH: 1
@@ -4,15 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{tryouts}
8
- s.version = "2.1.0"
7
+ s.name = "tryouts"
8
+ s.version = "2.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Delano Mandelbaum"]
12
- s.date = %q{2011-02-12}
13
- s.default_executable = %q{try}
14
- s.description = %q{Don't waste your time writing tests}
15
- s.email = %q{delano@solutious.com}
12
+ s.date = "2012-04-30"
13
+ s.description = "Don't waste your time writing tests"
14
+ s.email = "delano@solutious.com"
16
15
  s.executables = ["try"]
17
16
  s.extra_rdoc_files = [
18
17
  "LICENSE.txt",
@@ -26,7 +25,6 @@ Gem::Specification.new do |s|
26
25
  "Rakefile",
27
26
  "VERSION.yml",
28
27
  "bin/try",
29
- "lib/sysinfo.rb",
30
28
  "lib/tryouts.rb",
31
29
  "try/step1_try.rb",
32
30
  "try/step2_try.rb",
@@ -34,20 +32,23 @@ Gem::Specification.new do |s|
34
32
  "try/step4_try.rb",
35
33
  "tryouts.gemspec"
36
34
  ]
37
- s.homepage = %q{http://github.com/delano/tryouts}
35
+ s.homepage = "http://github.com/delano/tryouts"
38
36
  s.rdoc_options = ["--charset=UTF-8"]
39
37
  s.require_paths = ["lib"]
40
- s.rubyforge_project = %q{tryouts}
41
- s.rubygems_version = %q{1.5.2}
42
- s.summary = %q{Don't waste your time writing tests}
38
+ s.rubyforge_project = "tryouts"
39
+ s.rubygems_version = "1.8.22"
40
+ s.summary = "Don't waste your time writing tests"
43
41
 
44
42
  if s.respond_to? :specification_version then
45
43
  s.specification_version = 3
46
44
 
47
45
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ s.add_runtime_dependency(%q<sysinfo>, [">= 0.7.3"])
48
47
  else
48
+ s.add_dependency(%q<sysinfo>, [">= 0.7.3"])
49
49
  end
50
50
  else
51
+ s.add_dependency(%q<sysinfo>, [">= 0.7.3"])
51
52
  end
52
53
  end
53
54
 
metadata CHANGED
@@ -1,29 +1,41 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: tryouts
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.1.1
4
5
  prerelease:
5
- version: 2.1.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Delano Mandelbaum
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-02-12 00:00:00 -05:00
14
- default_executable: try
15
- dependencies: []
16
-
12
+ date: 2012-04-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sysinfo
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.7.3
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.7.3
17
30
  description: Don't waste your time writing tests
18
31
  email: delano@solutious.com
19
- executables:
32
+ executables:
20
33
  - try
21
34
  extensions: []
22
-
23
- extra_rdoc_files:
35
+ extra_rdoc_files:
24
36
  - LICENSE.txt
25
37
  - README.rdoc
26
- files:
38
+ files:
27
39
  - .gitignore
28
40
  - CHANGES.txt
29
41
  - LICENSE.txt
@@ -31,40 +43,35 @@ files:
31
43
  - Rakefile
32
44
  - VERSION.yml
33
45
  - bin/try
34
- - lib/sysinfo.rb
35
46
  - lib/tryouts.rb
36
47
  - try/step1_try.rb
37
48
  - try/step2_try.rb
38
49
  - try/step3_try.rb
39
50
  - try/step4_try.rb
40
51
  - tryouts.gemspec
41
- has_rdoc: true
42
52
  homepage: http://github.com/delano/tryouts
43
53
  licenses: []
44
-
45
54
  post_install_message:
46
- rdoc_options:
55
+ rdoc_options:
47
56
  - --charset=UTF-8
48
- require_paths:
57
+ require_paths:
49
58
  - lib
50
- required_ruby_version: !ruby/object:Gem::Requirement
59
+ required_ruby_version: !ruby/object:Gem::Requirement
51
60
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: "0"
56
- required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
66
  none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: "0"
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
62
71
  requirements: []
63
-
64
72
  rubyforge_project: tryouts
65
- rubygems_version: 1.5.2
73
+ rubygems_version: 1.8.22
66
74
  signing_key:
67
75
  specification_version: 3
68
76
  summary: Don't waste your time writing tests
69
77
  test_files: []
70
-
@@ -1,278 +0,0 @@
1
- require 'socket'
2
- require 'time'
3
-
4
- # = SysInfo
5
- #
6
- # A container for the platform specific system information.
7
- # Portions of this code were originally from Amazon's EC2 AMI tools,
8
- # specifically lib/platform.rb.
9
- class SysInfo
10
- unless defined?(IMPLEMENTATIONS)
11
- VERSION = "0.7.3".freeze
12
- IMPLEMENTATIONS = [
13
-
14
- # These are for JRuby, System.getproperty('os.name').
15
- # For a list of all values, see: http://lopica.sourceforge.net/os.html
16
-
17
- #regexp matcher os implementation
18
- [/mac\s*os\s*x/i, :unix, :osx ],
19
- [/sunos/i, :unix, :solaris ],
20
- [/windows\s*ce/i, :windows, :wince ],
21
- [/windows/i, :windows, :windows ],
22
- [/osx/i, :unix, :osx ],
23
-
24
- # These are for RUBY_PLATFORM and JRuby
25
- [/java/i, :java, :java ],
26
- [/darwin/i, :unix, :osx ],
27
- [/linux/i, :unix, :linux ],
28
- [/freebsd/i, :unix, :freebsd ],
29
- [/netbsd/i, :unix, :netbsd ],
30
- [/solaris/i, :unix, :solaris ],
31
- [/irix/i, :unix, :irix ],
32
- [/cygwin/i, :unix, :cygwin ],
33
- [/mswin/i, :windows, :windows ],
34
- [/djgpp/i, :windows, :djgpp ],
35
- [/mingw/i, :windows, :mingw ],
36
- [/bccwin/i, :windows, :bccwin ],
37
- [/wince/i, :windows, :wince ],
38
- [/vms/i, :vms, :vms ],
39
- [/os2/i, :os2, :os2 ],
40
- [nil, :unknown, :unknown ],
41
- ].freeze
42
-
43
- ARCHITECTURES = [
44
- [/(i\d86)/i, :x86 ],
45
- [/x86_64/i, :x86_64 ],
46
- [/x86/i, :x86 ], # JRuby
47
- [/ia64/i, :ia64 ],
48
- [/alpha/i, :alpha ],
49
- [/sparc/i, :sparc ],
50
- [/mips/i, :mips ],
51
- [/powerpc/i, :powerpc ],
52
- [/universal/i,:x86_64 ],
53
- [nil, :unknown ],
54
- ].freeze
55
- end
56
-
57
- attr_reader :vm
58
- attr_reader :os
59
- attr_reader :impl
60
- attr_reader :arch
61
- attr_reader :hostname
62
- attr_reader :ipaddress_internal
63
- attr_reader :uptime
64
-
65
- attr_reader :paths
66
- attr_reader :tmpdir
67
- attr_reader :home
68
- attr_reader :shell
69
- attr_reader :user
70
- attr_reader :ruby
71
-
72
- attr_reader :attr_names
73
- alias :implementation :impl
74
- alias :architecture :arch
75
-
76
- def initialize
77
- @vm, @os, @impl, @arch = find_platform_info
78
- @hostname, @ipaddress_internal, @uptime = find_network_info
79
- @ruby = RUBY_VERSION.split('.').collect { |v| v.to_i }
80
- @user = ENV['USER']
81
- require 'Win32API' if @os == :windows && @vm == :ruby
82
- end
83
-
84
- # Returns [vm, os, impl, arch]
85
- def find_platform_info
86
- vm, os, impl, arch = :ruby, :unknown, :unknown, :unknow
87
- IMPLEMENTATIONS.each do |r, o, i|
88
- next unless RUBY_PLATFORM =~ r
89
- os, impl = [o, i]
90
- break
91
- end
92
- ARCHITECTURES.each do |r, a|
93
- next unless RUBY_PLATFORM =~ r
94
- arch = a
95
- break
96
- end
97
- os == :java ? guess_java : [vm, os, impl, arch]
98
- end
99
-
100
- # Returns [hostname, ipaddr (internal), uptime]
101
- def find_network_info
102
- hostname, ipaddr, uptime = :unknown, :unknown, :unknown
103
- begin
104
- hostname = find_hostname
105
- ipaddr = find_ipaddress_internal
106
- uptime = find_uptime
107
- rescue => ex # Be silent!
108
- end
109
- [hostname, ipaddr, uptime]
110
- end
111
-
112
- # Return the hostname for the local machine
113
- def find_hostname; Socket.gethostname; end
114
-
115
- # Returns the local uptime in hours. Use Win32API in Windows,
116
- # 'sysctl -b kern.boottime' os osx, and 'who -b' on unix.
117
- # Based on Ruby Quiz solutions by: Matthias Reitinger
118
- # On Windows, see also: net statistics server
119
- def find_uptime
120
- hours = 0
121
- begin
122
- seconds = execute_platform_specific("find_uptime") || 0
123
- hours = seconds / 3600 # seconds to hours
124
- rescue => ex
125
- #puts ex.message # TODO: implement debug?
126
- end
127
- hours
128
- end
129
-
130
-
131
- # Return the local IP address which receives external traffic
132
- # from: http://coderrr.wordpress.com/2008/05/28/get-your-local-ip-address/
133
- # NOTE: This <em>does not</em> open a connection to the IP address.
134
- def find_ipaddress_internal
135
- # turn off reverse DNS resolution temporarily
136
- orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true
137
- UDPSocket.open {|s| s.connect('65.74.177.129', 1); s.addr.last } # GitHub IP
138
- ensure
139
- Socket.do_not_reverse_lookup = orig
140
- end
141
-
142
- # Returns a Symbol of the short platform descriptor in the format: VM-OS
143
- # e.g. <tt>:java-unix</tt>
144
- def platform
145
- "#{@vm}-#{@os}".to_sym
146
- end
147
-
148
- # Returns a String of the full platform descriptor in the format: VM-OS-IMPL-ARCH
149
- # e.g. <tt>java-unix-osx-x86_64</tt>
150
- def to_s(*args)
151
- "#{@vm}-#{@os}-#{@impl}-#{@arch}".to_sym
152
- end
153
-
154
- # Returns the environment paths as an Array
155
- def paths; execute_platform_specific(:paths); end
156
- # Returns the path to the current user's home directory
157
- def home; execute_platform_specific(:home); end
158
- # Returns the name of the current shell
159
- def shell; execute_platform_specific(:shell); end
160
- # Returns the path to the current temp directory
161
- def tmpdir; execute_platform_specific(:tmpdir); end
162
-
163
- private
164
-
165
- # Look for and execute a platform specific method.
166
- # The name of the method will be in the format: +dtype-VM-OS-IMPL+.
167
- # e.g. find_uptime_ruby_unix_osx
168
- #
169
- def execute_platform_specific(dtype)
170
- criteria = [@vm, @os, @impl]
171
- while !criteria.empty?
172
- meth = [dtype, criteria].join('_').to_sym
173
- return self.send(meth) if SysInfo.private_method_defined?(meth)
174
- criteria.pop
175
- end
176
- raise "#{dtype}_#{@vm}_#{@os}_#{@impl} not implemented"
177
- end
178
-
179
- def paths_ruby_unix; (ENV['PATH'] || '').split(':'); end
180
- def paths_ruby_windows; (ENV['PATH'] || '').split(';'); end # Not tested!
181
- def paths_java
182
- delim = @impl == :windows ? ';' : ':'
183
- (ENV['PATH'] || '').split(delim)
184
- end
185
-
186
- def tmpdir_ruby_unix; (ENV['TMPDIR'] || '/tmp'); end
187
- def tmpdir_ruby_windows; (ENV['TMPDIR'] || 'C:\\temp'); end
188
- def tmpdir_java
189
- default = @impl == :windows ? 'C:\\temp' : '/tmp'
190
- (ENV['TMPDIR'] || default)
191
- end
192
-
193
- def shell_ruby_unix; (ENV['SHELL'] || 'bash').to_sym; end
194
- def shell_ruby_windows; :dos; end
195
- alias_method :shell_java_unix, :shell_ruby_unix
196
- alias_method :shell_java_windows, :shell_ruby_windows
197
-
198
- def home_ruby_unix; File.expand_path(ENV['HOME']); end
199
- def home_ruby_windows; File.expand_path(ENV['USERPROFILE']); end
200
- def home_java
201
- if @impl == :windows
202
- File.expand_path(ENV['USERPROFILE'])
203
- else
204
- File.expand_path(ENV['HOME'])
205
- end
206
- end
207
-
208
- # Ya, this is kinda wack. Ruby -> Java -> Kernel32. See:
209
- # http://www.oreillynet.com/ruby/blog/2008/01/jruby_meets_the_windows_api_1.html
210
- # http://msdn.microsoft.com/en-us/library/ms724408(VS.85).aspx
211
- # Ruby 1.9.1: Win32API is now deprecated in favor of using the DL library.
212
- def find_uptime_java_windows_windows
213
- kernel32 = com.sun.jna.NativeLibrary.getInstance('kernel32')
214
- buf = java.nio.ByteBuffer.allocate(256)
215
- (kernel32.getFunction('GetTickCount').invokeInt([256, buf].to_java).to_f / 1000).to_f
216
- end
217
- def find_uptime_ruby_windows_windows
218
- # Win32API is required in self.guess
219
- getTickCount = Win32API.new("kernel32", "GetTickCount", nil, 'L')
220
- ((getTickCount.call()).to_f / 1000).to_f
221
- end
222
- def find_uptime_ruby_unix_osx
223
- # This is faster than "who" and could work on BSD also.
224
- (Time.now.to_f - Time.at(`sysctl -b kern.boottime 2>/dev/null`.unpack('L').first).to_f).to_f
225
- end
226
-
227
- # This should work for most unix flavours.
228
- def find_uptime_ruby_unix
229
- # who is sloooooow. Use File.read('/proc/uptime')
230
- (Time.now.to_i - Time.parse(`who -b 2>/dev/null`).to_f)
231
- end
232
- alias_method :find_uptime_java_unix_osx, :find_uptime_ruby_unix
233
-
234
- # Determine the values for vm, os, impl, and arch when running on Java.
235
- def guess_java
236
- vm, os, impl, arch = :java, :unknown, :unknown, :unknown
237
- require 'java'
238
- include_class java.lang.System unless defined?(System)
239
-
240
- osname = System.getProperty("os.name")
241
- IMPLEMENTATIONS.each do |r, o, i|
242
- next unless osname =~ r
243
- os, impl = [o, i]
244
- break
245
- end
246
-
247
- osarch = System.getProperty("os.arch")
248
- ARCHITECTURES.each do |r, a|
249
- next unless osarch =~ r
250
- arch = a
251
- break
252
- end
253
- [vm, os, impl, arch]
254
- end
255
-
256
- # Returns the local IP address based on the hostname.
257
- # According to coderrr (see comments on blog link above), this implementation
258
- # doesn't guarantee that it will return the address for the interface external
259
- # traffic goes through. It's also possible the hostname isn't resolvable to the
260
- # local IP.
261
- #
262
- # NOTE: This code predates the current ip_address_internal. It was just as well
263
- # but the other code is cleaner. I'm keeping this old version here for now.
264
- def ip_address_internal_alt
265
- ipaddr = :unknown
266
- begin
267
- saddr = Socket.getaddrinfo( Socket.gethostname, nil, Socket::AF_UNSPEC, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME)
268
- ipaddr = saddr.select{|type| type[0] == 'AF_INET' }[0][3]
269
- rescue => ex
270
- end
271
- ipaddr
272
- end
273
- end
274
-
275
-
276
- if $0 == __FILE__
277
- puts SysInfo.new.to_yaml
278
- end