bsd_wtf 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: 66b00e46d1389bd3f2f42f2af708d2f9eaa27073
4
+ data.tar.gz: 8fd19b20e5d56548b3219aaf880543e930691d9b
5
+ SHA512:
6
+ metadata.gz: 97889ae5784601b6c925b05530770ddd82433dc0dd76dd59f3f249a5ff0662d4f51bb81cd50a4a2dfe51e45530dfd28bc59ef4de8c005dfd301e6b84fc0667c1
7
+ data.tar.gz: 29a4b7c007f2c6cb30a78e71ea335b1a0e12151430fe61066e68cd486fcbad237cd053ea3a06b181f17e11a26d30d8314f941eaa1f323e01d26f40fe82b7b4e8
data/.gitignore ADDED
@@ -0,0 +1,87 @@
1
+ ### https://raw.github.com/github/gitignore/ea2aa40cb4620e334a87e8494e03d0e7d1ec11df/Ruby.gitignore
2
+
3
+ *.gem
4
+ *.rbc
5
+ /.config
6
+ /coverage/
7
+ /InstalledFiles
8
+ /pkg/
9
+ /spec/reports/
10
+ /spec/examples.txt
11
+ /.rspec_status
12
+ /test/tmp/
13
+ /test/version_tmp/
14
+ /tmp/
15
+
16
+ # Used by dotenv library to load environment variables.
17
+ # .env
18
+
19
+ ## Documentation cache and generated files:
20
+ /.yardoc/
21
+ /_yardoc/
22
+ /doc/
23
+ /rdoc/
24
+
25
+ ## Environment normalization:
26
+ /.bundle/
27
+ /vendor/bundle
28
+ /lib/bundler/man/
29
+
30
+ # for a library or gem, you might want to ignore these files since the code is
31
+ # intended to run in multiple environments; otherwise, check them in:
32
+ # Gemfile.lock
33
+ # .ruby-version
34
+ # .ruby-gemset
35
+
36
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
37
+ .rvmrc
38
+
39
+
40
+ ### https://raw.github.com/github/gitignore/ea2aa40cb4620e334a87e8494e03d0e7d1ec11df/Global/macOS.gitignore
41
+
42
+ # General
43
+ .DS_Store
44
+ .AppleDouble
45
+ .LSOverride
46
+
47
+ # Icon must end with two \r
48
+ Icon
49
+
50
+ # Thumbnails
51
+ ._*
52
+
53
+ # Files that might appear in the root of a volume
54
+ .DocumentRevisions-V100
55
+ .fseventsd
56
+ .Spotlight-V100
57
+ .TemporaryItems
58
+ .Trashes
59
+ .VolumeIcon.icns
60
+ .com.apple.timemachine.donotpresent
61
+
62
+ # Directories potentially created on remote AFP share
63
+ .AppleDB
64
+ .AppleDesktop
65
+ Network Trash Folder
66
+ Temporary Items
67
+ .apdisk
68
+
69
+
70
+ ### https://raw.github.com/github/gitignore/ea2aa40cb4620e334a87e8494e03d0e7d1ec11df/Global/Vim.gitignore
71
+
72
+ # Swap
73
+ [._]*.s[a-v][a-z]
74
+ [._]*.sw[a-p]
75
+ [._]s[a-v][a-z]
76
+ [._]sw[a-p]
77
+
78
+ # Session
79
+ Session.vim
80
+
81
+ # Temporary
82
+ .netrwhist
83
+ *~
84
+ # Auto-generated tag files
85
+ tags
86
+
87
+
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.1.8
5
+ before_install: gem install bundler -v 1.16.0
@@ -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 steve.huff@runkeeper.com. 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,12 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gem "json", "~> 2"
6
+ gem "whiches", "~> 0"
7
+
8
+ group :development do
9
+ gem "irbtools", "~> 2"
10
+ gem "rake", "~> 10.0"
11
+ gem "rspec", "~> 3.0"
12
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,89 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ awesome_print (1.8.0)
5
+ binding.repl (3.0.0)
6
+ cd (1.0.1)
7
+ clipboard (1.1.1)
8
+ code (0.9.2)
9
+ coderay (~> 1.1)
10
+ method_source (~> 0.9)
11
+ coderay (1.1.2)
12
+ debugging (1.1.1)
13
+ binding.repl (~> 3.0)
14
+ paint (>= 0.9, < 3.0)
15
+ diff-lcs (1.3)
16
+ every_day_irb (2.0.0)
17
+ cd (~> 1.0)
18
+ fancy_irb (1.1.0)
19
+ paint (>= 0.9, < 3.0)
20
+ unicode-display_width (~> 1.1)
21
+ ffi (1.9.18)
22
+ hirb (0.7.3)
23
+ instance (0.2.0)
24
+ interactive_editor (0.0.11)
25
+ spoon (>= 0.0.1)
26
+ irbtools (2.2.0)
27
+ binding.repl (~> 3.0)
28
+ clipboard (~> 1.1)
29
+ code (~> 0.9)
30
+ coderay (~> 1.1)
31
+ debugging (~> 1.1)
32
+ every_day_irb (~> 2.0)
33
+ fancy_irb (~> 1.1)
34
+ hirb (~> 0.7, >= 0.7.3)
35
+ instance (~> 0.2)
36
+ interactive_editor (~> 0.0, >= 0.0.10)
37
+ method_locator (~> 0.0, >= 0.0.4)
38
+ methodfinder (~> 2.0)
39
+ ori (~> 0.1.0)
40
+ os (~> 1.0)
41
+ paint (>= 0.9, < 3.0)
42
+ ruby_engine (~> 1.0)
43
+ ruby_info (~> 1.0)
44
+ ruby_version (~> 1.0)
45
+ wirb (~> 2.0)
46
+ json (2.1.0)
47
+ method_locator (0.0.4)
48
+ method_source (0.9.0)
49
+ methodfinder (2.1.1)
50
+ ori (0.1.0)
51
+ os (1.0.0)
52
+ paint (2.0.1)
53
+ rake (10.5.0)
54
+ rspec (3.7.0)
55
+ rspec-core (~> 3.7.0)
56
+ rspec-expectations (~> 3.7.0)
57
+ rspec-mocks (~> 3.7.0)
58
+ rspec-core (3.7.0)
59
+ rspec-support (~> 3.7.0)
60
+ rspec-expectations (3.7.0)
61
+ diff-lcs (>= 1.2.0, < 2.0)
62
+ rspec-support (~> 3.7.0)
63
+ rspec-mocks (3.7.0)
64
+ diff-lcs (>= 1.2.0, < 2.0)
65
+ rspec-support (~> 3.7.0)
66
+ rspec-support (3.7.0)
67
+ ruby_engine (1.0.1)
68
+ ruby_info (1.0.1)
69
+ ruby_version (1.0.1)
70
+ spoon (0.0.6)
71
+ ffi
72
+ unicode-display_width (1.3.0)
73
+ whiches (0.0.2)
74
+ awesome_print
75
+ wirb (2.1.2)
76
+ paint (>= 0.9, < 3.0)
77
+
78
+ PLATFORMS
79
+ ruby
80
+
81
+ DEPENDENCIES
82
+ irbtools (~> 2)
83
+ json (~> 2)
84
+ rake (~> 10.0)
85
+ rspec (~> 3.0)
86
+ whiches (~> 0)
87
+
88
+ BUNDLED WITH
89
+ 1.16.0
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Steve Huff
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.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # BsdWtf
2
+
3
+ This gem wraps the [BSD wtf](https://www.freebsd.org/cgi/man.cgi?query=wtf&manpath=NetBSD+7.1) command in a Ruby interface.
4
+
5
+ The `wtf` executable must already be present on this system and located in `$PATH`.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'bsd_wtf'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install bsd_wtf
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ $ irb -r bsd_wtf
27
+ irb(main):001:0> BsdWtf.wtf("wtf")
28
+ => {:success=>[{:acronym=>"WTF", :definition=>"where's the food"}], :failure=>[]}
29
+ irb(main):002:0> BsdWtf.wtf(["wtf","lolwut"]).to_json
30
+ => "{\"success\":[{\"acronym\":\"WTF\",\"definition\":\"where's the food\"}],\"failure\":[\"lolwut\"]}"
31
+ ```
32
+
33
+ ## Development
34
+
35
+ 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.
36
+
37
+ To install this gem onto your local machine, run `bundle exec rake install`.
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/hakamadare/rubygem-bsd_wtf. 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.
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
46
+
47
+ ## Code of Conduct
48
+
49
+ Everyone interacting in the BsdWtf project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/hakamadare/rubygem-bsd_wtf/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -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
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bsd_wtf"
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__)
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
data/bsd_wtf.gemspec ADDED
@@ -0,0 +1,30 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "bsd_wtf/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bsd_wtf"
8
+ spec.version = BsdWtf::VERSION
9
+ spec.authors = ["Steve Huff"]
10
+ spec.email = ["shuff@vecna.org"]
11
+
12
+ spec.summary = %q{Wrap the `wtf` command}
13
+ spec.description = %q{Capture the output of the BSD `wtf` command}
14
+ spec.homepage = "https://github.com/hakamadare/rubygem-bsd_wtf"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.16"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+
28
+ spec.add_dependency "json", "~> 2"
29
+ spec.add_dependency "whiches", "~> 0"
30
+ end
data/lib/bsd_wtf.rb ADDED
@@ -0,0 +1,55 @@
1
+ require "bsd_wtf/version"
2
+ require "open3"
3
+ require "whiches"
4
+ require "json"
5
+
6
+ module BsdWtf
7
+ def self.wtf(acronyms = [])
8
+ _do_wtf(_get_wtf, acronyms)
9
+ end
10
+
11
+ private
12
+
13
+ def self._do_wtf(wtf=_get_wtf, acronyms=[])
14
+ wtf_cmd = wtf + ' ' + Array(acronyms).join(' ')
15
+
16
+ stdout_str, stderr_str, status = Open3.capture3(wtf_cmd)
17
+
18
+ if status.success?
19
+ _process_wtf(stdout_str)
20
+ else
21
+ raise StandardError.new(stderr_str.chomp)
22
+ end
23
+ end
24
+
25
+ def self._get_wtf
26
+ results = Whiches.whiches("wtf")
27
+
28
+ if results
29
+ results[0]
30
+ else
31
+ raise StandardError.new("unable to find 'wtf' in path")
32
+ end
33
+ end
34
+
35
+ def self._process_wtf(raw='')
36
+ result = {
37
+ :success => [],
38
+ :failure => [],
39
+ }
40
+
41
+ raw.chomp.split("\n").each do |line|
42
+ acronym, definition = line.split(':', 2)
43
+
44
+ /nothing appropriate/ =~ definition
45
+
46
+ if Regexp.last_match.nil?
47
+ result[:success].push({:acronym => acronym, :definition => definition.strip})
48
+ else
49
+ result[:failure].push(acronym)
50
+ end
51
+ end
52
+
53
+ result
54
+ end
55
+ end
@@ -0,0 +1,3 @@
1
+ module BsdWtf
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bsd_wtf
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Steve Huff
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-12-12 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
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.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.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: whiches
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Capture the output of the BSD `wtf` command
84
+ email:
85
+ - shuff@vecna.org
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - CODE_OF_CONDUCT.md
94
+ - Gemfile
95
+ - Gemfile.lock
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/console
100
+ - bin/setup
101
+ - bsd_wtf.gemspec
102
+ - lib/bsd_wtf.rb
103
+ - lib/bsd_wtf/version.rb
104
+ homepage: https://github.com/hakamadare/rubygem-bsd_wtf
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.2.5
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Wrap the `wtf` command
128
+ test_files: []