specinfra 0.5.2 → 0.5.3

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: 2f6848c1efbe2dd1cc262e2252ac6323c03f0fb2
4
- data.tar.gz: 9d50e6bd1adfa3e16dda75e877c8b7688fd178f6
3
+ metadata.gz: 7d2a7729c219753f59d62bc1328a39351d4a4ff4
4
+ data.tar.gz: 344bf7e974f354e503525d84db748c69ca6d97e0
5
5
  SHA512:
6
- metadata.gz: 79a536cdef75bd1d17b923a1890aef25676b06927faa710542f5223862236c40a16392d982bdc8ac8c0979bf67072449c9bd3c5357a2500e1e36ce4e0fccf1e1
7
- data.tar.gz: 60f950015c6386696680325890ad9fb20def5b77b45fb7e03114bda565048f46116920676c4a8ba6afe9952c57c68b88565da9da8a7c86bb08719856a2543f6b
6
+ metadata.gz: f1236c277dfd01ddb7d5749c0d43d476ad269f005848edf04a5619d7acb56155b2a1847760f9b472739eebf0d16a5655c23ab1131454867d8c97fa6791e714dc
7
+ data.tar.gz: 6ce175a48de5f27672c62aa448a1072bdf0a3bd817698057780c045938127ac1ec48f5c1a34fac39dbb6bb039a88f9951aa323803f37e74b93a0a553f7faf82f
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
+ require "bundler/gem_helper"
2
3
  require 'rspec/core/rake_task'
3
4
 
4
5
  task :spec => 'spec:all'
@@ -28,3 +29,40 @@ namespace :spec do
28
29
  end
29
30
  end
30
31
 
32
+ desc 'Release gem and create a release on GitHub'
33
+ task 'create_release' => 'release' do
34
+ require 'octokit'
35
+
36
+ Octokit.configure do |c|
37
+ c.login = `git config --get github.user`.strip
38
+ c.access_token = `git config --get github.token`.strip
39
+ end
40
+
41
+ t = Bundler::GemHelper.new
42
+
43
+ current_version = "v#{t.gemspec.version.to_s}"
44
+ previous_version = ""
45
+ `git tag`.split(/\n/).each do |tag|
46
+ break if tag == current_version
47
+ previous_version = tag
48
+ end
49
+
50
+ log = `git log #{previous_version}..#{current_version} --grep=Merge`
51
+
52
+ repo = `git remote -v | grep origin`.match(/([\w-]+\/[\w-]+)\.git/)[1]
53
+
54
+ description = []
55
+ log.split(/commit/).each do |lines|
56
+ lines.match(/Merge pull request \#(\d+)/) do |m|
57
+ url = "https://github.com/#{repo}/pull/#{m[1]}"
58
+ title = Octokit.pull_request(repo, m[1]).title
59
+ description << "* [#{title}](#{url})"
60
+ end
61
+ end
62
+
63
+ Octokit.create_release(
64
+ repo,
65
+ current_version,
66
+ {:body => description.join("\n")}
67
+ )
68
+ end
@@ -0,0 +1,51 @@
1
+ function IsRemotePortListening{
2
+ param(
3
+ [string]$hostname,
4
+ [string]$proto="tcp",
5
+ [int]$port,
6
+ [int]$timeout)
7
+
8
+
9
+ If ($proto -eq "tcp") {
10
+ $tcpobject = new-Object system.Net.Sockets.TcpClient
11
+ $connect = $tcpobject.BeginConnect($hostname,$port,$null,$null)
12
+ $wait = $connect.AsyncWaitHandle.WaitOne($timeout * 1000,$false)
13
+ #If timeout
14
+ If(!$wait) {
15
+ $tcpobject.Close()
16
+ return $false
17
+ }
18
+ else{
19
+ $result = $tcpobject.Connected
20
+ $tcpobject.Close()
21
+ return $result
22
+ }
23
+ }
24
+ elseif ($proto -eq "udp") {
25
+ $udpobject = new-Object system.Net.Sockets.Udpclient
26
+ $udpobject.client.ReceiveTimeout = $timeout * 1000
27
+ $udpobject.Connect($hostname,$port)
28
+ $a = new-object system.text.asciiencoding
29
+ $byte = $a.GetBytes("$(Get-Date)")
30
+ [void]$udpobject.Send($byte,$byte.length)
31
+ $remoteendpoint = New-Object system.net.ipendpoint([system.net.ipaddress]::Any,0)
32
+ try{
33
+ #Blocks until a message returns on this socket from a remote host.
34
+ $receivebytes = $udpobject.Receive([ref]$remoteendpoint)
35
+ [string]$returndata = $a.GetString($receivebytes)
36
+ If ($returndata) {
37
+ $udpobject.close()
38
+ return $true
39
+ }
40
+ else{
41
+ return $false
42
+ }
43
+ }
44
+ catch{
45
+ return $false
46
+ }
47
+ }
48
+ else{
49
+ throw "Protocol ${proto} not supported"
50
+ }
51
+ }
@@ -181,6 +181,28 @@ module SpecInfra
181
181
  Backend::PowerShell::Command.new { exec cmd }
182
182
  end
183
183
 
184
+ def check_resolvable(name, type)
185
+ if type == "hosts"
186
+ cmd = "@(Select-String -path (Join-Path -Path $($env:windir) -ChildPath 'system32/drivers/etc/hosts') -pattern '#{name}\\b').count -gt 0"
187
+ else
188
+ cmd = "@([System.Net.Dns]::GetHostAddresses('#{name}')).count -gt 0"
189
+ end
190
+ Backend::PowerShell::Command.new { exec cmd }
191
+ end
192
+
193
+ def check_reachable(host, port, proto, timeout)
194
+ if port.nil?
195
+ Backend::PowerShell::Command.new do
196
+ exec "(New-Object System.Net.NetworkInformation.Ping).send('#{host}').Status -eq 'Success'"
197
+ end
198
+ else
199
+ Backend::PowerShell::Command.new do
200
+ using 'is_remote_port_listening.ps1'
201
+ exec"(IsRemotePortListening -hostname #{host} -port #{port} -timeout #{timeout} -proto #{proto}) -eq $true"
202
+ end
203
+ end
204
+ end
205
+
184
206
  private
185
207
 
186
208
  def item_has_attribute item, attribute
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-30 00:00:00.000000000 Z
11
+ date: 2014-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -82,6 +82,7 @@ files:
82
82
  - lib/specinfra/backend/powershell/support/find_user.ps1
83
83
  - lib/specinfra/backend/powershell/support/find_usergroup.ps1
84
84
  - lib/specinfra/backend/powershell/support/is_port_listening.ps1
85
+ - lib/specinfra/backend/powershell/support/is_remote_port_listening.ps1
85
86
  - lib/specinfra/backend/shellscript.rb
86
87
  - lib/specinfra/backend/ssh.rb
87
88
  - lib/specinfra/backend/winrm.rb