Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 88 lines (76 sloc) 3.104 kB
0030580 @arthurgeek Added Rakefile and gemspec
arthurgeek authored
1 require 'rake'
2
db14b86 @fnando Removed rubigen; using main instead. Refactored generator code
fnando authored
3 PKG_FILES = %w(Rakefile kitabu.gemspec README.markdown) + Dir["{bin,lib,templates}/**/*"]
0030580 @arthurgeek Added Rakefile and gemspec
arthurgeek authored
4
5 spec = Gem::Specification.new do |s|
6 s.name = "kitabu"
db14b86 @fnando Removed rubigen; using main instead. Refactored generator code
fnando authored
7 s.version = "0.3.0"
6cd5eee @fnando Changed gem description. Changed install instructions.
fnando authored
8 s.summary = "A framework for creating e-books from Markdown/Textile text markup using Ruby."
0030580 @arthurgeek Added Rakefile and gemspec
arthurgeek authored
9 s.authors = ["Nando Vieira"]
6cd5eee @fnando Changed gem description. Changed install instructions.
fnando authored
10 s.email = ["fnando.vieira@gmail.com"]
0030580 @arthurgeek Added Rakefile and gemspec
arthurgeek authored
11 s.homepage = "http://github.com/fnando/kitabu"
12 s.description = "A framework for creating e-books from Markdown/Textile text markup using Ruby. Using the Prince PDF generator, you'll be able to get high quality PDFs. Mac users that have Textmate installed can have source code highlighted with his favorite theme."
13 s.has_rdoc = false
14 s.files = PKG_FILES
15 s.bindir = "bin"
16 s.executables = "kitabu"
17
18 # Dependencies
19 s.add_dependency "discount"
20 s.add_dependency "hpricot"
21 s.add_dependency "unicode"
db14b86 @fnando Removed rubigen; using main instead. Refactored generator code
fnando authored
22 s.add_dependency "main"
23
0030580 @arthurgeek Added Rakefile and gemspec
arthurgeek authored
24 # Requirements
25 s.requirements << "Install the Oniguruma RE library and ultraviolet gem to get Syntax Highlighting (only for TextMate users)"
26 end
27
28 namespace :gem do
29 # Thanks to the Merb project for this code.
30 desc "Update Github Gemspec"
db14b86 @fnando Removed rubigen; using main instead. Refactored generator code
fnando authored
31 task :update_gemspec do
32 skip_fields = %w(new_platform original_platform specification_version loaded required_ruby_version rubygems_version platform )
33
34 result = "# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!\n"
35 result << "# RUN : 'rake gem:update_gemspec'\n\n"
36 result << "Gem::Specification.new do |s|\n"
37
38 spec.instance_variables.each do |ivar|
39 value = spec.instance_variable_get(ivar)
40 name = ivar.split("@").last
cd30099 @fnando Now markup files can be created outside a chapter folder.
fnando authored
41 next if name == "date"
f54b478 @fnando s.date is now updated as Time.now
fnando authored
42
db14b86 @fnando Removed rubigen; using main instead. Refactored generator code
fnando authored
43 if name == 'version'
44 base_file = File.join(File.dirname(__FILE__), 'lib/kitabu/base.rb')
45 contents = File.read(base_file)
46 contents.gsub!(/VERSION = "[\d\.]+"/sim, %(VERSION = "#{value}"))
47 File.open(base_file, 'w+') do |f|
48 f << contents
49 end
50 end
f54b478 @fnando s.date is now updated as Time.now
fnando authored
51
db14b86 @fnando Removed rubigen; using main instead. Refactored generator code
fnando authored
52 next if skip_fields.include?(name) || value.nil? || value == "" || (value.respond_to?(:empty?) && value.empty?)
53 if name == "dependencies"
54 value.each do |d|
55 dep, *ver = d.to_s.split(" ")
56 result << " s.add_dependency #{dep.inspect}, #{ver.join(" ").inspect.gsub(/[()]/, "").gsub(", runtime", "")}\n"
57 end
58 else
59 case value
60 when Array
61 value = name != "files" ? value.inspect : value.inspect.split(",").join(",\n")
62 when FalseClass
63 when TrueClass
64 when Fixnum
65 when String
66 value = value.inspect
0030580 @arthurgeek Added Rakefile and gemspec
arthurgeek authored
67 else
db14b86 @fnando Removed rubigen; using main instead. Refactored generator code
fnando authored
68 value = value.to_s.inspect
0030580 @arthurgeek Added Rakefile and gemspec
arthurgeek authored
69 end
db14b86 @fnando Removed rubigen; using main instead. Refactored generator code
fnando authored
70 result << " s.#{name} = #{value}\n"
0030580 @arthurgeek Added Rakefile and gemspec
arthurgeek authored
71 end
72 end
db14b86 @fnando Removed rubigen; using main instead. Refactored generator code
fnando authored
73
74 result << "end"
75 File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w"){|f| f << result}
76 end
77
78 desc "Build gem"
79 task :build => :update_gemspec do
80 system "rm *.gem"
81 system "gem build #{spec.instance_variable_get('@name')}.gemspec"
82 end
83
84 desc "Install gem"
85 task :install => :build do
86 system "sudo gem install #{spec.instance_variable_get('@name')}"
87 end
0030580 @arthurgeek Added Rakefile and gemspec
arthurgeek authored
88 end
Something went wrong with that request. Please try again.