Skip to content

Commit 2ad273e

Browse files
author
segfault
committed
added the NOTES file
fixed the version generation code proxy server now outputs some information the rakefile can now deploy the project git-svn-id: svn://hasno.info/ruby-hl7/trunk@23 72d81af0-b0fa-4b65-b54c-2b622d79b57a
1 parent 638bf42 commit 2ad273e

File tree

5 files changed

+119
-21
lines changed

5 files changed

+119
-21
lines changed

NOTES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
$Id$
2+
== Ruby-HL7 v0.1.23 Release Notes
3+
Initial public release, please see the
4+
README for information about the project.

README

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
=Ruby HL7 Library README
22

33
A simple way to parse and create hl7 2.x messages with ruby.
4-
Examples can be found in lib/ruby-hl7.rb
4+
Examples can be found in HL7::Message
5+
The version id can be found in the HL7::VERSION constant.
56

67
* Bug tracking: http://trac.hasno.info/ruby-hl7
78
* Subversion: svn://hasno.info/ruby-hl7

Rakefile

Lines changed: 92 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,41 @@ require 'rake/testtask'
55
require 'rake/rdoctask'
66
require 'rake/packagetask'
77
require 'rake/gempackagetask'
8+
require 'rake/contrib/sshpublisher'
9+
require 'rbconfig'
10+
require 'rubyforge'
11+
812
$: << './lib'
913
require 'ruby-hl7'
1014

15+
# Many of these tasks were garnered from zenspider's Hoe
16+
# just forced to work my way
17+
18+
19+
spec = Gem::Specification.new do |s|
20+
s.name = "Ruby-HL7"
21+
s.version = HL7::VERSION
22+
s.author = "Mark Guzman"
23+
s.email = "[email protected]"
24+
s.homepage = "http://rubyforge.org/ruby-hl7"
25+
s.platform = Gem::Platform::RUBY
26+
s.summary = "Ruby HL7 Library"
27+
s.rubyforge_project = "ruby-hl7"
28+
s.description = "A simple library to parse and generate HL7 2.x messages"
29+
s.files = FileList["{bin,lib,test_data}/**/*"].to_a
30+
s.require_path = "lib"
31+
s.autorequire = "ruby-hl7"
32+
s.test_files = FileList["{test}/**/test*.rb"].to_a
33+
s.has_rdoc = true
34+
s.extra_rdoc_files = %w[README LICENSE]
35+
s.add_dependency("facets", ">= 1.8.51")
36+
s.add_dependency("rake", ">= #{RAKEVERSION}")
37+
s.add_dependency("rubyforge", ">= #{::RubyForge::VERSION}")
38+
end
39+
1140

1241
Rake::TestTask.new do |t|
13-
t.test_files = FileList[ 'test/test*.rb' ]
42+
t.test_files = FileList[ 'test/test*.rb', 'test/*test.rb' ]
1443
t.verbose = true
1544
end
1645

@@ -28,30 +57,75 @@ namespace :test do
2857
task :heckle do
2958
system("heckle HL7::Message")
3059
end
60+
61+
desc 'Show which test files fail when run alone.'
62+
task :deps do
63+
tests = Dir["test/**/test_*.rb"] + Dir["test/**/*_test.rb"]
64+
65+
tests.each do |test|
66+
if not system "ruby -Ibin:lib:test #{test} &> /dev/null" then
67+
puts "Dependency Issues: #{test}"
68+
end
69+
end
70+
end
3171
end
3272

3373
Rake::RDocTask.new do |rd|
3474
rd.main = "README"
3575
rd.rdoc_files.include("README", "LICENSE", "lib/**/*.rb")
76+
rd.title = "%s (%s) Documentation" % [ spec.name, spec.version ]
77+
rd.rdoc_dir = 'doc'
3678
end
3779

38-
spec = Gem::Specification.new do |s|
39-
s.name = "Ruby-HL7"
40-
s.version = HL7::VERSION
41-
s.author = "Mark Guzman"
42-
s.email = "[email protected]"
43-
s.homepage = "http://rubyforge.org/ruby-hl7"
44-
s.platform = Gem::Platform::RUBY
45-
s.summary = "Ruby HL7 Library"
46-
s.files = FileList["{bin,lib,test_data}/**/*"].to_a
47-
s.require_path = "lib"
48-
s.autorequire = "ruby-hl7"
49-
s.test_files = FileList["{test}/**/test*.rb"].to_a
50-
s.has_rdoc = true
51-
s.extra_rdoc_files = %w[README LICENSE]
52-
s.add_dependency("facets", ">= 0.0.0")
53-
end
54-
80+
5581
Rake::GemPackageTask.new(spec) do |pkg|
5682
pkg.need_tar = true
5783
end
84+
85+
desc 'Clean up all the extras'
86+
task :clean => [ :clobber_rdoc, :clobber_package ] do
87+
%w[*.gem ri coverage*].each do |pattern|
88+
files = Dir[pattern]
89+
rm_rf files unless files.empty?
90+
end
91+
end
92+
93+
desc 'Publish RDoc to RubyForge'
94+
task :publish_docs => [:clean, :rdoc] do
95+
config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
96+
host = "#{config["username"]}@rubyforge.org"
97+
remote_dir = "/var/www/gforge-projects/#{spec.rubyforge_project}"
98+
local_dir = 'doc'
99+
sh %{rsync -av --delete #{local_dir}/ #{host}:#{remote_dir}}
100+
end
101+
102+
desc 'Package and upload the release to rubyforge.'
103+
task :release => [:clean, :package] do |t|
104+
v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
105+
abort "Versions don't match #{v} vs #{spec.version}" if v != spec.version
106+
pkg = "pkg/#{spec.name}-#{spec.version}"
107+
108+
if $DEBUG then
109+
puts "release_id = rf.add_release #{spec.rubyforge_project.inspect}, #{spec.name.inspect}, #{version.inspect}, \"#{pkg}.tgz\""
110+
puts "rf.add_file #{spec.rubyforge_project.inspect}, #{spec.name.inspect}, release_id, \"#{pkg}.gem\""
111+
end
112+
113+
rf = RubyForge.new
114+
puts "Logging in"
115+
rf.login
116+
117+
c = rf.userconfig
118+
c["release_notes"] = spec.description if spec.description
119+
c["release_changes"] = changes if changes
120+
c["preformatted"] = true
121+
122+
files = ["#{pkg}.tgz", "#{pkg}.gem"].compact
123+
124+
puts "Releasing #{spec.name} v. #{spec.version}"
125+
rf.add_release spec.rubyforge_project, spec.name, spec.version, *files
126+
end
127+
128+
desc 'Install the package as a gem'
129+
task :install_gem => [:clean, :package] do
130+
sh "sudo gem install pkg/*.gem"
131+
end

examples/proxy_server.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
# $Id$
22
# Ruby-HL7 Proxy Server Example
3+
require 'rubygems'
34
require 'ruby-hl7'
45
require 'thread'
56
require 'socket'
67

7-
srv = TCPServer.new(2402)
8+
PORT = 2402
89
target_ip = "127.0.0.1"
910
target_port = 5900
1011

12+
srv = TCPServer.new(PORT)
13+
puts "proxy_server listening on port: %i" % PORT
14+
puts "proxying for: %s:%i" % [ target_ip, target_port ]
1115
while true
1216
sok = srv.accept
1317
Thread.new( sok ) do |my_socket|
1418
raw_inp = my_socket.readlines
1519
msg = HL7::Message.new( raw_input )
20+
puts "forwarding message:\n%s" % msg.to_s
1621
soc = TCPSocket.open( target_ip, target_port )
1722
soc.write msg.to_mllp
1823
soc.close

lib/ruby-hl7.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
require 'facets/core/class/cattr'
2222

2323
module HL7 # :nodoc:
24-
VERSION = "0.1.%s" % "$Rev$".gsub(/\$Rev:\s+/, '').gsub(/\$$/, '')
24+
VERSION = "0.1.%s" % "$Rev$".gsub(/\$Rev:\s+/, '').gsub(/\s*\$$/, '')
2525
end
2626

2727
# Encapsulate HL7 specific exceptions
@@ -261,6 +261,20 @@ def generate_segments( ary )
261261
# The segments can be setup to provide aliases to specific fields with
262262
# optional validation code that is run when the field is modified
263263
# The segment field data is also accessible via the e<number> method.
264+
#
265+
# == Defining a New Segment
266+
# class HL7::Message::Segment::NK1 < HL7::Message::Segment
267+
# wieght 100 # segments are sorted ascendingly
268+
# add_field :name=>:something_you_want # assumes :idx=>1
269+
# add_field :name=>:something_else, :idx=>6 # :idx=>6 and field count=6
270+
# add_field :name=>:something_more # :idx=>7
271+
# add_field :name=>:block_example do |value|
272+
# raise HL7::InvalidDataError.new unless value.to_i < 100 && value.to_i > 10
273+
# return value
274+
# end
275+
# # this block will be executed when seg.block_example= is called
276+
# # and when seg.block_example is called
277+
#
264278
class HL7::Message::Segment
265279
attr :element_delim
266280
attr :item_delim

0 commit comments

Comments
 (0)