cleanup_recordings 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c843cdbdabb3b0bea4ac6dad0953782e676f4ab8
4
+ data.tar.gz: a3c5225e999cda41465b38ad78b74fd71a7505cf
5
+ SHA512:
6
+ metadata.gz: b50e089b302990da09e61db3093c556339ad1ee234f54aeb87df2c90c937abdf23cff20a56c800020f150479f10ac98edf3ffaf3ad275d95c31fe6dbc6136c7e
7
+ data.tar.gz: 3d26ec0ce6dbb6b56abb825e6fd7d8bb0968c6c373b52538780d2a6c789096d857821736cf7d37b2c4ffa433e9116334976e3d979ae1caf41f46b41dad1b2c9a
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ .DS_Store
2
+ results.html
3
+ pkg
4
+ html
5
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cleanup_recordings.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cleanup_recordings (0.1.0)
5
+ methadone (~> 1.9.2)
6
+ sys-filesystem (~> 1.1.6)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ aruba (0.14.2)
12
+ childprocess (~> 0.5.6)
13
+ contracts (~> 0.9)
14
+ cucumber (>= 1.3.19)
15
+ ffi (~> 1.9.10)
16
+ rspec-expectations (>= 2.99)
17
+ thor (~> 0.19)
18
+ builder (3.2.3)
19
+ childprocess (0.5.9)
20
+ ffi (~> 1.0, >= 1.0.11)
21
+ contracts (0.15.0)
22
+ cucumber (2.4.0)
23
+ builder (>= 2.1.2)
24
+ cucumber-core (~> 1.5.0)
25
+ cucumber-wire (~> 0.0.1)
26
+ diff-lcs (>= 1.1.3)
27
+ gherkin (~> 4.0)
28
+ multi_json (>= 1.7.5, < 2.0)
29
+ multi_test (>= 0.1.2)
30
+ cucumber-core (1.5.0)
31
+ gherkin (~> 4.0)
32
+ cucumber-wire (0.0.1)
33
+ diff-lcs (1.3)
34
+ ffi (1.9.18)
35
+ gherkin (4.1.1)
36
+ methadone (1.9.5)
37
+ bundler
38
+ multi_json (1.12.1)
39
+ multi_test (0.1.2)
40
+ power_assert (1.0.1)
41
+ rake (12.0.0)
42
+ rdoc (5.1.0)
43
+ rspec-expectations (3.5.0)
44
+ diff-lcs (>= 1.2.0, < 2.0)
45
+ rspec-support (~> 3.5.0)
46
+ rspec-support (3.5.0)
47
+ sys-filesystem (1.1.7)
48
+ ffi
49
+ test-unit (3.2.3)
50
+ power_assert
51
+ thor (0.19.4)
52
+
53
+ PLATFORMS
54
+ ruby
55
+
56
+ DEPENDENCIES
57
+ aruba
58
+ bundler (~> 1.12)
59
+ cleanup_recordings!
60
+ rake
61
+ rdoc
62
+ test-unit
63
+
64
+ BUNDLED WITH
65
+ 1.12.5
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # CleanupRecordings
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cleanup_recordings`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'cleanup_recordings'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install cleanup_recordings
22
+
23
+ ## Usage
24
+
25
+
26
+ Use -s<GB> to set the space you want to reserve.
27
+ EG: cleaning up to 20GB left.
28
+ : cleanup_recordings -s20
29
+
30
+
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
+
35
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
36
+
37
+ ## Contributing
38
+
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cleanup_recordings.
40
+
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = cleanup_recordings - DESCRIBE YOUR GEM
2
+
3
+ Author:: YOUR NAME (YOUR EMAIL)
4
+ Copyright:: Copyright (c) 2017 YOUR NAME
5
+
6
+
7
+ DESCRIBE YOUR GEM HERE
8
+
9
+ == Links
10
+
11
+ * {Source on Github}[LINK TO GITHUB]
12
+ * RDoc[LINK TO RDOC.INFO]
13
+
14
+ == Install
15
+
16
+ == Examples
17
+
18
+ == Contributing
19
+
data/Rakefile ADDED
@@ -0,0 +1,61 @@
1
+ def dump_load_path
2
+ puts $LOAD_PATH.join("\n")
3
+ found = nil
4
+ $LOAD_PATH.each do |path|
5
+ if File.exists?(File.join(path,"rspec"))
6
+ puts "Found rspec in #{path}"
7
+ if File.exists?(File.join(path,"rspec","core"))
8
+ puts "Found core"
9
+ if File.exists?(File.join(path,"rspec","core","rake_task"))
10
+ puts "Found rake_task"
11
+ found = path
12
+ else
13
+ puts "!! no rake_task"
14
+ end
15
+ else
16
+ puts "!!! no core"
17
+ end
18
+ end
19
+ end
20
+ if found.nil?
21
+ puts "Didn't find rspec/core/rake_task anywhere"
22
+ else
23
+ puts "Found in #{path}"
24
+ end
25
+ end
26
+ require 'bundler'
27
+ require 'rake/clean'
28
+
29
+ require 'rake/testtask'
30
+
31
+ require 'cucumber'
32
+ require 'cucumber/rake/task'
33
+ gem 'rdoc' # we need the installed RDoc gem, not the system one
34
+ require 'rdoc/task'
35
+
36
+ include Rake::DSL
37
+
38
+ Bundler::GemHelper.install_tasks
39
+
40
+
41
+ Rake::TestTask.new do |t|
42
+ t.pattern = 'test/tc_*.rb'
43
+ end
44
+
45
+
46
+ CUKE_RESULTS = 'results.html'
47
+ CLEAN << CUKE_RESULTS
48
+ Cucumber::Rake::Task.new(:features) do |t|
49
+ t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
50
+ t.fork = false
51
+ end
52
+
53
+ Rake::RDocTask.new do |rd|
54
+
55
+ rd.main = "README.rdoc"
56
+
57
+ rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
58
+ end
59
+
60
+ task :default => [:test,:features]
61
+
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'fileutils'
4
+ require 'sys/filesystem'
5
+ require 'optparse'
6
+ require 'methadone'
7
+ require 'cleanup_recordings.rb'
8
+
9
+ class App
10
+ include Methadone::Main
11
+ include Methadone::CLILogging
12
+
13
+ main do # Add args you want: |like,so|
14
+ # your program code here
15
+ # You can access CLI options via
16
+ # the options Hash
17
+
18
+ part = options[:partition] || "/home"
19
+ puts "Checking #{part}..."
20
+
21
+ # Get the available space in GB for /home partition
22
+ stat = Sys::Filesystem.stat(part)
23
+ md_available = stat.block_size * stat.blocks_available / 1024 / 1024 / 1024
24
+ space = (options[:space] || 10).to_i
25
+
26
+ puts "\tAvailable: #{md_available}"
27
+ puts "\tReserve: #{space}"
28
+ puts "\tThere is not enough space, let's cleanup" if md_available < space
29
+
30
+ files = Dir.glob('/home/hts/*ts').sort_by{|f| File.mtime(f)}.reverse
31
+
32
+ # Check that available space is at least space otherwise remove files.
33
+ while md_available < space
34
+ break if files.empty?
35
+
36
+ # Remove file
37
+ file = files.pop
38
+ puts "Remove #{file}"
39
+ FileUtils.rm(file)
40
+
41
+ # Recalculate and print available space.
42
+ stat = Sys::Filesystem.stat(part)
43
+ md_available = stat.block_size * stat.blocks_available / 1024 / 1024 / 1024
44
+ puts "A: #{md_available} S: #{space}"
45
+ sleep 0.5
46
+ end
47
+
48
+ if md_available >= space
49
+ puts "\n\nRecordings have been cleaned up"
50
+ end
51
+
52
+ puts "Available now: #{md_available}"
53
+ end
54
+
55
+ # supplemental methods here
56
+
57
+ # Declare command-line interface here
58
+
59
+ # description "one line description of your app"
60
+ #
61
+ # Accept flags via:
62
+ # on("--flag VAL","Some flag")
63
+ # options[flag] will contain VAL
64
+ on("-s", "--space SPACE", "Space to reserve in GB")
65
+ on("-p", "--partition PARTITION", "Partition to check (default: /home)")
66
+ #
67
+ # Specify switches via:
68
+ # on("--[no-]switch","Some switch")
69
+ #
70
+ # Or, just call OptionParser methods on opts
71
+ #
72
+ # Require an argument
73
+ # arg :some_arg
74
+ #
75
+ # # Make an argument optional
76
+ # arg :optional_arg, :optional
77
+
78
+ version CleanupRecordings::VERSION
79
+
80
+ use_log_level_option :toggle_debug_on_signal => 'USR1'
81
+
82
+ go!
83
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cleanup_recordings"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/make_temp ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Make some temp files
4
+
5
+ fallocate -l 10G /home/hts/1.ts
6
+ fallocate -l 10G /home/hts/2.ts
7
+ fallocate -l 10G /home/hts/3.ts
8
+ fallocate -l 10G /home/hts/4.ts
9
+
10
+ ls -altrh /home/hts
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+
4
+
5
+ # Calculate
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cleanup_recordings/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cleanup_recordings"
8
+ spec.license=""
9
+ spec.version = CleanupRecordings::VERSION
10
+ spec.authors = ["Michael Pope"]
11
+ spec.email = ["michael@dtcorp.com.au"]
12
+
13
+ spec.summary = %q{Cleanup a directory till we have a set amount of space}
14
+ spec.description = %q{Given an amount of space you want free this will remove recordings until we hit that value.}
15
+ spec.homepage = "https://github.com/map7/cleanup_recordings"
16
+
17
+ # # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.12"
31
+ # spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency('rdoc')
33
+ spec.add_development_dependency('aruba')
34
+ spec.add_development_dependency('rake')
35
+ spec.add_development_dependency('test-unit')
36
+
37
+ spec.add_dependency('methadone', '~> 1.9.2')
38
+ spec.add_dependency('sys-filesystem', '~> 1.1.6')
39
+ end
@@ -0,0 +1,3 @@
1
+ module CleanupRecordings
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "cleanup_recordings/version"
2
+
3
+ module CleanupRecordings
4
+ # Your code goes here...
5
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cleanup_recordings
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Pope
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-03-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: aruba
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: test-unit
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: methadone
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.9.2
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.9.2
97
+ - !ruby/object:Gem::Dependency
98
+ name: sys-filesystem
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.1.6
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.1.6
111
+ description: Given an amount of space you want free this will remove recordings until
112
+ we hit that value.
113
+ email:
114
+ - michael@dtcorp.com.au
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - Gemfile
121
+ - Gemfile.lock
122
+ - README.md
123
+ - README.rdoc
124
+ - Rakefile
125
+ - bin/cleanup_recordings
126
+ - bin/console
127
+ - bin/make_temp
128
+ - bin/setup
129
+ - cleanup_recordings
130
+ - cleanup_recordings.gemspec
131
+ - lib/cleanup_recordings.rb
132
+ - lib/cleanup_recordings/version.rb
133
+ homepage: https://github.com/map7/cleanup_recordings
134
+ licenses:
135
+ - ''
136
+ metadata: {}
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.4.5.1
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: Cleanup a directory till we have a set amount of space
157
+ test_files: []