Module: Gemstub

Defined in:
lib/gemstub.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.test_frameworkObject

Returns the value of attribute test_framework.



24
25
26
# File 'lib/gemstub.rb', line 24

def test_framework
  @test_framework
end

Class Method Details

.gem_spec(&block) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/gemstub.rb', line 58

def gem_spec(&block)
  @gem_spec = Gem::Specification.new do |s|
    s.name = File.basename(FileUtils.pwd)
    s.version = "0.0.1"
    s.summary = s.name
    s.author = (ENV["USERNAME"] || ENV["USER"])
    s.description = "#{s.name} was developed by: #{s.author}"
    s.email = ""
    s.homepage = ""
    s.files = FileList['lib/**/*.*', 'LICENSE', 'bin/**/*.*']
    s.require_paths = ['lib']
    s.bindir = 'bin'
    s.extra_rdoc_files = ['LICENSE']
    yield s
  end

  # rake package
  Rake::GemPackageTask.new(@gem_spec) do |pkg|
    pkg.need_zip = false
    pkg.need_tar = false
    rm_f FileList['pkg/**/*.*']
  end

  desc 'regenerate the gemspec'
  task :gemspec do
    @gem_spec.version = "#{@gem_spec.version}.#{Time.now.strftime('%Y%m%d%H%M%S')}"
    File.open(File.join("#{@gem_spec.name}.gemspec"), 'w') {|f| f.puts @gem_spec.to_ruby}
  end

  desc "Install the gem"
  task :install => [:package] do |t|
    sudo = ENV['SUDOLESS'] == 'true' || RUBY_PLATFORM =~ /win32|cygwin/ ? '' : 'sudo'
    puts `#{sudo} gem install #{File.join("pkg", @gem_spec.name)}-#{@gem_spec.version}.gem --no-update-sources --no-ri --no-rdoc`
  end

  desc "Release the gem"
  task :release => :install do |t|
    gem_pkg = File.join("pkg", "#{@gem_spec.name}-#{@gem_spec.version}.gem")
    system "gem push #{gem_pkg}"
  end
  
  # task :readme do
  #   txt = File.read(File.join(FileUtils.pwd, 'README.textile'))
  #   plain = File.join(FileUtils.pwd, 'README')
  # 
  #   # txt.gsub!(/[\s](@\S+@)[\s]/, "<tt>#{$1}</tt>")
  #   txt.scan(/[\s]@(\S+)@[\s|\.]/).flatten.each do |word|
  #     # puts "replacing: @#{word}@ w/ <tt>#{word}</tt>"
  #     txt.gsub!("@#{word}@", "<tt>#{word}</tt>")
  #   end
  # 
  #   ['h1', 'h2', 'h3', 'h4'].each_with_index do |h, i|
  #     txt.scan(/(#{h}.\s)/).flatten.each do |word|
  #       eq = '=' * (i + 1)
  #       # puts "replacing: '#{word}' w/ #{eq}"
  #       txt.gsub!(word, eq)
  #     end
  #   end
  # 
  #   ['<pre><code>', '</code></pre>'].each do |h|
  #     txt.scan(/(#{h}.*$)/).flatten.each do |word|
  #       # puts "replacing: '#{word}' with nothing"
  #       txt.gsub!(word, '')
  #     end
  #   end
  # 
  #   txt.gsub!("\n\n\n", "\n\n")
  #   File.open(plain, 'w') {|f| f.write txt}
  # end

end

.rdoc(&block) ⇒ Object

gem_spec



130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/gemstub.rb', line 130

def rdoc(&block)
  Rake::RDocTask.new do |rd|
    rd.rdoc_files = Dir.glob(File.join('lib', '**', '*.rb'))
    rd.rdoc_files << 'LICENSE'
    rd.rdoc_dir = "doc"
    rd.options << "--line-numbers"
    rd.options << "--inline-source"
    rd.title = "content_o_matic"
    yield rd if block_given?
  end
  
  task :doc => [:rerdoc]
end

.rspec?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/gemstub.rb', line 26

def rspec?
  test_framework == :rspec
end

.test_unit?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/gemstub.rb', line 30

def test_unit?
  test_framework == :test_unit
end