ttyname 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2011 by Samuel Kadolph
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,32 @@
1
+ # ruby-ttyname
2
+
3
+ ruby-ttyname is a small library that lets get the name of a tty device.
4
+
5
+ ruby-ttyname adds one method (`ttyname`) for use with any `IO` instance for a
6
+ TTY device.
7
+
8
+ ## Installing
9
+
10
+ ### Recommended
11
+
12
+ ```
13
+ gem install ttyname
14
+ ```
15
+
16
+ ### Edge
17
+
18
+ ```
19
+ git clone https://github.com/samuelkadolph/ruby-ttyname
20
+ cd ruby-ttyname && rake install
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ To get the ttyname of the `$stdout` terminal.
26
+
27
+ ```ruby
28
+ require "ttyname"
29
+
30
+ name = $stdout.ttyname
31
+ puts "Your terminal is #{name}"
32
+ ```
@@ -0,0 +1,6 @@
1
+ require "mkmf"
2
+
3
+ abort("unistd.h is required") unless have_header("unistd.h")
4
+ abort("ttyname() is required") unless have_func("ttyname")
5
+
6
+ create_makefile "ttyname"
@@ -0,0 +1,18 @@
1
+ #include <ruby.h>
2
+ #include <unistd.h>
3
+
4
+ static VALUE fd_ttyname(VALUE self, VALUE fd)
5
+ {
6
+ char * name = ttyname(NUM2INT(fd));
7
+
8
+ if (name == NULL)
9
+ rb_raise(rb_eRuntimeError, "not a TTY device");
10
+
11
+ return rb_str_new2(name);
12
+ }
13
+
14
+ void Init_ttyname()
15
+ {
16
+ VALUE mTTYName = rb_define_module("TTYName");
17
+ rb_define_singleton_method(mTTYName, "ttyname", fd_ttyname, 1);
18
+ }
@@ -0,0 +1,12 @@
1
+ require "ttyname.so"
2
+ require "ttyname/version"
3
+
4
+ module TTYName
5
+ def ttyname
6
+ TTYName.ttyname(fileno)
7
+ end
8
+ end
9
+
10
+ class IO
11
+ include TTYName
12
+ end
@@ -0,0 +1,3 @@
1
+ module TTYName
2
+ VERSION = "1.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ttyname
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.0
6
+ platform: ruby
7
+ authors:
8
+ - Samuel Kadolph
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-24 00:00:00 -04:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: ruby-ttyname adds one method (ttyname) for use with any IO instance for a TTY device.
18
+ email:
19
+ - samuel@kadolph.com
20
+ executables: []
21
+
22
+ extensions:
23
+ - ext/extconf.rb
24
+ extra_rdoc_files: []
25
+
26
+ files:
27
+ - ext/extconf.rb
28
+ - ext/ttyname.c
29
+ - lib/ttyname/version.rb
30
+ - lib/ttyname.rb
31
+ - LICENSE
32
+ - README.md
33
+ has_rdoc: true
34
+ homepage: https://github.com/samuelkadolph/ruby-ttyname
35
+ licenses: []
36
+
37
+ post_install_message:
38
+ rdoc_options: []
39
+
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ requirements: []
55
+
56
+ rubyforge_project:
57
+ rubygems_version: 1.6.2
58
+ signing_key:
59
+ specification_version: 3
60
+ summary: ruby-ttyname is a small library that lets get the name of a tty device.
61
+ test_files: []
62
+