File: rakefile

package info (click to toggle)
ruby-feedtools 0.2.29%2Bdfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,008 kB
  • sloc: ruby: 18,815; sql: 39; makefile: 13
file content (207 lines) | stat: -rw-r--r-- 5,559 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/contrib/rubyforgepublisher'

require File.join(File.dirname(__FILE__), 'lib/feed_tools', 'version')

PKG_NAME      = 'feedtools'
PKG_VERSION   = FeedTools::FEED_TOOLS_VERSION::STRING
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"

RELEASE_NAME  = "REL #{PKG_VERSION}"

RUBY_FORGE_PROJECT = PKG_NAME
RUBY_FORGE_USER    = "sporkmonger"
RUBY_FORGE_PATH    = "/var/www/gforge-projects/#{RUBY_FORGE_PROJECT}"

PKG_FILES = FileList[
    "lib/**/*", "test/**/*", "examples/**/*", "doc/**/*", "db/**/*",
    "[A-Z]*", "install.rb", "rakefile"
].exclude(/\bCVS\b|~$/).exclude(/database\.yml/).exclude(/\._.*/)

desc "Default Task"
task :default => [ :test_all ]

# Run the unit tests

Rake::TestTask.new("test_all") { |t|
  t.libs << "test"
  t.test_files = FileList['test/unit/*_test.rb']
  t.verbose = true
}
Rake::TestTask.new("amp_test") { |t|
  t.libs << "test"
  t.test_files = FileList['test/unit/amp_test.rb']
  t.verbose = true
}
Rake::TestTask.new("atom_test") { |t|
  t.libs << "test"
  t.test_files = FileList['test/unit/atom_test.rb']
  t.verbose = true
}
Rake::TestTask.new("cache_test") { |t|
  t.libs << "test"
  t.test_files = FileList['test/unit/cache_test.rb']
  t.verbose = true
}
Rake::TestTask.new("cdf_test") { |t|
  t.libs << "test"
  t.test_files = FileList['test/unit/cdf_test.rb']
  t.verbose = true
}
Rake::TestTask.new("encoding_test") { |t|
  t.libs << "test"
  t.test_files = FileList['test/unit/encoding_test.rb']
  t.verbose = true
}
Rake::TestTask.new("generation_test") { |t|
  t.libs << "test"
  t.test_files = FileList['test/unit/generation_test.rb']
  t.verbose = true
}
Rake::TestTask.new("helper_test") { |t|
  t.libs << "test"
  t.test_files = FileList['test/unit/helper_test.rb']
  t.verbose = true
}
Rake::TestTask.new("interface_test") { |t|
  t.libs << "test"
  t.test_files = FileList['test/unit/interface_test.rb']
  t.verbose = true
}
Rake::TestTask.new("nonstandard_test") { |t|
  t.libs << "test"
  t.test_files = FileList['test/unit/nonstandard_test.rb']
  t.verbose = true
}
Rake::TestTask.new("rdf_test") { |t|
  t.libs << "test"
  t.test_files = FileList['test/unit/rdf_test.rb']
  t.verbose = true
}
Rake::TestTask.new("rss_test") { |t|
  t.libs << "test"
  t.test_files = FileList['test/unit/rss_test.rb']
  t.verbose = true
}

# Generate the RDoc documentation

Rake::RDocTask.new { |rdoc|
  rdoc.rdoc_dir = 'doc'
  rdoc.title    = "Feed Tools -- caching system for xml news feeds"
  rdoc.options << '--line-numbers' << '--inline-source' <<
    '--accessor' << 'cattr_accessor=object'
  rdoc.template = "#{ENV['template']}.rb" if ENV['template']
  rdoc.rdoc_files.include('README', 'CHANGELOG')
  rdoc.rdoc_files.include('lib/**/*.rb')
  rdoc.rdoc_files.include('db/**/*.sql')
}

# Create compressed packages

dist_dirs = [ "lib", "test", "db" ]

spec = Gem::Specification.new do |s|
  s.name = PKG_NAME
  s.version = PKG_VERSION
  s.summary = "Parsing, generation, and caching system for xml news feeds."
  s.description = "Implements a simple system for handling xml news feeds with caching."

  s.files = [ "rakefile", "install.rb", "README", "CHANGELOG" ]
  dist_dirs.each do |dir|
    s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if do |item|
      item.include?( "\.svn" ) || item.include?( "database\.yml" )
    end
  end
  
  s.add_dependency('activerecord', '>= 1.10.1')
  s.add_dependency('uuidtools', '>= 1.0.0')
  s.add_dependency('builder', '>= 1.2.4')

  s.require_path = 'lib'
  
  begin
  s.post_install_message = <<-TEXT

    FeedTool's caching schema has changed to allow Feed objects to be
    serialized to the cache.  This should offer some limited speed up
    in some cases.

  TEXT
  rescue Exception
  end

  s.has_rdoc = true
  s.extra_rdoc_files = %w( README )
  s.rdoc_options.concat ['--main',  'README']
  
  s.author = "Bob Aman"
  s.email = "bob@sporkmonger.com"
  s.homepage = "http://sporkmonger.com/projects/feedtools"
  s.rubyforge_project = "feedtools"
end
  
Rake::GemPackageTask.new(spec) do |p|
  p.gem_spec = spec
  p.need_tar = true
  p.need_zip = true
end

task :profile do
  $:.unshift(File.dirname(__FILE__) + '/lib')
  require 'feed_tools'
  puts "Profiling FeedTools #{FeedTools::FEED_TOOLS_VERSION::STRING}..."
  command = 'ruby -rprofile -e \'' +
    '$:.unshift(File.dirname(__FILE__) + "/lib");' +
    'require "feed_tools";' +
    'FeedTools::Feed.open(' +
      '"http://hsivonen.iki.fi/test/unknown-namespace.atom")' +
        '.build_xml("atom", 1.0)\''
  `#{command}`
end

task :lines do
  lines, codelines, total_lines, total_codelines = 0, 0, 0, 0

  for file_name in FileList["lib/**/*.rb"]
    f = File.open(file_name)

    while line = f.gets
      lines += 1
      next if line =~ /^\s*$/
      next if line =~ /^\s*#/
      codelines += 1
    end
    puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
    
    total_lines     += lines
    total_codelines += codelines
    
    lines, codelines = 0, 0
  end

  puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
end


# Publishing ------------------------------------------------------

namespace :publish do
  desc "Publish the API documentation"
  task :api => [ "rdoc" ] do 
    Rake::SshDirPublisher.new(
      "#{RUBY_FORGE_USER}@rubyforge.org",
      "#{RUBY_FORGE_PATH}/",
      "doc"
    ).upload
  end

  desc "Runs all of the publishing tasks"
  task :all => ["publish:api"] do
  end
end