scbi_headers 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,3 @@
1
+ === 0.0.1 2012-05-28
2
+
3
+ * Initial release
data/Manifest.txt ADDED
@@ -0,0 +1,12 @@
1
+ History.txt
2
+ lib/scbi_headers/scbi_header.rb
3
+ lib/scbi_headers.rb
4
+ Manifest.txt
5
+ PostInstall.txt
6
+ Rakefile
7
+ README.rdoc
8
+ script/console
9
+ script/destroy
10
+ script/generate
11
+ test/test_helper.rb
12
+ test/test_scbi_headers.rb
data/PostInstall.txt ADDED
@@ -0,0 +1,7 @@
1
+
2
+ For more information on scbi_headers, see http://scbi_headers.rubyforge.org
3
+
4
+ NOTE: Change this information in PostInstall.txt
5
+ You can also delete it if you don't want it.
6
+
7
+
data/README.rdoc ADDED
@@ -0,0 +1,114 @@
1
+ = scbi_headers
2
+
3
+ * http://www.scbi.uma.es/downloads
4
+
5
+ == DESCRIPTION:
6
+
7
+ scbi_headers is a gem that provides consistent text headers for command line applications.
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ Can show the following information
12
+
13
+ * Corporate infomation
14
+ * Application name
15
+ * Version
16
+ * Description
17
+ * Authors
18
+ * Articles to be referenced
19
+
20
+ == SYNOPSIS:
21
+
22
+ This sample code:
23
+
24
+ require 'scbi_headers'
25
+
26
+
27
+ @header = ScbiHeader.new('SAMPLE_PROGRAM','101')
28
+
29
+ @header.description="A long description for this program. It may include a few lines of text. In such cases, a word based wrap will be applied."
30
+
31
+ @header.copyright='2012'
32
+
33
+ @header.authors<< "Dario Guerrero"
34
+ @header.authors<< "Other"
35
+
36
+ @header.articles<< "Article one: with one description line"
37
+ @header.articles<< "Article two: with one description line"
38
+
39
+ # The main title can also be changed:
40
+
41
+ @header.title=[]
42
+ @header.title << "SuperComputing and BioInformatics - SCBI"
43
+ @header.title << "University of Malaga - Spain"
44
+ @header.title << "http://www.scbi.uma.es"
45
+
46
+ # To output the header
47
+ puts @header
48
+
49
+
50
+ Will produce the following output:
51
+
52
+ #==============================================================================#
53
+ # SuperComputing and BioInformatics - SCBI #
54
+ # University of Malaga - Spain #
55
+ # http://www.scbi.uma.es #
56
+ #------------------------------------------------------------------------------#
57
+ # #
58
+ # SAMPLE_PROGRAM - version: 101 - (c) 2012 #
59
+ # #
60
+ #------------------------------------------------------------------------------#
61
+ # #
62
+ # A long description for this program. It may include a few lines of text. In #
63
+ # such cases, a word based wrap will be applied. #
64
+ # #
65
+ #------------------------------------------------------------------------------#
66
+ # #
67
+ # Authors #
68
+ # -Dario Guerrero #
69
+ # -Other #
70
+ #------------------------------------------------------------------------------#
71
+ # #
72
+ # **NOTE: If you find this program useful, please cite the following articles: #
73
+ # #
74
+ # -Article one: with one description line #
75
+ # -Article two: with one description line #
76
+ #==============================================================================#
77
+
78
+
79
+
80
+ == REQUIREMENTS:
81
+
82
+ None
83
+
84
+ == INSTALL:
85
+
86
+ Common install with gem install:
87
+
88
+ gem install scbi_headers
89
+
90
+ == LICENSE:
91
+
92
+ (The MIT License)
93
+
94
+ Copyright (c) 2012 Dario Guerrero
95
+
96
+ Permission is hereby granted, free of charge, to any person obtaining
97
+ a copy of this software and associated documentation files (the
98
+ 'Software'), to deal in the Software without restriction, including
99
+ without limitation the rights to use, copy, modify, merge, publish,
100
+ distribute, sublicense, and/or sell copies of the Software, and to
101
+ permit persons to whom the Software is furnished to do so, subject to
102
+ the following conditions:
103
+
104
+ The above copyright notice and this permission notice shall be
105
+ included in all copies or substantial portions of the Software.
106
+
107
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
108
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
109
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
110
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
111
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
112
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
113
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
114
+
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/scbi_headers'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'scbi_headers' do
14
+ self.developer 'Dario Guerrero', 'dariogf@scbi.uma.es'
15
+ # self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
16
+ self.rubyforge_name = self.name # TODO this is default value
17
+ # self.extra_deps = [['activesupport','>= 2.0.2']]
18
+
19
+ end
20
+
21
+ require 'newgem/tasks'
22
+ Dir['tasks/**/*.rake'].each { |t| load t }
23
+
24
+ # TODO - want other tests/tasks run by default? Add them to the list
25
+ # remove_task :default
26
+ # task :default => [:spec, :features]
@@ -0,0 +1,166 @@
1
+
2
+ # A class to print information headers in all command line applications of SCBI
3
+
4
+ class ScbiHeader
5
+
6
+ attr_accessor :description,:l1_separator_char,:l2_separator_char,:program_name,:program_version,:width
7
+
8
+ attr_accessor :title,:authors, :articles, :copyright
9
+
10
+ def initialize(program_name, program_version, use_default_title = true, width = 80)
11
+ @res=[]
12
+ @comment_char='#'
13
+ @l1_separator_char='='
14
+ @l2_separator_char='*'
15
+ @l3_separator_char='-'
16
+
17
+ @title=[]
18
+
19
+ @copyright=''
20
+
21
+ if use_default_title
22
+ default_title
23
+ end
24
+
25
+ @authors=[]
26
+ @articles=[]
27
+
28
+ @program_name=program_name
29
+ @description=description
30
+ @program_version=program_version
31
+ @width=width
32
+
33
+ end
34
+
35
+ def default_title
36
+
37
+ @title << "SuperComputing and BioInformatics - SCBI"
38
+ @title << "University of Malaga - Spain"
39
+ @title << "http://www.scbi.uma.es"
40
+ end
41
+
42
+ def to_s
43
+ inspect
44
+ end
45
+
46
+ def inspect
47
+ populate_header
48
+ @res.join("\n")
49
+ end
50
+
51
+ private
52
+
53
+
54
+ # build the real string into @res
55
+ def populate_header()
56
+
57
+ separator(@l1_separator_char)
58
+
59
+ @title.each do |title_line|
60
+ centered_line(title_line)
61
+ end
62
+ separator(@l3_separator_char)
63
+ empty_line
64
+
65
+ name_line="#{@program_name} - version: #{@program_version}"
66
+
67
+ if !@copyright.empty?
68
+ name_line+=" - (c) #{@copyright}"
69
+ end
70
+
71
+ left_line(name_line)
72
+
73
+ empty_line
74
+
75
+ separator(@l3_separator_char)
76
+ empty_line
77
+
78
+ wrap(@description,@width).each do |line|
79
+ left_line(line)
80
+ end
81
+ empty_line
82
+
83
+ if !@authors.empty?
84
+ separator(@l3_separator_char)
85
+
86
+ empty_line
87
+ left_line('Authors')
88
+
89
+ @authors.each do |line|
90
+ left_line(' '*6+'-'+line)
91
+ end
92
+ end
93
+
94
+
95
+ if !@articles.empty?
96
+ separator(@l3_separator_char)
97
+
98
+ empty_line
99
+ left_line('**NOTE: If you find this program useful, please cite the following articles:')
100
+ empty_line
101
+ @articles.each do |line|
102
+ left_line(' '*6+'-'+line)
103
+ end
104
+ end
105
+
106
+ separator(@l1_separator_char)
107
+
108
+
109
+ end
110
+
111
+
112
+ # make a simple wrap of complete words
113
+ def wrap(s,width)
114
+ res=[]
115
+ lines=s.split("\n")
116
+
117
+ lines.each do |input_line|
118
+ words=input_line.split(/\s/)
119
+ line=''
120
+ words.each do |w|
121
+ if (line.length+w.length)>(width-4)
122
+ res << line
123
+ line=''
124
+ end
125
+
126
+ line << ' '+w
127
+
128
+ end
129
+
130
+ if !line.empty?
131
+ res << line
132
+ line=''
133
+ end
134
+
135
+ end
136
+
137
+ res
138
+ end
139
+
140
+ def separator(level_char)
141
+ @res << @comment_char + level_char*(@width-2)+@comment_char
142
+
143
+ end
144
+
145
+ def add_line(line)
146
+ @res << @comment_char + ' '+line+' '+@comment_char
147
+ end
148
+
149
+ def centered_line(line)
150
+ add_line(line.center(@width-4))
151
+ end
152
+
153
+ def empty_line()
154
+ centered_line('')
155
+ end
156
+
157
+ def left_line(line)
158
+ add_line(line.ljust(@width-4))
159
+ end
160
+
161
+
162
+ def right_line(line)
163
+ add_line(line.rjust(@width-4))
164
+ end
165
+
166
+ end
@@ -0,0 +1,8 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'scbi_headers/scbi_header'
5
+
6
+ module ScbiHeaders
7
+ VERSION = '0.0.1'
8
+ end
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/scbi_headers.rb'}"
9
+ puts "Loading scbi_headers gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,3 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/scbi_headers'
@@ -0,0 +1,24 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestScbiHeaders < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @header = ScbiHeader.new('SAMPLE_PROGRAM','101')
7
+ @header.description="A long description for this program. It may include a few lines of text. In such cases, a word based wrap will be applied."
8
+
9
+ @header.copyright='2012'
10
+
11
+ @header.authors<< "Dario Guerrero"
12
+ @header.authors<< "Other"
13
+
14
+ @header.articles<< "Article one: with one description line"
15
+ @header.articles<< "Article two: with one description line"
16
+
17
+ puts @header
18
+ end
19
+
20
+ def test_truth
21
+
22
+ assert true
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scbi_headers
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Dario Guerrero
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-05-28 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.8.0
24
+ type: :development
25
+ version_requirements: *id001
26
+ description: scbi_headers is a gem that provides consistent text headers for command line applications.
27
+ email:
28
+ - dariogf@scbi.uma.es
29
+ executables: []
30
+
31
+ extensions: []
32
+
33
+ extra_rdoc_files:
34
+ - History.txt
35
+ - Manifest.txt
36
+ - PostInstall.txt
37
+ files:
38
+ - History.txt
39
+ - lib/scbi_headers/scbi_header.rb
40
+ - lib/scbi_headers.rb
41
+ - Manifest.txt
42
+ - PostInstall.txt
43
+ - Rakefile
44
+ - README.rdoc
45
+ - script/console
46
+ - script/destroy
47
+ - script/generate
48
+ - test/test_helper.rb
49
+ - test/test_scbi_headers.rb
50
+ homepage: http://www.scbi.uma.es/downloads
51
+ licenses: []
52
+
53
+ post_install_message:
54
+ rdoc_options:
55
+ - --main
56
+ - README.rdoc
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: "0"
71
+ requirements: []
72
+
73
+ rubyforge_project: scbi_headers
74
+ rubygems_version: 1.7.2
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: scbi_headers is a gem that provides consistent text headers for command line applications.
78
+ test_files:
79
+ - test/test_helper.rb
80
+ - test/test_scbi_headers.rb