btrfs 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c37db01b11b48cb3dc8bfbdb1aff625fe459a305
4
+ data.tar.gz: 2165664deff02bb82192c5779f44f3ea4ac011df
5
+ SHA512:
6
+ metadata.gz: ab64c5a26d3281d16f1b97fcb769ae52aa185844247f810ef7982b228cad3b34452dc6ae7d1cc51f660f75b13f2a54f97bf54950c46f5f0184497d093ed5bc7f
7
+ data.tar.gz: '0718304a80abe80115e68d7fff0b94069048b0bc3775b07751155e3a2654e123245b205a55d2a650820e1ef40e648b3f33df51297964316ab9f5155731761673'
@@ -0,0 +1,54 @@
1
+
2
+ # Created by https://www.gitignore.io/api/ruby
3
+
4
+ ### Ruby ###
5
+ *.gem
6
+ *.rbc
7
+ /.config
8
+ /coverage/
9
+ /InstalledFiles
10
+ /pkg/
11
+ /spec/reports/
12
+ /spec/examples.txt
13
+ /test/tmp/
14
+ /test/version_tmp/
15
+ /tmp/
16
+
17
+ # Used by dotenv library to load environment variables.
18
+ # .env
19
+
20
+ ## Specific to RubyMotion:
21
+ .dat*
22
+ .repl_history
23
+ build/
24
+ *.bridgesupport
25
+ build-iPhoneOS/
26
+ build-iPhoneSimulator/
27
+
28
+ ## Specific to RubyMotion (use of CocoaPods):
29
+ #
30
+ # We recommend against adding the Pods directory to your .gitignore. However
31
+ # you should judge for yourself, the pros and cons are mentioned at:
32
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
33
+ #
34
+ # vendor/Pods/
35
+
36
+ ## Documentation cache and generated files:
37
+ /.yardoc/
38
+ /_yardoc/
39
+ /doc/
40
+ /rdoc/
41
+
42
+ ## Environment normalization:
43
+ /.bundle/
44
+ /vendor/bundle
45
+ /lib/bundler/man/
46
+
47
+ # for a library or gem, you might want to ignore these files since the code is
48
+ # intended to run in multiple environments; otherwise, check them in:
49
+ # Gemfile.lock
50
+ # .ruby-version
51
+ # .ruby-gemset
52
+
53
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
54
+ .rvmrc
@@ -0,0 +1,21 @@
1
+
2
+ The MIT License (MIT)
3
+ Copyright © 2016 Chris Olstrom <chris@olstrom.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the “Software”), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,37 @@
1
+ #+TITLE: btrfs.rb
2
+
3
+ * Overview
4
+
5
+ Wraps btrfs volumes in Ruby Objects.
6
+
7
+ * Why does this exist?
8
+
9
+ To simplify working with btrfs volumes in Ruby.
10
+
11
+ * Installation
12
+
13
+ #+BEGIN_SRC shell
14
+ gem install btrfs
15
+ #+END_SRC
16
+
17
+ * Usage
18
+
19
+ The following will delete all subvolumes on a btrfs volume:
20
+
21
+ #+BEGIN_SRC ruby
22
+ require 'btrfs'
23
+
24
+ volume = Btrfs::Volume.new '/path/to/volume'
25
+
26
+ volume.subvolumes.each do |subvolume|
27
+ subvolume.delete
28
+ end
29
+ #+END_SRC
30
+
31
+ * License
32
+
33
+ ~btrfs.rb~ is available under the [[https://tldrlegal.com/license/mit-license][MIT License]]. See ~LICENSE.txt~ for the full text.
34
+
35
+ * Contributors
36
+
37
+ - [[https://colstrom.github.io/][Chris Olstrom]] | [[mailto:chris@olstrom.com][e-mail]] | [[https://twitter.com/ChrisOlstrom][Twitter]]
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new do |gem|
2
+ gem.name = 'btrfs'
3
+ gem.version = `git describe --tags --abbrev=0`.chomp
4
+ gem.licenses = 'MIT'
5
+ gem.authors = ['Chris Olstrom']
6
+ gem.email = 'chris@olstrom.com'
7
+ gem.homepage = 'https://github.com/colstrom/btrfs.rb'
8
+ gem.summary = 'Ruby Objects for btrfs concepts'
9
+
10
+ gem.files = `git ls-files`.split("\n")
11
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
12
+ gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
13
+ gem.require_paths = ['lib']
14
+ end
@@ -0,0 +1 @@
1
+ require_relative 'btrfs/volume'
@@ -0,0 +1,48 @@
1
+ module Btrfs
2
+ class Subvolume
3
+ attr_reader :root, :record
4
+
5
+ def initialize(root, record)
6
+ @root = root.squeeze('/').chomp('/')
7
+ @record = record.squeeze(' ').split
8
+ self
9
+ end
10
+
11
+ def id
12
+ @id ||= record.first
13
+ end
14
+
15
+ def generation
16
+ @generation ||= record.slice(1)
17
+ end
18
+
19
+ alias_method :gen, :generation
20
+
21
+ def top_level
22
+ @top_level ||= record.slice(2)
23
+ end
24
+
25
+ def path
26
+ @path ||= [root, record.last].join('/')
27
+ end
28
+
29
+ def deleted?
30
+ @deleted == true
31
+ end
32
+
33
+ def delete
34
+ return true if deleted?
35
+
36
+ @deleted = system("btrfs subvolume delete #{path}")
37
+ end
38
+
39
+ def to_h
40
+ {
41
+ id: id,
42
+ generation: generation,
43
+ top_level: top_level,
44
+ path: path
45
+ }
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,18 @@
1
+ require_relative 'subvolume'
2
+
3
+ module Btrfs
4
+ class Volume
5
+ attr_reader :path
6
+
7
+ def initialize(path)
8
+ @path = path
9
+ self
10
+ end
11
+
12
+ def subvolumes
13
+ `btrfs subvolume list -t #{path}`.lines.drop(2).map do |subvolume|
14
+ Subvolume.new path, line
15
+ end
16
+ end
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: btrfs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
+ platform: ruby
6
+ authors:
7
+ - Chris Olstrom
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-13 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: chris@olstrom.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".gitignore"
20
+ - LICENSE.txt
21
+ - README.org
22
+ - btrfs.gemspec
23
+ - lib/btrfs.rb
24
+ - lib/btrfs/subvolume.rb
25
+ - lib/btrfs/volume.rb
26
+ homepage: https://github.com/colstrom/btrfs.rb
27
+ licenses:
28
+ - MIT
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 2.5.1
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: Ruby Objects for btrfs concepts
50
+ test_files: []