nr 0.1.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: 29f3b5815171dfd6e87829a17b726a1af0a1a7b7
4
+ data.tar.gz: 034727f6deecff98c96b3405b3eb1f942870bf6f
5
+ !binary "U0hBNTEy":
6
+ metadata.gz: f7b34a40b37d0b317c7d0ad2317658058577d17cdd6b700d5bce0e3f65730af2485e5f78237ebd314b66703da55812dfe43a5a73e8b2fc8abc50ec06be7d7ec4
7
+ data.tar.gz: e1070ca1aec27d5cd4477babbcb45bb3b1988915a4ef11c2a216e0547509c4b7e8df972e79a114cf407434e6a196e0828cf1d9f822bdf3d8b5b6ff48fb54d115
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ task 'gem:spec' do
11
11
  s.name = 'nr'
12
12
  s.version = Nr::VERSION
13
13
 
14
- %w[cool.io].each{ |g| s.add_runtime_dependency(g) }
14
+ %w[celluloid-io].each{ |g| s.add_runtime_dependency(g) }
15
15
  end
16
16
 
17
17
  Gemgem.write
data/bin/nr CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'nr'
4
- Nr.start ARGV
3
+ require 'nr/runner'
4
+ Nr::Runner.run
data/lib/nr.rb CHANGED
@@ -1,20 +1,21 @@
1
1
 
2
- require 'cool.io'
2
+ require 'celluloid/io'
3
3
 
4
- module Nr
5
- class Connection < Coolio::TCPSocket
6
- def on_close
7
- Coolio::Loop.default.stop
8
- end
4
+ class Nr
5
+ include Celluloid::IO
9
6
 
10
- def on_read data
11
- print data
12
- end
7
+ def initialize host, port
8
+ @server = TCPServer.new(host, port)
13
9
  end
14
10
 
15
- def self.start argv
16
- loop = Coolio::Loop.default
17
- Coolio::TCPServer.new(argv[0], argv[1].to_i, Connection).attach(loop)
18
- loop.run
11
+ def start
12
+ sock = @server.accept
13
+ loop{ yield sock.readpartial(4096) }
14
+ rescue EOFError
15
+ begin
16
+ sock.close
17
+ rescue EOFError
18
+ end
19
+ terminate
19
20
  end
20
21
  end
data/lib/nr/runner.rb ADDED
@@ -0,0 +1,65 @@
1
+
2
+ require 'nr'
3
+
4
+ module Nr::Runner
5
+ module_function
6
+ def options
7
+ @options ||=
8
+ [['-o, --host HOST' ,
9
+ 'HOST it is listening to (default: 0.0.0.0)'],
10
+
11
+ ['-p, --port PORT' ,
12
+ 'PORT it is bound to (default: 12344)' ],
13
+
14
+ ['-h, --help' , 'Print this message' ],
15
+ ['-v, --version' , 'Print the version' ]]
16
+ end
17
+
18
+ def run argv=ARGV
19
+ host, port = parse(argv)
20
+ warn("Listening on #{host}:#{port}")
21
+ Nr.new(host, port).start{ |bytes| print bytes }
22
+ end
23
+
24
+ def parse argv
25
+ unused, host, port = [], '0.0.0.0', 12344
26
+ until argv.empty?
27
+ case arg = argv.shift
28
+ when /^-p=?(.+)?/, /^--port=?(.+)?/
29
+ port = $1 || argv.shift
30
+
31
+ when /^-o=?(.+)?/, /^--host=?(.+)?/
32
+ host = $1 || argv.shift
33
+
34
+ when /^-h/, '--help'
35
+ puts(help)
36
+ exit
37
+
38
+ when /^-v/, '--version'
39
+ require 'nr/version'
40
+ puts(Nr::VERSION)
41
+ exit
42
+
43
+ when /^(\d+)/
44
+ port = arg
45
+
46
+ else
47
+ host = arg
48
+ end
49
+ end
50
+ [host, port]
51
+ end
52
+
53
+ def help
54
+ maxn = options.transpose.first.map(&:size).max
55
+ maxd = options.transpose.last .map(&:size).max
56
+ "Usage: nr HOST PORT\n" +
57
+ options.map{ |(name, desc)|
58
+ if desc.empty?
59
+ name
60
+ else
61
+ sprintf(" %-*s %-*s", maxn, name, maxd, desc)
62
+ end
63
+ }.join("\n")
64
+ end
65
+ end
data/lib/nr/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Nr
3
- VERSION = '0.1.0'
3
+ VERSION = '0.9.0'
4
4
  end
data/nr.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "nr"
5
- s.version = "0.1.0"
5
+ s.version = "0.9.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Lin Jen-Shin (godfat)"]
9
- s.date = "2011-09-13"
9
+ s.date = "2013-04-16"
10
10
  s.description = "nr -- net received -- The other side of nc\n\nPlay with `nr localhost 1234` and `nc localhost 1234`"
11
11
  s.email = ["godfat (XD) godfat.org"]
12
12
  s.executables = ["nr"]
@@ -17,24 +17,25 @@ Gem::Specification.new do |s|
17
17
  "Rakefile",
18
18
  "bin/nr",
19
19
  "lib/nr.rb",
20
+ "lib/nr/runner.rb",
20
21
  "lib/nr/version.rb",
21
22
  "nr.gemspec",
22
23
  "task/.gitignore",
23
24
  "task/gemgem.rb"]
24
25
  s.homepage = "https://github.com/godfat/nr"
25
26
  s.require_paths = ["lib"]
26
- s.rubygems_version = "1.8.10"
27
+ s.rubygems_version = "2.0.0"
27
28
  s.summary = "nr -- net received -- The other side of nc"
28
29
 
29
30
  if s.respond_to? :specification_version then
30
- s.specification_version = 3
31
+ s.specification_version = 4
31
32
 
32
33
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
33
- s.add_runtime_dependency(%q<cool.io>, [">= 0"])
34
+ s.add_runtime_dependency(%q<celluloid-io>, [">= 0"])
34
35
  else
35
- s.add_dependency(%q<cool.io>, [">= 0"])
36
+ s.add_dependency(%q<celluloid-io>, [">= 0"])
36
37
  end
37
38
  else
38
- s.add_dependency(%q<cool.io>, [">= 0"])
39
+ s.add_dependency(%q<celluloid-io>, [">= 0"])
39
40
  end
40
41
  end
data/task/gemgem.rb CHANGED
@@ -32,7 +32,8 @@ module Gemgem
32
32
  }
33
33
  @readme ||=
34
34
  if path
35
- ps = File.read(path).scan(/#+[^\n]+\n\n.+?(?=\n\n#+[^\n]+\n)/m)
35
+ ps = "##{File.read(path)}".
36
+ scan(/((#+)[^\n]+\n\n.+?(?=\n\n\2[^#\n]+\n))/m).map(&:first)
36
37
  ps.inject({'HEADER' => ps.first}){ |r, s, i|
37
38
  r[s[/\w+/]] = s
38
39
  r
@@ -54,19 +55,20 @@ module Gemgem
54
55
  if path
55
56
  date = '\d+{4}\-\d+{2}\-\d{2}'
56
57
  File.read(path).match(
57
- /([^\n]+#{date}\n\n(.+?))(?=\n\n[^\n]+#{date}\n)/m)[1]
58
+ /([^\n]+#{date}\n\n(.+?))(?=\n\n[^\n]+#{date}\n|\Z)/m)[1]
58
59
  else
59
60
  ''
60
61
  end
61
62
  end
62
63
 
63
64
  def ann_md
64
- "##{readme['HEADER'].sub(/([\w\-]+)/, "[\\1](#{spec.homepage})")}\n\n" \
65
+ "#{readme['HEADER'].sub(/([\w\-]+)/, "[\\1](#{spec.homepage})")}\n\n" \
65
66
  "##{readme['DESCRIPTION'][/[^\n]+\n\n[^\n]+/]}\n\n" \
66
67
  "### CHANGES:\n\n" \
67
68
  "###{changes}\n\n" \
68
69
  "##{readme['INSTALLATION']}\n\n" +
69
- if readme['SYNOPSIS'] then "##{readme['SYNOPSIS']}" else '' end
70
+ if readme['SYNOPSIS'] then "##{readme['SYNOPSIS'][/[^\n]+\n\n[^\n]+/]}"
71
+ else '' end
70
72
  end
71
73
 
72
74
  def ann_html
@@ -113,7 +115,7 @@ module Gemgem
113
115
 
114
116
  def all_files
115
117
  @all_files ||= find_files(Pathname.new(dir)).map{ |file|
116
- if file.to_s =~ %r{\.git/}
118
+ if file.to_s =~ %r{\.git/|\.git$}
117
119
  nil
118
120
  else
119
121
  file.to_s
@@ -177,7 +179,7 @@ namespace :gem do
177
179
 
178
180
  desc 'Install gem'
179
181
  task :install => [:build] do
180
- sh("#{Gem.ruby} -S gem install pkg/#{Gemgem.gem_tag}")
182
+ sh("#{Gem.ruby} -S gem install pkg/#{Gemgem.gem_tag}.gem")
181
183
  end
182
184
 
183
185
  desc 'Build gem'
@@ -199,14 +201,14 @@ task :check do
199
201
  ver = Gemgem.spec.version.to_s
200
202
 
201
203
  if ENV['VERSION'].nil?
202
- puts("\x1b[35mExpected " \
203
- "\x1b[33mVERSION\x1b[35m=\x1b[33m#{ver}\x1b[m")
204
+ puts("\e[35mExpected " \
205
+ "\e[33mVERSION\e[35m=\e[33m#{ver}\e[0m")
204
206
  exit(1)
205
207
 
206
208
  elsif ENV['VERSION'] != ver
207
- puts("\x1b[35mExpected \x1b[33mVERSION\x1b[35m=\x1b[33m#{ver} " \
208
- "\x1b[35mbut got\n " \
209
- "\x1b[33mVERSION\x1b[35m=\x1b[33m#{ENV['VERSION']}\x1b[m")
209
+ puts("\e[35mExpected \e[33mVERSION\e[35m=\e[33m#{ver} " \
210
+ "\e[35mbut got\n " \
211
+ "\e[33mVERSION\e[35m=\e[33m#{ENV['VERSION']}\e[0m")
210
212
  exit(2)
211
213
  end
212
214
  end
metadata CHANGED
@@ -1,27 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.9.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Lin Jen-Shin (godfat)
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-09-13 00:00:00.000000000Z
11
+ date: 2013-04-16 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: cool.io
16
- requirement: &2152449000 !ruby/object:Gem::Requirement
17
- none: false
14
+ name: celluloid-io
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *2152449000
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  description: ! 'nr -- net received -- The other side of nc
26
28
 
27
29
 
@@ -39,32 +41,32 @@ files:
39
41
  - Rakefile
40
42
  - bin/nr
41
43
  - lib/nr.rb
44
+ - lib/nr/runner.rb
42
45
  - lib/nr/version.rb
43
46
  - nr.gemspec
44
47
  - task/.gitignore
45
48
  - task/gemgem.rb
46
49
  homepage: https://github.com/godfat/nr
47
50
  licenses: []
51
+ metadata: {}
48
52
  post_install_message:
49
53
  rdoc_options: []
50
54
  require_paths:
51
55
  - lib
52
56
  required_ruby_version: !ruby/object:Gem::Requirement
53
- none: false
54
57
  requirements:
55
58
  - - ! '>='
56
59
  - !ruby/object:Gem::Version
57
60
  version: '0'
58
61
  required_rubygems_version: !ruby/object:Gem::Requirement
59
- none: false
60
62
  requirements:
61
63
  - - ! '>='
62
64
  - !ruby/object:Gem::Version
63
65
  version: '0'
64
66
  requirements: []
65
67
  rubyforge_project:
66
- rubygems_version: 1.8.10
68
+ rubygems_version: 2.0.0
67
69
  signing_key:
68
- specification_version: 3
70
+ specification_version: 4
69
71
  summary: nr -- net received -- The other side of nc
70
72
  test_files: []