vhd 0.0.2
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.
- checksums.yaml +15 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +40 -0
- data/README.md +27 -0
- data/lib/libvhd.so.0.1.1 +0 -0
- data/lib/vhd.rb +5 -0
- data/lib/vhd/library.rb +24 -0
- data/lib/vhd/version.rb +3 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/vhd_tests.rb +23 -0
- data/vhd-ruby.gemspec +20 -0
- metadata +70 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MWQ2NzlhZDJhOThjZTgyMDZkOTU5ODIzYzczNmQ4N2FlMTJkYjBhMg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MzRmMjJiODJhZTZkNzg5M2FjNWYzMDRiN2IwMWVhOTJiY2NhNjNjZg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ODhiZTdmYTg1MmM2NjQwMDU1YTRlYTUxZjBjY2U3MDIyMTU5NDFjNjkwMjM0
|
10
|
+
NmVlNzg2YTgwYzhiNTMzMjE5NGZmYzVjMDVmM2Y1YjA5MzhiYTFmZmFmYzhl
|
11
|
+
YTYxOWEyNmY3YWRjZmQ1NjQzOWNjMjJiMTA4ZDRhNzcxMjhmNmU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZDhlZWNmMTc0MWU3OGFmYjZhY2UzNTc2OTZmMGMyMDdjYTM3NDg0ZTk0ZDQ4
|
14
|
+
MWMwMDEwNjkwYjUxNzJhN2Q2YTViY2Q1MzZjMTVlMjRkMDQ5OWU4YjE4Y2Yw
|
15
|
+
ZjIzYTZiODdlMWFhZDFiNDA2MWM1ZmIyNTE3MWY2ZDE2NzY0ZmQ=
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
vhd-ruby (0.0.1)
|
5
|
+
ffi
|
6
|
+
|
7
|
+
GEM
|
8
|
+
specs:
|
9
|
+
awesome_print (1.1.0)
|
10
|
+
coderay (1.0.9)
|
11
|
+
diff-lcs (1.2.1)
|
12
|
+
ffaker (1.15.0)
|
13
|
+
ffi (1.9.3)
|
14
|
+
method_source (0.8.1)
|
15
|
+
pry (0.9.12)
|
16
|
+
coderay (~> 1.0.5)
|
17
|
+
method_source (~> 0.8)
|
18
|
+
slop (~> 3.4)
|
19
|
+
pry-nav (0.2.3)
|
20
|
+
pry (~> 0.9.10)
|
21
|
+
rspec (2.13.0)
|
22
|
+
rspec-core (~> 2.13.0)
|
23
|
+
rspec-expectations (~> 2.13.0)
|
24
|
+
rspec-mocks (~> 2.13.0)
|
25
|
+
rspec-core (2.13.1)
|
26
|
+
rspec-expectations (2.13.0)
|
27
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
28
|
+
rspec-mocks (2.13.0)
|
29
|
+
slop (3.4.4)
|
30
|
+
|
31
|
+
PLATFORMS
|
32
|
+
ruby
|
33
|
+
|
34
|
+
DEPENDENCIES
|
35
|
+
awesome_print
|
36
|
+
ffaker
|
37
|
+
pry
|
38
|
+
pry-nav
|
39
|
+
rspec
|
40
|
+
vhd-ruby!
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# vhd-ruby
|
2
|
+
|
3
|
+
## About
|
4
|
+
|
5
|
+
FFI extension that wraps libvhd in order to create and modify VHD images in Ruby
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
### Create a dynamic VHD
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
Vhd::Library.create_dynamic_disk('some_name.vhd', some_size_in_gb)
|
13
|
+
```
|
14
|
+
|
15
|
+
### Create a fixed VHD
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
Vhd::Library.create_fixed_disk('some_name.vhd', some_size_in_gb)
|
19
|
+
```
|
20
|
+
|
21
|
+
## Contributing
|
22
|
+
|
23
|
+
1. Fork it
|
24
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
25
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
26
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
27
|
+
5. Create new Pull Request
|
data/lib/libvhd.so.0.1.1
ADDED
Binary file
|
data/lib/vhd.rb
ADDED
data/lib/vhd/library.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Vhd::Library
|
2
|
+
extend FFI::Library
|
3
|
+
ffi_lib "libvhd.so.0.1.1"
|
4
|
+
attach_function :vhd_create, [ :string, :uint64, :int, :uint64, :uint ], :int
|
5
|
+
|
6
|
+
HD_TYPE_FIXED = 2
|
7
|
+
HD_TYPE_DYNAMIC = 3
|
8
|
+
|
9
|
+
def self.create_dynamic_disk(name, size_in_gb)
|
10
|
+
size_in_bytes = self.size_in_bytes(size_in_gb)
|
11
|
+
|
12
|
+
vhd_create(name, size_in_bytes, HD_TYPE_DYNAMIC, 0, 0)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.create_fixed_disk(name, size_in_gb)
|
16
|
+
size_in_bytes = self.size_in_bytes(size_in_gb)
|
17
|
+
|
18
|
+
vhd_create(name, size_in_bytes, HD_TYPE_FIXED, 0, 2)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.size_in_bytes(size_in_gb)
|
22
|
+
size_in_gb * 1024 * 1024 * 1024
|
23
|
+
end
|
24
|
+
end
|
data/lib/vhd/version.rb
ADDED
data/spec/spec_helper.rb
ADDED
data/spec/vhd_tests.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "vhds" do
|
4
|
+
before(:each) do
|
5
|
+
@file_name = "/tmp/#{Faker::Name.first_name}"
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:file_name) { @file_name }
|
9
|
+
|
10
|
+
it "should create a dynamic vhd" do
|
11
|
+
Vhd::Library.create_dynamic_disk(file_name, 0.1)
|
12
|
+
File.size(file_name).should == 3584
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should create a fixed vhd" do
|
16
|
+
Vhd::Library.create_fixed_disk(file_name, 0.1)
|
17
|
+
File.size(file_name).should == 109052416
|
18
|
+
end
|
19
|
+
|
20
|
+
after(:each) do
|
21
|
+
FileUtils.rm_f(@file_name)
|
22
|
+
end
|
23
|
+
end
|
data/vhd-ruby.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/vhd/version', __FILE__)
|
3
|
+
require File.expand_path('../lib/vhd.rb', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.authors = ["Eugene Howe"]
|
7
|
+
gem.email = ["eugene@xtreme-computers.net"]
|
8
|
+
gem.description = %q{}
|
9
|
+
gem.summary = %q{}
|
10
|
+
gem.homepage = ""
|
11
|
+
|
12
|
+
gem.files = `git ls-files`.split($\)
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.name = "vhd"
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
gem.version = Vhd::VERSION
|
18
|
+
|
19
|
+
gem.add_dependency "ffi"
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vhd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eugene Howe
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ffi
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: ''
|
28
|
+
email:
|
29
|
+
- eugene@xtreme-computers.net
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- Gemfile
|
35
|
+
- Gemfile.lock
|
36
|
+
- README.md
|
37
|
+
- lib/libvhd.so.0.1.1
|
38
|
+
- lib/vhd.rb
|
39
|
+
- lib/vhd/library.rb
|
40
|
+
- lib/vhd/version.rb
|
41
|
+
- spec/spec_helper.rb
|
42
|
+
- spec/vhd_tests.rb
|
43
|
+
- vhd-ruby.gemspec
|
44
|
+
homepage: ''
|
45
|
+
licenses: []
|
46
|
+
metadata: {}
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 2.0.7
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: ''
|
67
|
+
test_files:
|
68
|
+
- spec/spec_helper.rb
|
69
|
+
- spec/vhd_tests.rb
|
70
|
+
has_rdoc:
|