formatador 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. data/Rakefile +131 -32
  2. data/formatador.gemspec +72 -43
  3. data/lib/formatador.rb +14 -1
  4. metadata +8 -11
  5. data/.document +0 -5
  6. data/.gitignore +0 -21
  7. data/VERSION +0 -1
data/Rakefile CHANGED
@@ -1,48 +1,147 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
+ require 'date'
3
4
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "formatador"
8
- gem.summary = %Q{Ruby STDOUT text formatting}
9
- gem.description = %Q{STDOUT text formatting}
10
- gem.email = "wbeary@engineyard.com"
11
- gem.homepage = "http://github.com/geemus/formatador"
12
- gem.authors = ["Wesley Beary"]
13
- # gem.add_development_dependency "shindo", ">= 0"
14
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
- end
16
- rescue LoadError
17
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
5
+ #############################################################################
6
+ #
7
+ # Helper functions
8
+ #
9
+ #############################################################################
10
+
11
+ def name
12
+ @name ||= Dir['*.gemspec'].first.split('.').first
18
13
  end
19
14
 
20
- require 'shindo/rake'
21
- Shindo::Rake.new
15
+ def version
16
+ line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
17
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
18
+ end
22
19
 
23
- begin
24
- require 'rcov/rcovtask'
25
- Rcov::RcovTask.new do |tests|
26
- tests.libs << 'tests'
27
- tests.pattern = 'tests/**/*_tests.rb'
28
- tests.verbose = true
29
- end
30
- rescue LoadError
31
- task :rcov do
32
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
33
- end
20
+ def date
21
+ Date.today.to_s
34
22
  end
35
23
 
36
- task :tests => :check_dependencies
24
+ def rubyforge_project
25
+ name
26
+ end
37
27
 
38
- task :default => :tests
28
+ def gemspec_file
29
+ "#{name}.gemspec"
30
+ end
31
+
32
+ def gem_file
33
+ "#{name}-#{version}.gem"
34
+ end
35
+
36
+ def replace_header(head, header_name)
37
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
38
+ end
39
+
40
+ #############################################################################
41
+ #
42
+ # Standard tasks
43
+ #
44
+ #############################################################################
45
+
46
+ task :default => :test
47
+
48
+ require 'rake/testtask'
49
+ Rake::TestTask.new(:test) do |test|
50
+ test.libs << 'lib' << 'test'
51
+ test.pattern = 'test/**/test_*.rb'
52
+ test.verbose = true
53
+ end
54
+
55
+ desc "Generate RCov test coverage and open in your browser"
56
+ task :coverage do
57
+ require 'rcov'
58
+ sh "rm -fr coverage"
59
+ sh "rcov test/test_*.rb"
60
+ sh "open coverage/index.html"
61
+ end
39
62
 
40
63
  require 'rake/rdoctask'
41
64
  Rake::RDocTask.new do |rdoc|
42
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
43
-
44
65
  rdoc.rdoc_dir = 'rdoc'
45
- rdoc.title = "formatador #{version}"
66
+ rdoc.title = "#{name} #{version}"
46
67
  rdoc.rdoc_files.include('README*')
47
68
  rdoc.rdoc_files.include('lib/**/*.rb')
48
69
  end
70
+
71
+ desc "Open an irb session preloaded with this library"
72
+ task :console do
73
+ sh "irb -rubygems -r ./lib/#{name}.rb"
74
+ end
75
+
76
+ #############################################################################
77
+ #
78
+ # Custom tasks (add your own tasks here)
79
+ #
80
+ #############################################################################
81
+
82
+
83
+
84
+ #############################################################################
85
+ #
86
+ # Packaging tasks
87
+ #
88
+ #############################################################################
89
+
90
+ task :release => :build do
91
+ unless `git branch` =~ /^\* master$/
92
+ puts "You must be on the master branch to release!"
93
+ exit!
94
+ end
95
+ sh "sudo gem install pkg/#{name}-#{version}.gem"
96
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
97
+ sh "git tag v#{version}"
98
+ sh "git push origin master"
99
+ sh "git push origin v#{version}"
100
+ sh "gem push pkg/#{name}-#{version}.gem"
101
+ end
102
+
103
+ task :build => :gemspec do
104
+ sh "mkdir -p pkg"
105
+ sh "gem build #{gemspec_file}"
106
+ sh "mv #{gem_file} pkg"
107
+ end
108
+
109
+ task :gemspec => :validate do
110
+ # read spec file and split out manifest section
111
+ spec = File.read(gemspec_file)
112
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
113
+
114
+ # replace name version and date
115
+ replace_header(head, :name)
116
+ replace_header(head, :version)
117
+ replace_header(head, :date)
118
+ #comment this out if your rubyforge_project has a different name
119
+ replace_header(head, :rubyforge_project)
120
+
121
+ # determine file list from git ls-files
122
+ files = `git ls-files`.
123
+ split("\n").
124
+ sort.
125
+ reject { |file| file =~ /^\./ }.
126
+ reject { |file| file =~ /^(rdoc|pkg)/ }.
127
+ map { |file| " #{file}" }.
128
+ join("\n")
129
+
130
+ # piece file back together and write
131
+ manifest = " s.files = %w[\n#{files}\n ]\n"
132
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
133
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
134
+ puts "Updated #{gemspec_file}"
135
+ end
136
+
137
+ task :validate do
138
+ libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
139
+ unless libfiles.empty?
140
+ puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
141
+ exit!
142
+ end
143
+ unless Dir['VERSION*'].empty?
144
+ puts "A `VERSION` file at root level violates Gem best practices."
145
+ exit!
146
+ end
147
+ end
@@ -1,47 +1,76 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
1
+ ## This is the rakegem gemspec template. Make sure you read and understand
2
+ ## all of the comments. Some sections require modification, and others can
3
+ ## be deleted if you don't need them. Once you understand the contents of
4
+ ## this file, feel free to delete any comments that begin with two hash marks.
5
+ ## You can find comprehensive Gem::Specification documentation, at
6
+ ## http://docs.rubygems.org/read/chapter/20
6
7
  Gem::Specification.new do |s|
7
- s.name = %q{formatador}
8
- s.version = "0.0.13"
9
-
8
+ s.specification_version = 2 if s.respond_to? :specification_version=
10
9
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Wesley Beary"]
12
- s.date = %q{2010-04-13}
13
- s.description = %q{STDOUT text formatting}
14
- s.email = %q{wbeary@engineyard.com}
15
- s.extra_rdoc_files = [
16
- "README.rdoc"
17
- ]
18
- s.files = [
19
- ".document",
20
- ".gitignore",
21
- "README.rdoc",
22
- "Rakefile",
23
- "VERSION",
24
- "formatador.gemspec",
25
- "lib/formatador.rb",
26
- "lib/formatador/progressbar.rb",
27
- "lib/formatador/table.rb",
28
- "tests/formatador_tests.rb",
29
- "tests/tests_helper.rb"
30
- ]
31
- s.homepage = %q{http://github.com/geemus/formatador}
10
+ s.rubygems_version = '1.3.5'
11
+
12
+ ## Leave these as is they will be modified for you by the rake gemspec task.
13
+ ## If your rubyforge_project name is different, then edit it and comment out
14
+ ## the sub! line in the Rakefile
15
+ s.name = 'formatador'
16
+ s.version = '0.0.14'
17
+ s.date = '2010-04-26'
18
+ s.rubyforge_project = 'formatador'
19
+
20
+ ## Make sure your summary is short. The description may be as long
21
+ ## as you like.
22
+ s.summary = "Ruby STDOUT text formatting"
23
+ s.description = "STDOUT text formatting"
24
+
25
+ ## List the primary authors. If there are a bunch of authors, it's probably
26
+ ## better to set the email to an email list or something. If you don't have
27
+ ## a custom homepage, consider using your GitHub URL or the like.
28
+ s.authors = ["geemus (Wesley Beary)"]
29
+ s.email = 'geemus@gmail.com'
30
+ s.homepage = 'http://github.com/geemus/NAME'
31
+
32
+ ## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
33
+ ## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
34
+ s.require_paths = %w[lib]
35
+
36
+ ## This sections is only necessary if you have C extensions.
37
+ # s.require_paths << 'ext'
38
+ # s.extensions = %w[ext/extconf.rb]
39
+
40
+ ## If your gem includes any executables, list them here.
41
+ # s.executables = ["name"]
42
+ # s.default_executable = 'name'
43
+
44
+ ## Specify any RDoc options here. You'll want to add your README and
45
+ ## LICENSE files to the extra_rdoc_files list.
32
46
  s.rdoc_options = ["--charset=UTF-8"]
33
- s.require_paths = ["lib"]
34
- s.rubygems_version = %q{1.3.6}
35
- s.summary = %q{Ruby STDOUT text formatting}
36
-
37
- if s.respond_to? :specification_version then
38
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
39
- s.specification_version = 3
40
-
41
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
42
- else
43
- end
44
- else
45
- end
46
- end
47
+ s.extra_rdoc_files = %w[README.rdoc]
48
+
49
+ ## List your runtime dependencies here. Runtime dependencies are those
50
+ ## that are needed for an end user to actually USE your code.
51
+ # s.add_dependency('DEPNAME', [">= 1.1.0", "< 2.0.0"])
47
52
 
53
+ ## List your development dependencies here. Development dependencies are
54
+ ## those that are only needed during development
55
+ # s.add_development_dependency('DEVDEPNAME', [">= 1.1.0", "< 2.0.0"])
56
+
57
+ ## Leave this section as-is. It will be automatically generated from the
58
+ ## contents of your Git repository via the gemspec task. DO NOT REMOVE
59
+ ## THE MANIFEST COMMENTS, they are used as delimiters by the task.
60
+ # = MANIFEST =
61
+ s.files = %w[
62
+ README.rdoc
63
+ Rakefile
64
+ formatador.gemspec
65
+ lib/formatador.rb
66
+ lib/formatador/progressbar.rb
67
+ lib/formatador/table.rb
68
+ tests/formatador_tests.rb
69
+ tests/tests_helper.rb
70
+ ]
71
+ # = MANIFEST =
72
+
73
+ ## Test files will be grabbed from the file list. Make sure the path glob
74
+ ## matches what you actually use.
75
+ s.test_files = s.files.select { |path| path =~ /^[spec|tests]\/.*_[spec|tests]\.rb/ }
76
+ end
@@ -3,6 +3,8 @@ require File.join(File.dirname(__FILE__), 'formatador', 'progressbar')
3
3
 
4
4
  class Formatador
5
5
 
6
+ VERSION = '0.0.14'
7
+
6
8
  STYLES = {
7
9
  :"\/" => "0",
8
10
  :reset => "0",
@@ -70,6 +72,13 @@ class Formatador
70
72
  nil
71
73
  end
72
74
 
75
+ def display_lines(lines = [])
76
+ for line in lines
77
+ display_line(line)
78
+ end
79
+ nil
80
+ end
81
+
73
82
  def parse(string)
74
83
  if STDOUT.tty?
75
84
  string.gsub(PARSE_REGEX) { "\e[#{STYLES[$1.to_sym]}m" }.gsub(INDENT_REGEX) { indentation }
@@ -94,7 +103,7 @@ class Formatador
94
103
  nil
95
104
  end
96
105
 
97
- %w{display display_line display_table parse redisplay redisplay_progressbar}.each do |method|
106
+ %w{display display_line display_lines display_table parse redisplay redisplay_progressbar}.each do |method|
98
107
  eval <<-DEF
99
108
  def self.#{method}(*args, &block)
100
109
  new.#{method}(*args, &block)
@@ -107,5 +116,9 @@ end
107
116
  if __FILE__ == $0
108
117
 
109
118
  Formatador.display_line("[negative]Formatador![/]")
119
+ Formatador.display_lines([
120
+ 'one',
121
+ 'two'
122
+ ])
110
123
 
111
124
  end
metadata CHANGED
@@ -5,21 +5,21 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 13
9
- version: 0.0.13
8
+ - 14
9
+ version: 0.0.14
10
10
  platform: ruby
11
11
  authors:
12
- - Wesley Beary
12
+ - geemus (Wesley Beary)
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-13 00:00:00 -07:00
17
+ date: 2010-04-26 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
21
21
  description: STDOUT text formatting
22
- email: wbeary@engineyard.com
22
+ email: geemus@gmail.com
23
23
  executables: []
24
24
 
25
25
  extensions: []
@@ -27,11 +27,8 @@ extensions: []
27
27
  extra_rdoc_files:
28
28
  - README.rdoc
29
29
  files:
30
- - .document
31
- - .gitignore
32
30
  - README.rdoc
33
31
  - Rakefile
34
- - VERSION
35
32
  - formatador.gemspec
36
33
  - lib/formatador.rb
37
34
  - lib/formatador/progressbar.rb
@@ -39,7 +36,7 @@ files:
39
36
  - tests/formatador_tests.rb
40
37
  - tests/tests_helper.rb
41
38
  has_rdoc: true
42
- homepage: http://github.com/geemus/formatador
39
+ homepage: http://github.com/geemus/NAME
43
40
  licenses: []
44
41
 
45
42
  post_install_message:
@@ -63,10 +60,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
60
  version: "0"
64
61
  requirements: []
65
62
 
66
- rubyforge_project:
63
+ rubyforge_project: formatador
67
64
  rubygems_version: 1.3.6
68
65
  signing_key:
69
- specification_version: 3
66
+ specification_version: 2
70
67
  summary: Ruby STDOUT text formatting
71
68
  test_files: []
72
69
 
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.13