shabang 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: e52d1ca3ac3fcabc709e1b3f88bd57cca2ab0862
4
+ data.tar.gz: a17eb4cd05d41b2bae8f444669f66be9701480b1
5
+ SHA512:
6
+ metadata.gz: 0957f27f43afdac0510c1989bba28b868f53b082b3c62c6b4bf7907678c793207e24ca3aca4daf091762d6627764766b3f21ce090c88627004139a6185d51f99
7
+ data.tar.gz: 61f4f8dec8cde035207472bc684785e0c4dde4cd616edba2b1836181acedcee0ec7b6f20103f46306669c7ed2ae438983d7223edf06f4683c0b3cfe520257513
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in shabang.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Brian Glusman
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # Shabang
2
+
3
+ Trivial convenience app for generating bin/executable unix utilites in scriping language of your choice, defaulting to ruby, because. I often forget the exact form and go to copy an existing one, this just saves me the effort, and anyone else who has the same issue.
4
+
5
+
6
+ ## Installation/Usage
7
+
8
+ Do not add this to your application's Gemfile; This does not belong in a gemfile.
9
+
10
+ All it does is give you an executable command (a pair of them actually, for both spellings, shabang and shebang) which takes a filename and creates that file, with a ruby shebang and executable permissions, at ./bin/FILENAME
11
+
12
+ There are some options for other paths and other options, but I doubt you'll need them. This is mostly to solve the problem of forgetting the syntax `#!/usr/bin/env language-executable`
13
+
14
+ ```ruby
15
+ gem 'shabang'
16
+ ```
17
+
18
+ ## Contributing
19
+
20
+ 1. Fork it ( https://github.com/[my-github-username]/shabang/fork )
21
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
22
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
23
+ 4. Push to the branch (`git push origin my-new-feature`)
24
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/shabang ADDED
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'fileutils'
5
+ require 'ostruct'
6
+ require 'pp'
7
+ require 'pry'
8
+
9
+ class Shabang
10
+ VERSION = '0.1.0'
11
+ LANGS = %w[python perl node ruby bash sbcl runhaskell]
12
+
13
+ def self.parse(args)
14
+ options = OpenStruct.new
15
+ options.language = 'ruby'
16
+ options.path = 'bin/'
17
+
18
+ opt_parser = OptionParser.new do |opts|
19
+ opts.banner = "Usage: shabang [options] (or shebang [options])"
20
+
21
+ opts.separator ""
22
+ opts.separator "Specific options:"
23
+
24
+ lang_list = LANGS.join(',')
25
+ opts.on("--lang LANGUAGE", LANGS, "Select language",
26
+ " (#{lang_list})") do |language|
27
+ options.language = language
28
+ end
29
+
30
+ # Boolean switch.
31
+ opts.on("-p", "--python", "Generate python shebang") do
32
+ options.language = 'python'
33
+ end
34
+
35
+ opts.on("-P", "--perl", "Generate perl shebang") do
36
+ options.language = 'perl'
37
+ end
38
+
39
+ opts.on("-j", "--node", "--javascript", "Generate node.js shebang") do
40
+ options.language = 'node'
41
+ end
42
+
43
+ opts.on("-h", "--haskell", "Generate Haskell shebang") do
44
+ options.language = 'runhaskell'
45
+ end
46
+
47
+ # opts.on("-f", "--filename", "specify filename here instead of as default argument")
48
+
49
+ opts.on("-n", "--nobin", "Skip creating/putting in bin directory") do
50
+ options.path = nil
51
+ end
52
+
53
+ opts.on('--path PATH', 'Path to place bin instead of ./bin/') do |path|
54
+ options.path = path
55
+ end
56
+
57
+ opts.separator ""
58
+ opts.separator "Common options:"
59
+
60
+ # No argument, shows at tail. This will print an options summary.
61
+ # Try it and see!
62
+ opts.on_tail("-h", "--help", "Show this message") do
63
+ puts opts
64
+ exit
65
+ end
66
+
67
+ # Another typical switch to print the version.
68
+ opts.on_tail("--version", "Show version") do
69
+ puts VERSION
70
+ exit
71
+ end
72
+
73
+ end
74
+
75
+ opt_parser.parse!(args)
76
+ options
77
+ end
78
+
79
+ end
80
+ filename = ARGV.shift
81
+ options = Shabang.parse(ARGV)
82
+ FileUtils.mkdir_p(options.path[0..-1]) if options.path
83
+ options.path += '/' unless options.path[-1] == '/'
84
+ File.open(options.path.to_s + filename, 'wb', 0755) do |f|
85
+ f.puts "#!/usr/bin/env #{options.language}"
86
+ end
87
+
data/bin/shebang ADDED
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'fileutils'
5
+ require 'ostruct'
6
+ require 'pp'
7
+ require 'pry'
8
+
9
+ class Shabang
10
+ VERSION = '0.1.0'
11
+ LANGS = %w[python perl node ruby bash sbcl runhaskell]
12
+
13
+ def self.parse(args)
14
+ options = OpenStruct.new
15
+ options.language = 'ruby'
16
+ options.path = 'bin/'
17
+
18
+ opt_parser = OptionParser.new do |opts|
19
+ opts.banner = "Usage: shabang [options] (or shebang [options])"
20
+
21
+ opts.separator ""
22
+ opts.separator "Specific options:"
23
+
24
+ lang_list = LANGS.join(',')
25
+ opts.on("--lang LANGUAGE", LANGS, "Select language",
26
+ " (#{lang_list})") do |language|
27
+ options.language = language
28
+ end
29
+
30
+ # Boolean switch.
31
+ opts.on("-p", "--python", "Generate python shebang") do
32
+ options.language = 'python'
33
+ end
34
+
35
+ opts.on("-P", "--perl", "Generate perl shebang") do
36
+ options.language = 'perl'
37
+ end
38
+
39
+ opts.on("-j", "--node", "--javascript", "Generate node.js shebang") do
40
+ options.language = 'node'
41
+ end
42
+
43
+ opts.on("-h", "--haskell", "Generate Haskell shebang") do
44
+ options.language = 'runhaskell'
45
+ end
46
+
47
+ # opts.on("-f", "--filename", "specify filename here instead of as default argument")
48
+
49
+ opts.on("-n", "--nobin", "Skip creating/putting in bin directory") do
50
+ options.path = nil
51
+ end
52
+
53
+ opts.on('--path PATH', 'Path to place bin instead of ./bin/') do |path|
54
+ options.path = path
55
+ end
56
+
57
+ opts.separator ""
58
+ opts.separator "Common options:"
59
+
60
+ # No argument, shows at tail. This will print an options summary.
61
+ # Try it and see!
62
+ opts.on_tail("-h", "--help", "Show this message") do
63
+ puts opts
64
+ exit
65
+ end
66
+
67
+ # Another typical switch to print the version.
68
+ opts.on_tail("--version", "Show version") do
69
+ puts VERSION
70
+ exit
71
+ end
72
+
73
+ end
74
+
75
+ opt_parser.parse!(args)
76
+ options
77
+ end
78
+
79
+ end
80
+ filename = ARGV.shift
81
+ options = Shabang.parse(ARGV)
82
+ FileUtils.mkdir_p(options.path[0..-1]) if options.path
83
+ options.path += '/' unless options.path[-1] == '/'
84
+ File.open(options.path.to_s + filename, 'wb', 0755) do |f|
85
+ f.puts "#!/usr/bin/env #{options.language}"
86
+ end
87
+
data/shabang.gemspec ADDED
@@ -0,0 +1,17 @@
1
+ # coding: utf-8
2
+ load 'bin/shabang'
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "shabang"
6
+ spec.version = Shabang::VERSION
7
+ spec.authors = ["Brian Glusman"]
8
+ spec.email = ["brian@glusman.me"]
9
+ spec.summary = %q{Trivial convenience app to make *nix shebang files }
10
+ spec.description = %q{Trivial convenience app for generating bin/executable unix utilites in scriping language of your choice, defaulting to ruby, because. I often forget the exact form and go to copy an existing one, this just saves me the effort, and anyone else who has the same issue.}
11
+ spec.homepage = "https://github.com/bglusman/shabang"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files -z`.split("\x0")
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+
17
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shabang
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Brian Glusman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-17 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Trivial convenience app for generating bin/executable unix utilites in
14
+ scriping language of your choice, defaulting to ruby, because. I often forget the
15
+ exact form and go to copy an existing one, this just saves me the effort, and anyone
16
+ else who has the same issue.
17
+ email:
18
+ - brian@glusman.me
19
+ executables:
20
+ - shabang
21
+ - shebang
22
+ extensions: []
23
+ extra_rdoc_files: []
24
+ files:
25
+ - ".gitignore"
26
+ - Gemfile
27
+ - LICENSE.txt
28
+ - README.md
29
+ - Rakefile
30
+ - bin/shabang
31
+ - bin/shebang
32
+ - shabang.gemspec
33
+ homepage: https://github.com/bglusman/shabang
34
+ licenses:
35
+ - MIT
36
+ metadata: {}
37
+ post_install_message:
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubyforge_project:
53
+ rubygems_version: 2.4.3
54
+ signing_key:
55
+ specification_version: 4
56
+ summary: Trivial convenience app to make *nix shebang files
57
+ test_files: []