File: Rakefile

package info (click to toggle)
jq 1.4-2.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 1,216 kB
  • sloc: ansic: 9,370; yacc: 588; lex: 175; makefile: 95; sh: 56; python: 21
file content (64 lines) | stat: -rw-r--r-- 1,710 bytes parent folder | download | duplicates (3)
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
require 'yaml'
require 'json'
require 'ronn'
require 'tempfile'
require 'yaml'

def load_manual
  YAML::ENGINE.yamler = 'syck'
  YAML::load(File.open("content/3.manual/manual.yml"))
end

task :manpage do
  Tempfile.open "manpage" do |f|
    manual = load_manual
    f.puts manual['manpage_intro']
    f.puts manual['body']
    manual['sections'].each do |section|
      
      f.puts "## #{section['title'].upcase}\n"
      f.puts section['body']
      f.puts ""
      (section['entries'] || []).each do |entry|
        f.puts "### #{entry['title']}\n"
        f.puts entry['body']
        f.puts ""
        (entry['examples'] || []).each do |example|
          f.puts "    jq '#{example['program']}'"
          f.puts "       #{example['input']}"
          f.puts "    => #{example['output'].join(", ")}"
          f.puts
        end
      end
      f.puts ""
    end
    f.puts manual['manpage_epilogue']
    f.close
    puts Ronn::Document.new(f.path).convert('roff').gsub(/<\/?code>/,"")
  end  
end

task :manpage_default => ["default_manpage.md"] do
  puts Ronn::Document.new("default_manpage.md").convert('roff').gsub(/<\/?code>/,"")
end

task :mantests do
  load_manual['sections'].each do |section|
    (section['entries'] || []).each do |entry|
      (entry['examples'] || []).each do |example|
        puts example['program'].gsub("\n", " ")
        puts example['input']
        example['output'].each do |s| puts s end
        puts
      end
    end
  end
end

directory "output/download/source"
task :tarball => ["output/download/source"] do
  sh "cd ..; ./configure && make dist && make distclean"
  sh "cp ../jq-*.tar.gz output/download/source"
end

task :dist => [:build, :binaries, :tarball]