aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/hyperestraier.rb
blob: 65f77195ebc1574c920c0bc9a6ebaa8ca8a77d2e (plain)
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
require 'formula'

class EucjpMecabIpadic < Requirement
  fatal true

  def initialize
    @mecab_ipadic_installed = Formula.factory('mecab-ipadic').installed?
  end

  satisfy { @mecab_ipadic_installed && mecab_dic_charset == 'euc' }

  def message
    if @mecab_ipadic_installed
      <<-EOS.undent
        Hyper Estraier supports only the EUC-JP version of MeCab-IPADIC.
        However, you have installed the #{mecab_dic_charset} version so far.

        You have to reinstall your mecab-ipadic package manually with the
        --with-charset=euc option before resuming the hyperestraier installation,
        or you have to build hyperestraier without MeCab support.

        To reinstall your mecab-ipadic and resume the hyperestraier installation:

            $ brew uninstall mecab-ipadic
            $ brew install mecab-ipadic --with-charset=euc
            $ brew install hyperestraier --enable-mecab

        To build hyperestraier without MeCab support:

            $ brew install hyperestraier
      EOS
    else
      <<-EOS.undent
        An EUC-JP version of MeCab-IPADIC is required. You have to install your
        mecab-ipadic package manually with the --with-charset=euc option before
        resuming the hyperestraier installation, or you have to build hyperestraier
        without MeCab support.

        To install an EUC-JP version of mecab-ipadic and resume the hyperestraier
        installation:

            $ brew install mecab-ipadic --with-charset=euc
            $ brew install hyperestraier --enable-mecab

        To build hyperestraier without MeCab support:

            $ brew install hyperestraier
      EOS
    end
  end

  def mecab_dic_charset
    /^charset:\t(\S+)$/ =~ `mecab -D` && $1
  end
end

class Hyperestraier < Formula
  homepage 'http://fallabs.com/hyperestraier/index.html'
  url 'http://fallabs.com/hyperestraier/hyperestraier-1.4.13.tar.gz'
  sha1 '1094686f457070323083ecf4f89665c564a0c5f0'

  option 'enable-mecab', 'Include MeCab support'

  depends_on 'qdbm'

  if build.include? 'enable-mecab'
    depends_on 'mecab'
    depends_on 'mecab-ipadic'
    depends_on EucjpMecabIpadic
  end

  def install
    args = %W[
      --disable-debug
      --disable-dependency-tracking
      --prefix=#{prefix}
    ]

    args << '--enable-mecab' if build.include? 'enable-mecab'

    system "./configure", *args
    system "make mac"
    system "make check-mac"
    system "make install-mac"
  end

  def test
    system "#{bin}/estcmd version"
  end
end