but 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 853bfa5259d6c243f2728c71d7dd1575914cb38a29c1b40dcf39b78833fd670f
4
+ data.tar.gz: b4d65cf498abbc277d1ec5280d6de2542a48810ac20f58f36c449dbf3410f493
5
+ SHA512:
6
+ metadata.gz: b90007c89eaa18486ebae63374caa47c3b32526fc58ac90b48542e0aa0cb67253caaf2336d56331218f84a7e319a023738718c1dc16a61c85ddef6937f93e68b
7
+ data.tar.gz: 74ea9639c7aaaaf9bf06db499e3031d97b3e48ccf332d9aa699ea18e93b7ad257a5065bf451018dce7672a02e045e75e5d50c488e776ff87b3fe73456e7536ca
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .*.swp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1 @@
1
+ 2.6.1
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.1
7
+ before_install: gem install bundler -v 1.17.2
File without changes
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at raphael.mueller@computational.bio.uni-giessen.de. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in but.gemspec
6
+ gemspec
@@ -0,0 +1,160 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ but (0.1.2)
5
+ colorize
6
+ thor
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (6.0.3.1)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 0.7, < 2)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ zeitwerk (~> 2.2, >= 2.2.2)
17
+ aruba (1.0.1)
18
+ childprocess (~> 3.0)
19
+ contracts (~> 0.16.0)
20
+ cucumber (>= 2.4, < 5.0)
21
+ ffi (~> 1.9)
22
+ rspec-expectations (~> 3.4)
23
+ thor (~> 1.0)
24
+ ast (2.4.0)
25
+ builder (3.2.4)
26
+ childprocess (3.0.0)
27
+ coderay (1.1.3)
28
+ colorize (0.8.1)
29
+ concurrent-ruby (1.1.6)
30
+ contracts (0.16.0)
31
+ cucumber (4.0.0)
32
+ builder (~> 3.2, >= 3.2.3)
33
+ cucumber-core (~> 7.0, >= 7.0.0)
34
+ cucumber-cucumber-expressions (~> 10.1, >= 10.1.0)
35
+ cucumber-gherkin (~> 13.0, >= 13.0.0)
36
+ cucumber-html-formatter (~> 6.0, >= 6.0.1)
37
+ cucumber-messages (~> 12.1, >= 12.1.1)
38
+ cucumber-wire (~> 3.0, >= 3.0.0)
39
+ diff-lcs (~> 1.3, >= 1.3)
40
+ multi_test (~> 0.1, >= 0.1.2)
41
+ sys-uname (~> 1.0, >= 1.0.2)
42
+ cucumber-core (7.0.0)
43
+ cucumber-gherkin (~> 13.0, >= 13.0.0)
44
+ cucumber-messages (~> 12.1, >= 12.1.1)
45
+ cucumber-tag-expressions (~> 2.0, >= 2.0.4)
46
+ cucumber-cucumber-expressions (10.2.0)
47
+ cucumber-gherkin (13.0.0)
48
+ cucumber-messages (~> 12.0, >= 12.0.0)
49
+ cucumber-html-formatter (6.0.2)
50
+ cucumber-messages (~> 12.1, >= 12.1.1)
51
+ cucumber-messages (12.1.1)
52
+ protobuf-cucumber (~> 3.10, >= 3.10.8)
53
+ cucumber-tag-expressions (2.0.4)
54
+ cucumber-wire (3.0.0)
55
+ cucumber-core (~> 7.0, >= 7.0.0)
56
+ cucumber-cucumber-expressions (~> 10.1, >= 10.1.0)
57
+ cucumber-messages (~> 12.1, >= 12.1.1)
58
+ diff-lcs (1.3)
59
+ ffi (1.13.0)
60
+ formatador (0.2.5)
61
+ guard (2.16.2)
62
+ formatador (>= 0.2.4)
63
+ listen (>= 2.7, < 4.0)
64
+ lumberjack (>= 1.0.12, < 2.0)
65
+ nenv (~> 0.1)
66
+ notiffany (~> 0.0)
67
+ pry (>= 0.9.12)
68
+ shellany (~> 0.0)
69
+ thor (>= 0.18.1)
70
+ guard-compat (1.2.1)
71
+ guard-cucumber (3.0.0)
72
+ cucumber (>= 3.1)
73
+ nenv (>= 0.1)
74
+ guard-rspec (4.7.3)
75
+ guard (~> 2.1)
76
+ guard-compat (~> 1.1)
77
+ rspec (>= 2.99.0, < 4.0)
78
+ i18n (1.8.3)
79
+ concurrent-ruby (~> 1.0)
80
+ listen (3.2.1)
81
+ rb-fsevent (~> 0.10, >= 0.10.3)
82
+ rb-inotify (~> 0.9, >= 0.9.10)
83
+ lumberjack (1.2.5)
84
+ method_source (1.0.0)
85
+ middleware (0.1.0)
86
+ minitest (5.14.1)
87
+ multi_test (0.1.2)
88
+ nenv (0.3.0)
89
+ notiffany (0.1.3)
90
+ nenv (~> 0.1)
91
+ shellany (~> 0.0)
92
+ parallel (1.19.1)
93
+ parser (2.7.1.3)
94
+ ast (~> 2.4.0)
95
+ protobuf-cucumber (3.10.8)
96
+ activesupport (>= 3.2)
97
+ middleware
98
+ thor
99
+ thread_safe
100
+ pry (0.13.1)
101
+ coderay (~> 1.1)
102
+ method_source (~> 1.0)
103
+ rainbow (3.0.0)
104
+ rake (10.5.0)
105
+ rb-fsevent (0.10.4)
106
+ rb-inotify (0.10.1)
107
+ ffi (~> 1.0)
108
+ rexml (3.2.4)
109
+ rspec (3.9.0)
110
+ rspec-core (~> 3.9.0)
111
+ rspec-expectations (~> 3.9.0)
112
+ rspec-mocks (~> 3.9.0)
113
+ rspec-core (3.9.2)
114
+ rspec-support (~> 3.9.3)
115
+ rspec-expectations (3.9.2)
116
+ diff-lcs (>= 1.2.0, < 2.0)
117
+ rspec-support (~> 3.9.0)
118
+ rspec-mocks (3.9.1)
119
+ diff-lcs (>= 1.2.0, < 2.0)
120
+ rspec-support (~> 3.9.0)
121
+ rspec-support (3.9.3)
122
+ rubocop (0.84.0)
123
+ parallel (~> 1.10)
124
+ parser (>= 2.7.0.1)
125
+ rainbow (>= 2.2.2, < 4.0)
126
+ rexml
127
+ rubocop-ast (>= 0.0.3)
128
+ ruby-progressbar (~> 1.7)
129
+ unicode-display_width (>= 1.4.0, < 2.0)
130
+ rubocop-ast (0.0.3)
131
+ parser (>= 2.7.0.1)
132
+ ruby-progressbar (1.10.1)
133
+ shellany (0.0.1)
134
+ sys-uname (1.2.1)
135
+ ffi (>= 1.0.0)
136
+ thor (1.0.1)
137
+ thread_safe (0.3.6)
138
+ tzinfo (1.2.7)
139
+ thread_safe (~> 0.1)
140
+ unicode-display_width (1.7.0)
141
+ zeitwerk (2.3.0)
142
+
143
+ PLATFORMS
144
+ ruby
145
+
146
+ DEPENDENCIES
147
+ aruba (>= 1.0.1)
148
+ bundler (~> 1.17)
149
+ but!
150
+ cucumber (>= 4.0.0)
151
+ guard (>= 2.16.2)
152
+ guard-compat (>= 1.2.1)
153
+ guard-cucumber (>= 3.0.0)
154
+ guard-rspec (>= 4.7.3)
155
+ rake (~> 10.0)
156
+ rspec (>= 3.9.0)
157
+ rubocop (~> 0.84.0)
158
+
159
+ BUNDLED WITH
160
+ 1.17.2
@@ -0,0 +1,74 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ cucumber_options = {
19
+ # Below are examples overriding defaults
20
+
21
+ cmd: 'bundle exec cucumber',
22
+ # cmd_additional_args: '--profile guard',
23
+
24
+ # all_after_pass: false,
25
+ # all_on_start: false,
26
+ # keep_failed: false,
27
+ # feature_sets: ['features/frontend', 'features/experimental'],
28
+
29
+ # run_all: { cmd_additional_args: '--profile guard_all' },
30
+ # focus_on: { 'wip' }, # @wip
31
+ notification: false
32
+ }
33
+
34
+ guard "cucumber", cucumber_options do
35
+ watch(%r{^features/.+\.feature$})
36
+ watch(%r{^features/support/.+$}) { "features" }
37
+
38
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) do |m|
39
+ Dir[File.join("**/#{m[1]}.feature")][0] || "features"
40
+ end
41
+
42
+ watch("lib/but/cli.rb") do |m|
43
+ "features"
44
+ end
45
+ end
46
+
47
+ # Note: The cmd option is now required due to the increasing number of ways
48
+ # rspec may be run, below are examples of the most common uses.
49
+ # * bundler: 'bundle exec rspec'
50
+ # * bundler binstubs: 'bin/rspec'
51
+ # * spring: 'bin/rspec' (This will use spring if running and you have
52
+ # installed the spring binstubs per the docs)
53
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
54
+ # * 'just' rspec: 'rspec'
55
+
56
+ guard :rspec, cmd: "bundle exec rspec" do
57
+ require "guard/rspec/dsl"
58
+ dsl = Guard::RSpec::Dsl.new(self)
59
+
60
+ # Feel free to open issues for suggestions and improvements
61
+
62
+ # RSpec files
63
+ rspec = dsl.rspec
64
+ watch(rspec.spec_helper) { rspec.spec_dir }
65
+ watch(rspec.spec_support) { rspec.spec_dir }
66
+ watch(rspec.spec_files)
67
+
68
+ watch(%r{^lib/but/(.+)\.rb$}){|m| "spec/#{m[1]}_spec.rb"}
69
+
70
+ # Ruby files
71
+ ruby = dsl.ruby
72
+ dsl.watch_spec_files_for(ruby.lib_files)
73
+
74
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Raphael Müller
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,109 @@
1
+ # **B**CF **U**ser **T**ools
2
+
3
+ Tools, to help users to improve their experience with the BCF infrastructure.
4
+
5
+ ## Motivation
6
+
7
+ BCF admins have a hard live. Their user's don't keep their `$HOMES` and other working places clean. It appears that some users don't know that they use too much space in their home or don't clean used directories on cluster (or other) machines. This tools helps users find unused and unwanted directories, which could make BCF admins happier.
8
+
9
+ ## Build status
10
+
11
+ Build status of continous integration
12
+
13
+ TODO: insert batches
14
+
15
+ ## Installation
16
+
17
+ use bundler to install this gem
18
+
19
+ ```
20
+ $ ./bin/setup
21
+ ```
22
+
23
+ or
24
+
25
+ ```
26
+ $ bundle install
27
+ ```
28
+
29
+ ## Tests
30
+
31
+ We use cucumber and rspec for testing purposes, so run:
32
+
33
+ ```
34
+ bundle exec cucumber features/
35
+ ```
36
+
37
+ and
38
+
39
+ ```
40
+ bundle exec rspec spec/
41
+ ```
42
+
43
+ Additionally, we provided a guard file for local continous testing
44
+
45
+ ```
46
+ bundle exec guard
47
+ ```
48
+
49
+
50
+ ## Usage
51
+
52
+ The BCF User Tool (but) uses plain english for its commands
53
+
54
+ ### If you ask yourself if you messed up your home
55
+
56
+ * Admin: People are messy with their homes
57
+ * You:
58
+
59
+ ```
60
+ $ but how messy am I?
61
+ ```
62
+
63
+ ### If you ask yourself if you messed up directories somewhere in the system
64
+
65
+ * Admin: people don't clean up working directories on `/var/scratch`
66
+ * You
67
+
68
+ ```
69
+ $ but I cleaned /var/scratch
70
+ ```
71
+
72
+ ## How to contribute?
73
+
74
+ Not sure right now. Just ask the project's owner
75
+
76
+ ## Evil scripts
77
+ ### home dump
78
+
79
+ Script for checking $HOME usage
80
+
81
+ ### check_var_scratch.sh
82
+
83
+ Script for checking `/var/scratch/`
84
+
85
+ #### FAQ
86
+
87
+ **Q:** Ich muss ständig mein Passwort eingeben.
88
+ **A:** Dann musst du nochmal dein SSH Schlüssel hochladen.
89
+
90
+ ## Things to Add
91
+
92
+ ### Development
93
+
94
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
95
+
96
+ 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).
97
+
98
+ ### Contributing
99
+
100
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/but. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
101
+
102
+ ### License
103
+
104
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
105
+
106
+ ### Code of Conduct
107
+
108
+ Everyone interacting in the But project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/but/blob/master/CODE_OF_CONDUCT.md).
109
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,56 @@
1
+ #!/bin/bash
2
+
3
+ ###
4
+ #
5
+ # Script for finding orphan folders, which no-one needs anymore
6
+ #
7
+ # usage:
8
+ #
9
+ # ./check_var_scratch.sh [user/group]
10
+ #
11
+ # if $1 not set, it looks for dirs of $USER
12
+ #
13
+ ###
14
+
15
+
16
+ set -o errexit
17
+ set -o verbose
18
+
19
+ ###
20
+ # setting var for whom or which group we're looking for
21
+ ###
22
+ if [ -z "$1" ]; then
23
+ WHO=$USER
24
+ else
25
+ WHO=$1
26
+ fi
27
+
28
+ ### generate tmp file for /var/scratch dirs
29
+ ### iit is not reachable atm
30
+ qhost | grep -v iit.internal | awk '/internal/{print $1}' | while read host; do echo $host; ssh -n $host "ls -lah /var/scratch"; done > /tmp/tst.txt
31
+
32
+ ### convert to list of shame
33
+ awk '/\.internal/{host=$1;next} NF<=2{print host,$0} NF>2{print $0,host}' /tmp/tst.txt > /tmp/listOfShame.txt
34
+
35
+ ### number of dirs per user
36
+ echo User Shame
37
+ awk 'NF>3{print $3}' /tmp/listOfShame.txt | sort | uniq -c
38
+ ### number of dirs per group
39
+ echo Group Shame
40
+ awk 'NF>3{print $4}' /tmp/listOfShame.txt | sort | uniq -c
41
+
42
+ ### awk thing for listing every dir of $WHO ($1 or $USER)
43
+ grep "$WHO" /tmp/listOfShame.txt | \
44
+ awk '
45
+ {
46
+ print $NF;
47
+ system("ssh -n "$NF" \"ls -lah /var/scratch/"$(NF-1)"\"");
48
+ printf "delete? (y/N) "; getline answer < "/dev/tty";
49
+ if(answer ~/^(y|Y)(es)?$/){
50
+ system("ssh -n "$NF" \"rm -rf /var/scratch/"$(NF-1)"\"");
51
+ print "deleted"
52
+ } else {
53
+ print "continue without deleting"
54
+ }
55
+ }'
56
+
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+
3
+ for i in `find $HOME -maxdepth 1 -type d`; do
4
+ du -hd 1 $i;
5
+ echo ">>>---$i---<<<";
6
+ done > $HOME/.diskusage.txt.tmp;
7
+
8
+ du -hd 0 $HOME >> $HOME/.diskusage.txt.tmp
9
+
10
+ mv $HOME/.diskusage.txt.tmp $HOME/.diskusage.txt
File without changes
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "but"
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(__FILE__)
@@ -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,56 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "but/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "but"
7
+ spec.version = But::VERSION
8
+ spec.authors = ["Raphael Müller"]
9
+ spec.email = ["raphael.mueller@computational.bio.uni-giessen.de"]
10
+ spec.homepage = 'https://git.computational.bio.uni-giessen.de/rmueller/bcf_user_tools'
11
+ spec.license = "MIT"
12
+ spec.summary = "Tools, to help users to improve their experience with the BCF infrastructure."
13
+ spec.description = "BCF admins have a hard live. Their user's don't keep their $HOMES and other working places clean. It appears that some users don't know that they use too much space in their home or don't clean used directories on cluster (or other) machines. This tools helps users find unused and unwanted directories, which could make BCF admins happier."
14
+
15
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
16
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
+
20
+ spec.metadata["homepage_uri"] = spec.homepage
21
+ spec.metadata["source_code_uri"] = "https://git.computational.bio.uni-giessen.de/rmueller/bcf_user_tools"
22
+ spec.metadata["changelog_uri"] = "https://git.computational.bio.uni-giessen.de/rmueller/bcf_user_tools/-/blob/master/CHANGELOG"
23
+ else
24
+ raise "RubyGems 2.0 or newer is required to protect against " \
25
+ "public gem pushes."
26
+ end
27
+
28
+ # Specify which files should be added to the gem when it is released.
29
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
30
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
31
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
+ end
33
+ spec.bindir = "exe"
34
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
+ spec.require_paths = ["lib"]
36
+
37
+ spec.add_development_dependency "bundler", "~> 1.17"
38
+ spec.add_development_dependency "rake", "~> 10.0"
39
+ spec.add_development_dependency 'rspec', '>=3.9.0'
40
+ spec.add_development_dependency 'cucumber', '>=4.0.0'
41
+ spec.add_development_dependency 'aruba', '>=1.0.1'
42
+ spec.add_development_dependency 'rubocop', '~> 0.84.0'
43
+ spec.add_development_dependency 'guard', '>= 2.16.2'
44
+ spec.add_development_dependency 'guard-compat', '>= 1.2.1'
45
+ spec.add_development_dependency 'guard-rspec', '>= 4.7.3'
46
+ spec.add_development_dependency 'guard-cucumber', '>= 3.0.0'
47
+
48
+
49
+ spec.add_dependency 'thor'
50
+ spec.add_dependency 'colorize'
51
+
52
+
53
+ spec.metadata = { "source_code_uri" => "https://git.computational.bio.uni-giessen.de/rmueller/bcf_user_tools" }
54
+
55
+
56
+ end
data/exe/but ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'but/cli'
4
+ But::CLI.start
File without changes
@@ -0,0 +1,10 @@
1
+ require "but/version"
2
+ require "but/home_keeper"
3
+ require "but/constants"
4
+ require 'but/dev_wrapper'
5
+
6
+ module But
7
+ class Error < StandardError; end
8
+ # Your code goes here...
9
+ #
10
+ end
@@ -0,0 +1,44 @@
1
+ require 'thor'
2
+ require 'but'
3
+
4
+ module But
5
+
6
+ class SubCommandBase < Thor
7
+ def self.banner(command, namespace = nil, subcommand = false)
8
+ "#{basename} #{subcommand_prefix} #{command.usage}"
9
+ end
10
+
11
+ def self.subcommand_prefix
12
+ self.name.gsub(%r{.*::}, '').gsub(%r{^[A-Z]}) { |match| match[0].downcase }.gsub(%r{[A-Z]}) { |match| "-#{match[0].downcase}" }
13
+ end
14
+ end
15
+
16
+
17
+ class How < Thor
18
+ class_option :measure, :type => :boolean, :default => false
19
+ class_option :gc, :type => :boolean, :default => true
20
+
21
+ desc "messy am I?", "How messed up is your home?"
22
+ def messy(*words)
23
+ if options[:measure]
24
+ measure(options) do
25
+ say But::HomeKeeper.judge
26
+ end
27
+ else
28
+ say But::HomeKeeper.judge
29
+ end
30
+ end
31
+ end
32
+
33
+ class CLI < Thor
34
+
35
+ desc "how", "asks something"
36
+ subcommand "how", How
37
+ #def how_messy_am_I?(*words)
38
+ # if words.any? {|w| w =~ /mess/}
39
+ # puts But::HomeKeeper.judge
40
+ # end
41
+ #end
42
+ end
43
+
44
+ end
@@ -0,0 +1,3 @@
1
+ module But
2
+ HOMELIMIT = 70 * 1024 * 1024
3
+ end
@@ -0,0 +1,33 @@
1
+ require "json"
2
+ require "benchmark"
3
+
4
+ #inspired by Ruby Performance Optimization: Alexander Dymo
5
+ def measure(options={}, &block)
6
+ gc = options[:gc]
7
+ if gc
8
+ GC.start
9
+ else
10
+ GC.disable
11
+ end
12
+
13
+ memory_before = `ps -o rss= -p #{Process.pid}`.to_i/1024
14
+ gc_stat_before = GC.stat
15
+ time = Benchmark.realtime do
16
+ yield
17
+ end
18
+ #puts ObjectSpace.count_objects
19
+ if gc
20
+ GC.start(full_mark: true, immediate_sweep: true, immediate_mark: false)
21
+ end
22
+ #puts ObjectSpace.count_objects
23
+ gc_stat_after = GC.stat
24
+ memory_after = `ps -o rss= -p #{Process.pid}`.to_i/1024
25
+ puts({
26
+ RUBY_VERSION => {
27
+ gc: gc ? 'enabled' : 'disabled',
28
+ time: time.round(3),
29
+ gc_count: gc_stat_after[:count] - gc_stat_before[:count],
30
+ memory: "%d MB" % (memory_after - memory_before)
31
+ }
32
+ }.to_json)
33
+ end
@@ -0,0 +1,42 @@
1
+ require 'open3'
2
+ require 'tempfile'
3
+ require 'colorize'
4
+
5
+ module But
6
+ module HomeKeeper
7
+
8
+ def self.info(options = {})
9
+ file = ENV['BUTHOMEKEEPER'] || create_disk_usage_file(options)
10
+ file_info = File.open(file).readlines.map(&:chomp)
11
+ end
12
+
13
+ def self.judge(options = {})
14
+ total_disc_usage, dir = info(options).last.split(/\s+/)
15
+ total_disc_usage = total_disc_usage.to_i
16
+
17
+ if total_disc_usage >= But::HOMELIMIT
18
+ return "Dare you! Your directory #{dir} contains #{total_disc_usage}, which is #{total_disc_usage - But::HOMELIMIT} above the limit of #{But::HOMELIMIT}. Dare you!".red
19
+ else
20
+ return "Good job! Your directory #{dir} takes only #{total_disc_usage} disk storage. Good job!".light_green
21
+ end
22
+ end
23
+
24
+
25
+ # Q: is $HOME always set?
26
+ def self.create_disk_usage_file(options = {})
27
+ tmpfile = ::Tempfile.new("diskusage")
28
+ dir = options[:dir] || ENV['HOME']
29
+ ::Open3.popen3("du","-d 0", dir) do |stdin, stdout, stderr, wait_thr|
30
+
31
+ if wait_thr.value != 0
32
+ STDERR.write "Exitcode: #{wait_thr.value}\n".light_black
33
+ STDERR.write stderr.gets(nil).light_black
34
+ end
35
+
36
+ tmpfile.write(stdout.gets(nil))
37
+ end
38
+ tmpfile.rewind
39
+ return tmpfile.path
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,3 @@
1
+ module But
2
+ VERSION = "0.1.2"
3
+ end
metadata ADDED
@@ -0,0 +1,243 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: but
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Raphael Müller
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-06-07 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.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 3.9.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 3.9.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: cucumber
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 4.0.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 4.0.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: aruba
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 1.0.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 1.0.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.84.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.84.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 2.16.2
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 2.16.2
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-compat
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 1.2.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 1.2.1
125
+ - !ruby/object:Gem::Dependency
126
+ name: guard-rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 4.7.3
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: 4.7.3
139
+ - !ruby/object:Gem::Dependency
140
+ name: guard-cucumber
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: 3.0.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 3.0.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: thor
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: colorize
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ description: BCF admins have a hard live. Their user's don't keep their $HOMES and
182
+ other working places clean. It appears that some users don't know that they use
183
+ too much space in their home or don't clean used directories on cluster (or other)
184
+ machines. This tools helps users find unused and unwanted directories, which could
185
+ make BCF admins happier.
186
+ email:
187
+ - raphael.mueller@computational.bio.uni-giessen.de
188
+ executables:
189
+ - but
190
+ extensions: []
191
+ extra_rdoc_files: []
192
+ files:
193
+ - ".gitignore"
194
+ - ".rspec"
195
+ - ".ruby-version"
196
+ - ".travis.yml"
197
+ - CHANGELOG
198
+ - CODE_OF_CONDUCT.md
199
+ - Gemfile
200
+ - Gemfile.lock
201
+ - Guardfile
202
+ - LICENSE.txt
203
+ - README.md
204
+ - Rakefile
205
+ - bash_idea_scripts/check_var_scratch.sh
206
+ - bash_idea_scripts/get_diskusage.sh
207
+ - bin/.keep
208
+ - bin/console
209
+ - bin/setup
210
+ - but.gemspec
211
+ - exe/but
212
+ - lib/.keep
213
+ - lib/but.rb
214
+ - lib/but/cli.rb
215
+ - lib/but/constants.rb
216
+ - lib/but/dev_wrapper.rb
217
+ - lib/but/home_keeper.rb
218
+ - lib/but/version.rb
219
+ homepage: https://git.computational.bio.uni-giessen.de/rmueller/bcf_user_tools
220
+ licenses:
221
+ - MIT
222
+ metadata:
223
+ source_code_uri: https://git.computational.bio.uni-giessen.de/rmueller/bcf_user_tools
224
+ post_install_message:
225
+ rdoc_options: []
226
+ require_paths:
227
+ - lib
228
+ required_ruby_version: !ruby/object:Gem::Requirement
229
+ requirements:
230
+ - - ">="
231
+ - !ruby/object:Gem::Version
232
+ version: '0'
233
+ required_rubygems_version: !ruby/object:Gem::Requirement
234
+ requirements:
235
+ - - ">="
236
+ - !ruby/object:Gem::Version
237
+ version: '0'
238
+ requirements: []
239
+ rubygems_version: 3.0.1
240
+ signing_key:
241
+ specification_version: 4
242
+ summary: Tools, to help users to improve their experience with the BCF infrastructure.
243
+ test_files: []