ferret 0.11.6 → 0.11.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +10 -22
- data/RELEASE_CHANGES +137 -0
- data/RELEASE_NOTES +60 -0
- data/Rakefile +379 -274
- data/TODO +100 -8
- data/bin/ferret-browser +0 -0
- data/ext/BZLIB_blocksort.c +1094 -0
- data/ext/BZLIB_bzlib.c +1578 -0
- data/ext/BZLIB_compress.c +672 -0
- data/ext/BZLIB_crctable.c +104 -0
- data/ext/BZLIB_decompress.c +626 -0
- data/ext/BZLIB_huffman.c +205 -0
- data/ext/BZLIB_randtable.c +84 -0
- data/ext/{api.c → STEMMER_api.c} +7 -10
- data/ext/{libstemmer.c → STEMMER_libstemmer.c} +3 -2
- data/ext/{stem_ISO_8859_1_danish.c → STEMMER_stem_ISO_8859_1_danish.c} +123 -124
- data/ext/{stem_ISO_8859_1_dutch.c → STEMMER_stem_ISO_8859_1_dutch.c} +177 -188
- data/ext/STEMMER_stem_ISO_8859_1_english.c +1117 -0
- data/ext/{stem_ISO_8859_1_finnish.c → STEMMER_stem_ISO_8859_1_finnish.c} +276 -306
- data/ext/STEMMER_stem_ISO_8859_1_french.c +1246 -0
- data/ext/{stem_ISO_8859_1_german.c → STEMMER_stem_ISO_8859_1_german.c} +161 -170
- data/ext/STEMMER_stem_ISO_8859_1_hungarian.c +1230 -0
- data/ext/STEMMER_stem_ISO_8859_1_italian.c +1065 -0
- data/ext/STEMMER_stem_ISO_8859_1_norwegian.c +297 -0
- data/ext/{stem_ISO_8859_1_porter.c → STEMMER_stem_ISO_8859_1_porter.c} +263 -290
- data/ext/{stem_ISO_8859_1_portuguese.c → STEMMER_stem_ISO_8859_1_portuguese.c} +362 -380
- data/ext/STEMMER_stem_ISO_8859_1_spanish.c +1093 -0
- data/ext/STEMMER_stem_ISO_8859_1_swedish.c +307 -0
- data/ext/STEMMER_stem_ISO_8859_2_romanian.c +998 -0
- data/ext/{stem_KOI8_R_russian.c → STEMMER_stem_KOI8_R_russian.c} +244 -245
- data/ext/STEMMER_stem_UTF_8_danish.c +339 -0
- data/ext/{stem_UTF_8_dutch.c → STEMMER_stem_UTF_8_dutch.c} +192 -211
- data/ext/STEMMER_stem_UTF_8_english.c +1125 -0
- data/ext/{stem_UTF_8_finnish.c → STEMMER_stem_UTF_8_finnish.c} +284 -324
- data/ext/STEMMER_stem_UTF_8_french.c +1256 -0
- data/ext/{stem_UTF_8_german.c → STEMMER_stem_UTF_8_german.c} +170 -187
- data/ext/STEMMER_stem_UTF_8_hungarian.c +1234 -0
- data/ext/STEMMER_stem_UTF_8_italian.c +1073 -0
- data/ext/STEMMER_stem_UTF_8_norwegian.c +299 -0
- data/ext/{stem_UTF_8_porter.c → STEMMER_stem_UTF_8_porter.c} +271 -310
- data/ext/STEMMER_stem_UTF_8_portuguese.c +1023 -0
- data/ext/STEMMER_stem_UTF_8_romanian.c +1004 -0
- data/ext/STEMMER_stem_UTF_8_russian.c +694 -0
- data/ext/STEMMER_stem_UTF_8_spanish.c +1097 -0
- data/ext/STEMMER_stem_UTF_8_swedish.c +309 -0
- data/ext/STEMMER_stem_UTF_8_turkish.c +2205 -0
- data/ext/{utilities.c → STEMMER_utilities.c} +100 -68
- data/ext/analysis.c +276 -121
- data/ext/analysis.h +190 -143
- data/ext/api.h +3 -4
- data/ext/array.c +5 -3
- data/ext/array.h +52 -43
- data/ext/bitvector.c +38 -482
- data/ext/bitvector.h +446 -124
- data/ext/bzlib.h +282 -0
- data/ext/bzlib_private.h +503 -0
- data/ext/compound_io.c +23 -22
- data/ext/config.h +21 -11
- data/ext/document.c +43 -40
- data/ext/document.h +31 -21
- data/ext/except.c +20 -38
- data/ext/except.h +89 -76
- data/ext/extconf.rb +3 -2
- data/ext/ferret.c +49 -35
- data/ext/ferret.h +14 -11
- data/ext/field_index.c +262 -0
- data/ext/field_index.h +52 -0
- data/ext/filter.c +11 -10
- data/ext/fs_store.c +65 -47
- data/ext/global.c +245 -165
- data/ext/global.h +252 -54
- data/ext/hash.c +200 -243
- data/ext/hash.h +205 -163
- data/ext/hashset.c +118 -96
- data/ext/hashset.h +110 -82
- data/ext/header.h +19 -19
- data/ext/helper.c +11 -10
- data/ext/helper.h +14 -6
- data/ext/index.c +745 -366
- data/ext/index.h +503 -529
- data/ext/internal.h +1020 -0
- data/ext/lang.c +10 -0
- data/ext/lang.h +35 -15
- data/ext/mempool.c +5 -4
- data/ext/mempool.h +30 -22
- data/ext/modules.h +35 -7
- data/ext/multimapper.c +43 -2
- data/ext/multimapper.h +32 -23
- data/ext/posh.c +0 -0
- data/ext/posh.h +4 -38
- data/ext/priorityqueue.c +10 -12
- data/ext/priorityqueue.h +33 -21
- data/ext/q_boolean.c +22 -9
- data/ext/q_const_score.c +3 -2
- data/ext/q_filtered_query.c +15 -12
- data/ext/q_fuzzy.c +147 -135
- data/ext/q_match_all.c +3 -2
- data/ext/q_multi_term.c +28 -32
- data/ext/q_parser.c +451 -173
- data/ext/q_phrase.c +158 -79
- data/ext/q_prefix.c +16 -18
- data/ext/q_range.c +363 -31
- data/ext/q_span.c +130 -141
- data/ext/q_term.c +21 -21
- data/ext/q_wildcard.c +19 -23
- data/ext/r_analysis.c +369 -242
- data/ext/r_index.c +421 -434
- data/ext/r_qparser.c +142 -92
- data/ext/r_search.c +790 -407
- data/ext/r_store.c +44 -44
- data/ext/r_utils.c +264 -96
- data/ext/ram_store.c +29 -23
- data/ext/scanner.c +895 -0
- data/ext/scanner.h +36 -0
- data/ext/scanner_mb.c +6701 -0
- data/ext/scanner_utf8.c +4415 -0
- data/ext/search.c +210 -87
- data/ext/search.h +556 -488
- data/ext/similarity.c +17 -16
- data/ext/similarity.h +51 -44
- data/ext/sort.c +157 -354
- data/ext/stem_ISO_8859_1_hungarian.h +16 -0
- data/ext/stem_ISO_8859_2_romanian.h +16 -0
- data/ext/stem_UTF_8_hungarian.h +16 -0
- data/ext/stem_UTF_8_romanian.h +16 -0
- data/ext/stem_UTF_8_turkish.h +16 -0
- data/ext/stopwords.c +287 -278
- data/ext/store.c +57 -51
- data/ext/store.h +308 -286
- data/ext/symbol.c +10 -0
- data/ext/symbol.h +23 -0
- data/ext/term_vectors.c +14 -293
- data/ext/threading.h +22 -22
- data/ext/win32.h +12 -4
- data/lib/ferret.rb +2 -1
- data/lib/ferret/browser.rb +1 -1
- data/lib/ferret/field_symbol.rb +94 -0
- data/lib/ferret/index.rb +221 -34
- data/lib/ferret/number_tools.rb +6 -6
- data/lib/ferret/version.rb +3 -0
- data/test/{unit → long_running}/largefile/tc_largefile.rb +1 -1
- data/test/test_helper.rb +7 -2
- data/test/test_installed.rb +1 -0
- data/test/threading/thread_safety_index_test.rb +10 -1
- data/test/threading/thread_safety_read_write_test.rb +4 -7
- data/test/threading/thread_safety_test.rb +0 -0
- data/test/unit/analysis/tc_analyzer.rb +29 -27
- data/test/unit/analysis/tc_token_stream.rb +23 -16
- data/test/unit/index/tc_index.rb +116 -11
- data/test/unit/index/tc_index_reader.rb +27 -27
- data/test/unit/index/tc_index_writer.rb +10 -0
- data/test/unit/index/th_doc.rb +38 -21
- data/test/unit/search/tc_filter.rb +31 -10
- data/test/unit/search/tc_index_searcher.rb +6 -0
- data/test/unit/search/tm_searcher.rb +53 -1
- data/test/unit/store/tc_fs_store.rb +40 -2
- data/test/unit/store/tc_ram_store.rb +0 -0
- data/test/unit/store/tm_store.rb +0 -0
- data/test/unit/store/tm_store_lock.rb +7 -6
- data/test/unit/tc_field_symbol.rb +26 -0
- data/test/unit/ts_analysis.rb +0 -0
- data/test/unit/ts_index.rb +0 -0
- data/test/unit/ts_store.rb +0 -0
- data/test/unit/ts_utils.rb +0 -0
- data/test/unit/utils/tc_number_tools.rb +0 -0
- data/test/utils/content_generator.rb +226 -0
- metadata +262 -221
- data/ext/inc/lang.h +0 -48
- data/ext/inc/threading.h +0 -31
- data/ext/stem_ISO_8859_1_english.c +0 -1156
- data/ext/stem_ISO_8859_1_french.c +0 -1276
- data/ext/stem_ISO_8859_1_italian.c +0 -1091
- data/ext/stem_ISO_8859_1_norwegian.c +0 -296
- data/ext/stem_ISO_8859_1_spanish.c +0 -1119
- data/ext/stem_ISO_8859_1_swedish.c +0 -307
- data/ext/stem_UTF_8_danish.c +0 -344
- data/ext/stem_UTF_8_english.c +0 -1176
- data/ext/stem_UTF_8_french.c +0 -1296
- data/ext/stem_UTF_8_italian.c +0 -1113
- data/ext/stem_UTF_8_norwegian.c +0 -302
- data/ext/stem_UTF_8_portuguese.c +0 -1055
- data/ext/stem_UTF_8_russian.c +0 -709
- data/ext/stem_UTF_8_spanish.c +0 -1137
- data/ext/stem_UTF_8_swedish.c +0 -313
- data/lib/ferret_version.rb +0 -3
data/README
CHANGED
@@ -1,39 +1,27 @@
|
|
1
1
|
= Ferret
|
2
2
|
|
3
|
-
Ferret is a Ruby
|
4
|
-
(http://jakarta.apache.org/lucene/) In the same way as Lucene, it is not
|
5
|
-
standalone application, but a library you can use to index documents and
|
3
|
+
Ferret is a Ruby search library inspired by the Apache Lucene search engine for
|
4
|
+
Java (http://jakarta.apache.org/lucene/). In the same way as Lucene, it is not
|
5
|
+
a standalone application, but a library you can use to index documents and
|
6
6
|
search for things in them later.
|
7
7
|
|
8
8
|
== Requirements
|
9
9
|
|
10
10
|
* Ruby 1.8
|
11
|
-
* C compiler to build the extension. Tested with gcc, VC6
|
11
|
+
* C compiler to build the extension. Tested with gcc, VC6
|
12
|
+
* make (or nmake on windows)
|
12
13
|
|
13
14
|
== Installation
|
14
15
|
|
15
|
-
|
16
|
+
$ sudo gem install ferret
|
16
17
|
|
17
|
-
|
18
|
+
If you don't have rubygems installed you can still install Ferret. Just
|
19
|
+
download one of the zipped up versions of Ferret, unzip it and change into the
|
20
|
+
unzipped directory. Then run the following set of commands;
|
18
21
|
|
19
|
-
Otherwise, you will need Rake installed. De-compress the archive and enter its top directory.
|
20
|
-
|
21
|
-
tar zxpvf ferret-<version>.tar.gz
|
22
|
-
cd ferret-<version>
|
23
|
-
|
24
|
-
Run the following;
|
25
|
-
|
26
|
-
$ rake ext
|
27
22
|
$ ruby setup.rb config
|
28
23
|
$ ruby setup.rb setup
|
29
|
-
|
30
|
-
|
31
|
-
These simple steps install ferret in the default location of Ruby libraries.
|
32
|
-
You can also install files into your favorite directory by supplying setup.rb
|
33
|
-
some options. Try;
|
34
|
-
|
35
|
-
$ ruby setup.rb --help
|
36
|
-
|
24
|
+
$ sudo ruby setup.rb install
|
37
25
|
|
38
26
|
== Usage
|
39
27
|
|
data/RELEASE_CHANGES
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
(in /home/dave/w/ferret/ruby)
|
2
|
+
------------------------------------------------------------------------
|
3
|
+
r830 | dbalmain | 2008-03-01 14:10:47 +1100 (Sat, 01 Mar 2008) | 1 line
|
4
|
+
|
5
|
+
A few more updates to the build system
|
6
|
+
------------------------------------------------------------------------
|
7
|
+
r829 | dbalmain | 2008-03-01 13:55:16 +1100 (Sat, 01 Mar 2008) | 1 line
|
8
|
+
|
9
|
+
A few more updates to the build system
|
10
|
+
------------------------------------------------------------------------
|
11
|
+
r828 | dbalmain | 2008-02-29 10:48:33 +1100 (Fri, 29 Feb 2008) | 1 line
|
12
|
+
|
13
|
+
Moved largefile test to a new long_running test directory so that tests can be run more easily
|
14
|
+
------------------------------------------------------------------------
|
15
|
+
r826 | dbalmain | 2008-02-29 10:09:48 +1100 (Fri, 29 Feb 2008) | 1 line
|
16
|
+
|
17
|
+
Updated references to ferret/version.rb. Updated Rakefile to allow release task testing
|
18
|
+
------------------------------------------------------------------------
|
19
|
+
r825 | dbalmain | 2008-02-29 10:02:27 +1100 (Fri, 29 Feb 2008) | 1 line
|
20
|
+
|
21
|
+
Updated Rakefile to clean it up (added namespaces).
|
22
|
+
------------------------------------------------------------------------
|
23
|
+
r824 | dbalmain | 2008-02-29 10:01:08 +1100 (Fri, 29 Feb 2008) | 1 line
|
24
|
+
|
25
|
+
Updated :filter_proc so that custom PostFilter extensions can be built and applied to searches. See ruby/examples/c_extensions/age_filter
|
26
|
+
------------------------------------------------------------------------
|
27
|
+
r823 | dbalmain | 2008-02-26 18:44:39 +1100 (Tue, 26 Feb 2008) | 1 line
|
28
|
+
|
29
|
+
Fixed ticket #277. This will also help with the correct highlighting of matching urls in queries
|
30
|
+
------------------------------------------------------------------------
|
31
|
+
r822 | dbalmain | 2008-02-22 12:46:48 +1100 (Fri, 22 Feb 2008) | 1 line
|
32
|
+
|
33
|
+
Updated to latest posh.h => http://poshlib.hookatooka.com/poshlib/
|
34
|
+
------------------------------------------------------------------------
|
35
|
+
r821 | dbalmain | 2008-02-22 09:05:25 +1100 (Fri, 22 Feb 2008) | 1 line
|
36
|
+
|
37
|
+
Added ruby bindings to MultiMapper for testing in Ruby
|
38
|
+
------------------------------------------------------------------------
|
39
|
+
r820 | dbalmain | 2008-02-09 14:30:55 +1100 (Sat, 09 Feb 2008) | 1 line
|
40
|
+
|
41
|
+
Updated svn:ignore properties to handle new stemmer files
|
42
|
+
------------------------------------------------------------------------
|
43
|
+
r819 | dbalmain | 2008-02-09 14:27:46 +1100 (Sat, 09 Feb 2008) | 9 lines
|
44
|
+
|
45
|
+
Fixed Ticket #337. StemFilter.new now works with 'English', :english or
|
46
|
+
'EnGlIsH' and 'UTF_8' or 'utf-8' etc.
|
47
|
+
|
48
|
+
Also, good news for Norwegians, Romanians, Turks and Finns. We now have 3 new
|
49
|
+
stemmers for Norwegian, Romanian and Turkish and 2 new stop-word lists for
|
50
|
+
Finnish and Hungarian. Please try them out and let me know if there are any
|
51
|
+
problems.
|
52
|
+
|
53
|
+
|
54
|
+
------------------------------------------------------------------------
|
55
|
+
r818 | dbalmain | 2008-02-09 13:20:37 +1100 (Sat, 09 Feb 2008) | 1 line
|
56
|
+
|
57
|
+
Removed old version of stemmer. Making way for new version. This will break build temporarily
|
58
|
+
------------------------------------------------------------------------
|
59
|
+
r817 | dbalmain | 2008-02-09 11:55:02 +1100 (Sat, 09 Feb 2008) | 1 line
|
60
|
+
|
61
|
+
Added a very useful group_by example.
|
62
|
+
------------------------------------------------------------------------
|
63
|
+
r816 | dbalmain | 2008-02-09 09:26:20 +1100 (Sat, 09 Feb 2008) | 1 line
|
64
|
+
|
65
|
+
Updated documentation for :filter_proc to indicate that you can return a Float to be used to modify the score.
|
66
|
+
------------------------------------------------------------------------
|
67
|
+
r815 | dbalmain | 2008-02-09 00:27:58 +1100 (Sat, 09 Feb 2008) | 1 line
|
68
|
+
|
69
|
+
Made TypedRangeQuery the default range query when used from Ferret::Index::Index
|
70
|
+
------------------------------------------------------------------------
|
71
|
+
r814 | dbalmain | 2008-02-08 23:16:55 +1100 (Fri, 08 Feb 2008) | 1 line
|
72
|
+
|
73
|
+
Made the TypedRangeQuery optional in the query parser
|
74
|
+
------------------------------------------------------------------------
|
75
|
+
r813 | dbalmain | 2008-02-08 23:12:13 +1100 (Fri, 08 Feb 2008) | 1 line
|
76
|
+
|
77
|
+
Added TypedRangeQuery and TypedRangeFilter to the ruby bindings
|
78
|
+
------------------------------------------------------------------------
|
79
|
+
r812 | dbalmain | 2008-02-08 22:19:31 +1100 (Fri, 08 Feb 2008) | 1 line
|
80
|
+
|
81
|
+
Added TypedRangeQuery so that you can do range queries with unpadded numbers
|
82
|
+
------------------------------------------------------------------------
|
83
|
+
r811 | dbalmain | 2008-02-08 16:22:06 +1100 (Fri, 08 Feb 2008) | 3 lines
|
84
|
+
|
85
|
+
Whoops, quick fix. Had unnecessarily nested locks.
|
86
|
+
|
87
|
+
|
88
|
+
------------------------------------------------------------------------
|
89
|
+
r810 | dbalmain | 2008-02-08 16:17:33 +1100 (Fri, 08 Feb 2008) | 1 line
|
90
|
+
|
91
|
+
Added patch for Ticket #340 which adds batch updating and deleting. Made significant modifications from the patch.
|
92
|
+
------------------------------------------------------------------------
|
93
|
+
r809 | dbalmain | 2008-02-08 13:49:07 +1100 (Fri, 08 Feb 2008) | 18 lines
|
94
|
+
|
95
|
+
Added score filter. This enables you to filter the results and modify the score
|
96
|
+
to change the sort order.
|
97
|
+
|
98
|
+
For example to modify the scoring so that a document with todays date gets
|
99
|
+
twice the score factor as a document 50 days ago and four times the score
|
100
|
+
factor of a document 100 days ago (ie a half life of 50 days) you would do
|
101
|
+
this;
|
102
|
+
|
103
|
+
fifty_day_half_life_filter = lambda do |doc, score, searcher|
|
104
|
+
days = (Date.today() - Date.parse(searcher[doc][:date])).to_i
|
105
|
+
1.0 / (2.0 ** (days.to_f / 50.0))
|
106
|
+
end
|
107
|
+
|
108
|
+
top_docs = @searcher.search(q, :filter_proc => fifty_day_half_life_filter)
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
------------------------------------------------------------------------
|
114
|
+
r808 | dbalmain | 2008-01-11 07:14:01 +1100 (Fri, 11 Jan 2008) | 1 line
|
115
|
+
|
116
|
+
Changed unsigned long longs to f_u64 type to fix ticket #336
|
117
|
+
------------------------------------------------------------------------
|
118
|
+
r807 | dbalmain | 2008-01-11 07:12:40 +1100 (Fri, 11 Jan 2008) | 1 line
|
119
|
+
|
120
|
+
Changed unsigned long longs to f_u64 type to fix ticket #336
|
121
|
+
------------------------------------------------------------------------
|
122
|
+
r806 | dbalmain | 2008-01-11 07:01:00 +1100 (Fri, 11 Jan 2008) | 1 line
|
123
|
+
|
124
|
+
Minor comment correction
|
125
|
+
------------------------------------------------------------------------
|
126
|
+
r805 | dbalmain | 2007-12-12 10:28:23 +1100 (Wed, 12 Dec 2007) | 1 line
|
127
|
+
|
128
|
+
Fixed Ticket #332. Added spaces so that code parses correctly.
|
129
|
+
------------------------------------------------------------------------
|
130
|
+
r804 | dbalmain | 2007-12-03 11:20:34 +1100 (Mon, 03 Dec 2007) | 1 line
|
131
|
+
|
132
|
+
Added test for ticket #324
|
133
|
+
------------------------------------------------------------------------
|
134
|
+
r803 | dbalmain | 2007-12-03 11:12:55 +1100 (Mon, 03 Dec 2007) | 1 line
|
135
|
+
|
136
|
+
Fixed Ferret::Index::Index#query_update for ticket #324. Was only updating a maximum of 10 records.
|
137
|
+
------------------------------------------------------------------------
|
data/RELEASE_NOTES
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
The most significant update in this release is that you can now alter the
|
2
|
+
scoring, thereby altering the ordering of search results. A great application of
|
3
|
+
this is that you can now change the weight of a document based on its age. In
|
4
|
+
this example we have 365 day half life, ie a year-old document has half the
|
5
|
+
weight of a new document and twice the weight of a 2-year-old document;
|
6
|
+
|
7
|
+
require 'ferret'
|
8
|
+
|
9
|
+
age_weight = lambda do |doc, score, searcher|
|
10
|
+
age = (Date.today - Date.parse(searcher[doc][:date])).to_i
|
11
|
+
1 / 2 ** (age.to_f/365)
|
12
|
+
end
|
13
|
+
|
14
|
+
index = Ferret::I.new
|
15
|
+
|
16
|
+
sales = [
|
17
|
+
{ :artist => 'Giovanni Bellini',
|
18
|
+
:date => '2006-10-23',
|
19
|
+
:work => 'Transfiguration'
|
20
|
+
},
|
21
|
+
{ :artist => 'Giovanni Bellini',
|
22
|
+
:date => '2008-01-05',
|
23
|
+
:work => 'Pesaro Altarpiece'
|
24
|
+
},
|
25
|
+
{ :artist => 'Gentile Bellini',
|
26
|
+
:date => '2008-02-10',
|
27
|
+
:work => 'St. Dominic'
|
28
|
+
},
|
29
|
+
].each {|doc| index << doc}
|
30
|
+
|
31
|
+
puts index.search('artist:(Giovanni Bellini)').to_s(:work)
|
32
|
+
# =>
|
33
|
+
# TopDocs: total_hits = 3, max_score = 0.767351 [
|
34
|
+
# 0 "Transfiguration": 0.767351
|
35
|
+
# 1 "Pesaro Altarpiece": 0.767351
|
36
|
+
# 2 "St. Dominic": 0.129147
|
37
|
+
# ]
|
38
|
+
|
39
|
+
puts index.search('artist:(Giovanni Bellini)',
|
40
|
+
:filter_proc => age_weight).to_s(:work)
|
41
|
+
# =>
|
42
|
+
# TopDocs: total_hits = 3, max_score = 0.718006 [
|
43
|
+
# 1 "Pesaro Altarpiece": 0.718006
|
44
|
+
# 0 "Transfiguration": 0.311937
|
45
|
+
# 2 "St. Dominic": 0.129147
|
46
|
+
# ]
|
47
|
+
|
48
|
+
You can also now write your own C extensions to filter the search results. You
|
49
|
+
can see an example of this by downloading the source and looking at;
|
50
|
+
|
51
|
+
ferret_unzipped/ruby/examples/c_extensions/age_filter/
|
52
|
+
|
53
|
+
Alternatively, you can view the code at;
|
54
|
+
|
55
|
+
http://ferret.davebalmain.com/trac/browser/trunk/ruby/examples/c_extensions?rev=828
|
56
|
+
|
57
|
+
Also, good news for Norwegians, Romanians, Turks and Finns. We now have 3 new
|
58
|
+
stemmers for Norwegian, Romanian and Turkish and 2 new stop-word lists for
|
59
|
+
Finnish and Hungarian. Please try them out and let me know if there are any
|
60
|
+
problems.
|
data/Rakefile
CHANGED
@@ -1,338 +1,443 @@
|
|
1
|
-
$:. << 'lib'
|
2
|
-
# Some parts of this Rakefile where taken from Jim Weirich's Rakefile for
|
3
|
-
# Rake. Other parts where taken from the David Heinemeier Hansson's Rails
|
4
|
-
# Rakefile. Both are under MIT-LICENSE. Thanks to both for their excellent
|
5
|
-
# projects.
|
6
|
-
|
7
1
|
require 'rake'
|
8
|
-
require 'rake/testtask'
|
9
|
-
require 'rake/rdoctask'
|
10
2
|
require 'rake/clean'
|
11
|
-
require '
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
require 'rake/testtask'
|
12
6
|
|
13
|
-
|
14
|
-
|
15
|
-
require 'rake/gempackagetask'
|
16
|
-
rescue Exception
|
17
|
-
nil
|
18
|
-
end
|
7
|
+
$:. << 'lib'
|
8
|
+
require 'ferret/version'
|
19
9
|
|
20
|
-
CURRENT_VERSION = Ferret::VERSION
|
21
|
-
if ENV['REL']
|
22
|
-
PKG_VERSION = ENV['REL']
|
23
|
-
else
|
24
|
-
PKG_VERSION = CURRENT_VERSION
|
25
|
-
end
|
26
10
|
|
27
|
-
def
|
11
|
+
def say(msg='')
|
28
12
|
STDERR.puts msg
|
29
13
|
end
|
30
14
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
CLEAN.include(FileList['**/*.o', '**/*.obj', 'InstalledFiles',
|
43
|
-
'.config', 'ext/cferret.c'])
|
44
|
-
CLOBBER.include(FileList['**/*.so'], 'ext/Makefile', EXT_SRC_DEST)
|
45
|
-
POLISH = Rake::FileList.new.include(FileList['**/*.so'], 'ext/Makefile')
|
46
|
-
|
47
|
-
desc "Clean specifically for the release."
|
48
|
-
task :polish => [:clean] do
|
49
|
-
POLISH.each { |fn| rm_r fn rescue nil }
|
15
|
+
def prompt(msg)
|
16
|
+
STDERR.print "#{msg} [Yna]: "
|
17
|
+
while true
|
18
|
+
case STDIN.gets.chomp!
|
19
|
+
when /^(y(es)?)?$/i then return true
|
20
|
+
when /^no?$/i then return false
|
21
|
+
when /^a(bort)?$/i then fail('aborted')
|
22
|
+
else
|
23
|
+
STDERR.print "Sorry, I don't understand. Please type y, n or a: "
|
24
|
+
end
|
25
|
+
end
|
50
26
|
end
|
51
27
|
|
52
|
-
|
53
|
-
|
54
|
-
sh "valgrind --gen-suppressions=yes --suppressions=ferret_valgrind.supp " +
|
55
|
-
"--leak-check=yes --show-reachable=yes -v ruby test/test_all.rb"
|
56
|
-
#sh "valgrind --suppressions=ferret_valgrind.supp " +
|
57
|
-
# "--leak-check=yes --show-reachable=yes -v ruby test/unit/index/tc_index_reader.rb"
|
58
|
-
#valgrind --gen-suppressions=yes --suppressions=ferret_valgrind.supp --leak-check=yes --show-reachable=yes -v ruby test/test_all.rb
|
59
|
-
end
|
28
|
+
windows = (RUBY_PLATFORM =~ /win32|cygwin/) rescue nil
|
29
|
+
SUDO = windows ? "" : "sudo "
|
60
30
|
|
61
|
-
|
62
|
-
|
31
|
+
|
32
|
+
task :default => 'test:unit'
|
33
|
+
#task :default => :build do
|
63
34
|
# sh "ruby test/unit/index/tc_index.rb"
|
64
35
|
#end
|
65
36
|
|
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
|
-
|
37
|
+
BZLIB_SRC = FileList["../c/lib/bzlib/*.h"] +
|
38
|
+
FileList["../c/lib/bzlib/*.c"].map do |fn|
|
39
|
+
fn.gsub(%r{/([^/]*.c)}, '/BZ_\1')
|
40
|
+
end
|
41
|
+
##############################################################################
|
42
|
+
# Building
|
43
|
+
##############################################################################
|
44
|
+
|
45
|
+
task :build => 'build:compile'
|
46
|
+
namespace :build do
|
47
|
+
EXT = "ferret_ext.so"
|
48
|
+
# Note: libstemmer.[h] is necessary so that the file isn't included when it
|
49
|
+
# doesn't exist. It needs to have one regular expression element.
|
50
|
+
EXT_SRC = FileList["../c/src/*.[ch]", "../c/include/*.h",
|
51
|
+
"../c/lib/bzlib/*.[ch]",
|
52
|
+
"../c/lib/libstemmer_c/src_c/*.[ch]",
|
53
|
+
"../c/lib/libstemmer_c/runtime/*.[ch]",
|
54
|
+
"../c/lib/libstemmer_c/libstemmer/*.[ch]",
|
55
|
+
"../c/lib/libstemmer_c/include/libstemmer.[h]"]
|
56
|
+
EXT_SRC.exclude('../c/**/ind.[ch]',
|
57
|
+
'../c/**/symbol.[ch]',
|
58
|
+
'../c/include/threading.h',
|
59
|
+
'../c/include/scanner.h',
|
60
|
+
'../c/include/internal.h',
|
61
|
+
'../c/src/lang.c',
|
62
|
+
'../c/include/lang.h')
|
63
|
+
|
64
|
+
EXT_SRC_MAP = {}
|
65
|
+
EXT_SRC_DEST = EXT_SRC.map do |fn|
|
66
|
+
ext_fn = File.join("ext", File.basename(fn))
|
67
|
+
if fn =~ /.c$/ and fn =~ /(bzlib|stemmer)/
|
68
|
+
prefix = $1.upcase
|
69
|
+
ext_fn.gsub!(/ext\//, "ext/#{prefix}_")
|
70
|
+
end
|
71
|
+
EXT_SRC_MAP[fn] = ext_fn
|
72
|
+
end
|
73
|
+
SRC = FileList["ext/*.[ch]", EXT_SRC_DEST, 'ext/internal.h'].uniq
|
74
|
+
|
75
|
+
CLEAN.include ['**/*.o', '**/*.obj', '.config', 'ext/cferret.c']
|
76
|
+
CLOBBER.include ['doc/api', 'ext/*.so', 'ext/Makefile',
|
77
|
+
'ext/internal.h', EXT_SRC_DEST]
|
78
|
+
|
79
|
+
# The following block creates file tasks for all of the c files. They
|
80
|
+
# belong in the ../c directory in source the working copy and they need
|
81
|
+
# to be linked to in the ext directory
|
82
|
+
EXT_SRC.each do |fn|
|
83
|
+
dest_fn = EXT_SRC_MAP[fn]
|
84
|
+
# prepend lib files to avoid conflicts
|
85
|
+
file dest_fn => fn do |t|
|
86
|
+
ln_sf File.expand_path(fn), File.expand_path(dest_fn)
|
87
|
+
|
88
|
+
if fn =~ /stemmer/
|
89
|
+
# flatten the directory structure for lib_stemmer
|
90
|
+
open(dest_fn) do |in_f|
|
91
|
+
open(dest_fn + ".out", "w") do |out_f|
|
92
|
+
in_f.each do |line|
|
93
|
+
out_f.write(line.sub(/(#include ["<])[.a-z_\/]*\//, '\1'))
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
mv dest_fn + ".out", dest_fn
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end if File.exists?("../c")
|
95
101
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
rescue Exception => e
|
103
|
-
cp File.expand_path(fn), dest_fn
|
102
|
+
file 'ext/internal.h' => '../c/include/internal.h' do
|
103
|
+
File.open('ext/internal.h', 'w') do |f|
|
104
|
+
File.readlines('../c/include/internal.h').each do |l|
|
105
|
+
next if l =~ /ALLOC/ and l !~ /ZERO|MP_/
|
106
|
+
f.puts(l)
|
107
|
+
end
|
104
108
|
end
|
109
|
+
end
|
105
110
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
+
desc "Build the extension (ferret_ext.so). You'll need a C compiler and Make."
|
112
|
+
task :compile => ["ext/#{EXT}"] + SRC
|
113
|
+
|
114
|
+
file "ext/#{EXT}" => "ext/Makefile" do
|
115
|
+
cd "ext"
|
116
|
+
if windows and ENV['make'].nil?
|
117
|
+
begin
|
118
|
+
sh "nmake"
|
119
|
+
rescue Exception => e
|
120
|
+
path = ':\Program Files\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT'
|
121
|
+
if File.exists? "f#{path}"
|
122
|
+
sh "f#{path}"
|
123
|
+
elsif File.exists? "c#{path}"
|
124
|
+
sh "c#{path}"
|
125
|
+
else
|
126
|
+
say
|
127
|
+
say "***************************************************************"
|
128
|
+
say "You need to have Visual C++ 6 to build Ferret on Windows."
|
129
|
+
say "If you have it installed, you may need to run;"
|
130
|
+
say ' C:\Program Files\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT'
|
131
|
+
say "***************************************************************"
|
132
|
+
say
|
133
|
+
raise e
|
111
134
|
end
|
135
|
+
sh "nmake"
|
112
136
|
end
|
113
|
-
|
137
|
+
else
|
138
|
+
sh "make"
|
114
139
|
end
|
140
|
+
cd ".."
|
115
141
|
end
|
116
|
-
end if File.exists?("../c")
|
117
|
-
|
118
|
-
desc "Build the extension"
|
119
|
-
task :ext => ["ext/#{EXT}"] + SRC do
|
120
|
-
rm_f 'ext/mem_pool.*'
|
121
|
-
rm_f 'ext/defines.h'
|
122
|
-
end
|
123
142
|
|
124
|
-
file "ext
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
if (/mswin/ =~ RUBY_PLATFORM) and ENV['make'].nil?
|
129
|
-
begin
|
130
|
-
sh "nmake"
|
131
|
-
rescue Exception => e
|
132
|
-
puts
|
133
|
-
puts "**********************************************************************"
|
134
|
-
puts "You may need to call VCVARS32.BAT to set the environment variables."
|
135
|
-
puts ' "f:\Program Files\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT"'
|
136
|
-
puts "**********************************************************************"
|
137
|
-
puts
|
138
|
-
raise e
|
139
|
-
end
|
140
|
-
else
|
141
|
-
sh "make"
|
143
|
+
file "ext/Makefile" => SRC do
|
144
|
+
cd "ext"
|
145
|
+
ruby "extconf.rb"
|
146
|
+
cd ".."
|
142
147
|
end
|
143
|
-
cd ".."
|
144
148
|
end
|
145
149
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
+
##############################################################################
|
151
|
+
# Testing
|
152
|
+
##############################################################################
|
153
|
+
|
154
|
+
task :test => 'test:units'
|
155
|
+
namespace :test do
|
156
|
+
desc "Run tests with Valgrind"
|
157
|
+
task :valgrind do
|
158
|
+
sh "valgrind --suppressions=ferret_valgrind.supp " +
|
159
|
+
"--leak-check=yes --show-reachable=yes " +
|
160
|
+
"-v ruby test/unit/index/tc_index_reader.rb"
|
161
|
+
end
|
150
162
|
|
151
|
-
|
152
|
-
|
153
|
-
cp "ext/inc/threading.h", "ext/threading.h"
|
154
|
-
end
|
163
|
+
desc "Run all tests"
|
164
|
+
task :all => [ :units ]
|
155
165
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
166
|
+
desc "run unit tests in test/unit"
|
167
|
+
Rake::TestTask.new("units" => :build) do |t|
|
168
|
+
t.libs << "test/unit"
|
169
|
+
t.pattern = 'test/unit/t[cs]_*.rb'
|
170
|
+
t.verbose = true
|
171
|
+
end
|
172
|
+
task :unit => :units
|
173
|
+
|
174
|
+
desc "run tests using locally installed gem"
|
175
|
+
Rake::TestTask.new("installed") do |t|
|
176
|
+
t.libs << "test/unit"
|
177
|
+
t.ruby_opts << '-rtest/test_installed'
|
178
|
+
t.pattern = 'test/unit/t[cs]_*.rb'
|
179
|
+
t.verbose = true
|
180
|
+
end
|
160
181
|
end
|
161
182
|
|
162
|
-
|
183
|
+
##############################################################################
|
184
|
+
# Documentation
|
185
|
+
##############################################################################
|
163
186
|
|
164
|
-
|
165
|
-
|
187
|
+
desc "Generate API documentation"
|
188
|
+
task :doc => 'doc:rdoc'
|
189
|
+
namespace :doc do
|
190
|
+
if allison = Gem.cache.find_name('allison').last
|
191
|
+
allison_template = File.join(allison.full_gem_path, 'lib/allison.rb')
|
192
|
+
end
|
193
|
+
desc "Generate documentation for the application"
|
194
|
+
$rd = Rake::RDocTask.new do |rdoc|
|
195
|
+
rdoc.rdoc_dir = 'doc/api'
|
196
|
+
rdoc.title = "Ferret Search Library Documentation"
|
197
|
+
rdoc.options << '--line-numbers'
|
198
|
+
rdoc.options << '--inline-source'
|
199
|
+
rdoc.options << '--charset=utf-8'
|
200
|
+
rdoc.template = allison_template if allison_template
|
201
|
+
rdoc.rdoc_files.include('README')
|
202
|
+
rdoc.rdoc_files.include('TODO')
|
203
|
+
rdoc.rdoc_files.include('TUTORIAL')
|
204
|
+
rdoc.rdoc_files.include('MIT-LICENSE')
|
205
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
206
|
+
rdoc.rdoc_files.include('ext/r_*.c')
|
207
|
+
rdoc.rdoc_files.include('ext/ferret.c')
|
208
|
+
end
|
166
209
|
|
167
|
-
|
168
|
-
|
169
|
-
|
210
|
+
desc "Look for TODO and FIXME tags in the code"
|
211
|
+
task :todo do
|
212
|
+
FileList['**/*.rb', 'ext/*.[ch]'].egrep /[#*].*(FIXME|TODO|TBD)/i
|
213
|
+
end
|
170
214
|
end
|
171
215
|
|
172
|
-
|
216
|
+
##############################################################################
|
217
|
+
# Packaging and Installing
|
218
|
+
##############################################################################
|
173
219
|
|
174
220
|
PKG_FILES = FileList[
|
175
221
|
'setup.rb',
|
176
222
|
'[-A-Z]*',
|
177
|
-
'
|
178
|
-
'lib/**/*.
|
179
|
-
'lib/**/*.
|
180
|
-
'lib/**/*.
|
181
|
-
'lib/**/*.js',
|
223
|
+
'lib/**/*.rb',
|
224
|
+
'lib/**/*.rhtml',
|
225
|
+
'lib/**/*.css',
|
226
|
+
'lib/**/*.js',
|
182
227
|
'test/**/*.rb',
|
183
228
|
'test/**/wordfile',
|
184
229
|
'rake_utils/**/*.rb',
|
185
|
-
'Rakefile'
|
230
|
+
'Rakefile',
|
231
|
+
SRC
|
186
232
|
]
|
187
|
-
PKG_FILES.exclude('**/*.o')
|
188
|
-
PKG_FILES.exclude('**/Makefile')
|
189
|
-
PKG_FILES.exclude('ext/ferret_ext.so')
|
190
|
-
|
191
|
-
|
192
|
-
if ! defined?(Gem)
|
193
|
-
puts "Package Target requires RubyGEMs"
|
194
|
-
else
|
195
|
-
spec = Gem::Specification.new do |s|
|
196
|
-
|
197
|
-
#### Basic information.
|
198
|
-
s.name = 'ferret'
|
199
|
-
s.version = PKG_VERSION
|
200
|
-
s.summary = "Ruby indexing library."
|
201
|
-
s.description = <<-EOF
|
202
|
-
Ferret is a port of the Java Lucene project. It is a powerful
|
203
|
-
indexing and search library.
|
204
|
-
EOF
|
205
233
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
+
spec = Gem::Specification.new do |s|
|
235
|
+
|
236
|
+
#### Basic information.
|
237
|
+
s.name = 'ferret'
|
238
|
+
s.version = Ferret::VERSION
|
239
|
+
s.summary = "Ruby indexing library."
|
240
|
+
s.description = "Ferret is a super fast, highly configurable search library."
|
241
|
+
|
242
|
+
#### Dependencies and requirements.
|
243
|
+
s.add_dependency('rake')
|
244
|
+
s.files = PKG_FILES.to_a
|
245
|
+
s.extensions << "ext/extconf.rb"
|
246
|
+
s.require_path = 'lib'
|
247
|
+
s.bindir = 'bin'
|
248
|
+
s.executables = ['ferret-browser']
|
249
|
+
s.default_executable = 'ferret-browser'
|
250
|
+
|
251
|
+
#### Author and project details.
|
252
|
+
s.author = "David Balmain"
|
253
|
+
s.email = "dbalmain@gmail.com"
|
254
|
+
#s.homepage = "http://ferret.davebalmain.com/trac"
|
255
|
+
s.homepage = "http://github.com/jkraemer/ferret"
|
256
|
+
s.rubyforge_project = "ferret"
|
257
|
+
|
258
|
+
s.has_rdoc = true
|
259
|
+
s.extra_rdoc_files = $rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
|
260
|
+
s.rdoc_options <<
|
261
|
+
'--title' << 'Ferret -- Ruby Search Library' <<
|
262
|
+
'--main' << 'README' << '--line-numbers' <<
|
263
|
+
'TUTORIAL' << 'TODO'
|
264
|
+
|
265
|
+
key_file = File.expand_path('~/.gem/gem-private_key.pem')
|
266
|
+
key_file = nil unless File.exists?(key_file)
|
267
|
+
cert_file = File.expand_path('~/.gem/gem-public_cert.pem')
|
268
|
+
cert_file = nil unless File.exists?(cert_file)
|
269
|
+
if key_file and cert_file
|
270
|
+
s.signing_key = key_file
|
271
|
+
s.cert_chain = cert_file
|
234
272
|
end
|
235
273
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
274
|
+
if windows
|
275
|
+
s.files = PKG_FILES.to_a + ["ext/#{EXT}"]
|
276
|
+
s.extensions.clear
|
277
|
+
s.platform = Gem::Platform::WIN32
|
278
|
+
else
|
279
|
+
s.platform = Gem::Platform::RUBY
|
241
280
|
end
|
242
281
|
end
|
243
282
|
|
244
|
-
|
283
|
+
package_task = Rake::GemPackageTask.new(spec) do |pkg|
|
284
|
+
unless windows
|
285
|
+
pkg.need_zip = true
|
286
|
+
pkg.need_tar = true
|
287
|
+
end
|
288
|
+
end
|
245
289
|
|
246
|
-
desc "
|
247
|
-
task :
|
248
|
-
|
290
|
+
desc "Run :gem and install the resulting gem"
|
291
|
+
task :install => :gem do
|
292
|
+
sh "#{SUDO}gem install pkg/ferret-#{Ferret::VERSION}.gem --no-rdoc --no-ri -l"
|
249
293
|
end
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
task :release => [
|
255
|
-
:prerelease,
|
256
|
-
:polish,
|
257
|
-
:test_all,
|
258
|
-
:update_version,
|
259
|
-
:package,
|
260
|
-
:tag] do
|
261
|
-
announce
|
262
|
-
announce "**************************************************************"
|
263
|
-
announce "* Release #{PKG_VERSION} Complete."
|
264
|
-
announce "* Packages ready to upload."
|
265
|
-
announce "**************************************************************"
|
266
|
-
announce
|
294
|
+
|
295
|
+
desc "Run :clobber and uninstall the .gem"
|
296
|
+
task :uninstall => :clobber do
|
297
|
+
sh "#{SUDO}gem uninstall ferret"
|
267
298
|
end
|
268
299
|
|
269
|
-
|
270
|
-
task :
|
271
|
-
|
272
|
-
|
273
|
-
announce "* Making RubyGem Release #{PKG_VERSION}"
|
274
|
-
announce "* (current version #{CURRENT_VERSION})"
|
275
|
-
announce "**************************************************************"
|
276
|
-
announce
|
277
|
-
|
278
|
-
# Is a release number supplied?
|
279
|
-
unless ENV['REL']
|
280
|
-
fail "Usage: rake release REL=x.y.z [REUSE=tag_suffix]"
|
281
|
-
end
|
300
|
+
desc "Same as :install but you must be rootgem"
|
301
|
+
task :root_install => :gem do
|
302
|
+
sh "gem install pkg/ferret-#{Ferret::VERSION}.gem --no-rdoc --no-ri -l"
|
303
|
+
end
|
282
304
|
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
end
|
305
|
+
desc "Same as :uninstall but you must be root"
|
306
|
+
task :root_uninstall => :clobber do
|
307
|
+
sh "gem uninstall ferret"
|
308
|
+
end
|
288
309
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
310
|
+
def list_changes_since_last_release
|
311
|
+
tag_listing = `svn list svn://davebalmain.com/ferret/tags`
|
312
|
+
last_tag = tag_listing.split("\n").last
|
313
|
+
log = `svn log --stop-on-copy svn://davebalmain.com/ferret/tags/#{last_tag}`
|
314
|
+
first_log = log.split(/-------+/)[-2]
|
315
|
+
last_revision = /^r(\d+)\s+\|/.match(first_log)[1]
|
316
|
+
`svn log .. -rHEAD:#{last_revision}`
|
296
317
|
end
|
297
318
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
319
|
+
desc "List changes since last release"
|
320
|
+
task :changes do
|
321
|
+
puts list_changes_since_last_release
|
322
|
+
end
|
323
|
+
|
324
|
+
if ENV['FERRET_DEV']
|
325
|
+
##############################################################################
|
326
|
+
# Releasing
|
327
|
+
##############################################################################
|
328
|
+
|
329
|
+
desc "Generate and upload a new release"
|
330
|
+
task :release => 'release:release'
|
331
|
+
namespace :release do
|
332
|
+
task :release => [:status_check, 'test:all', :package, :tag] do
|
333
|
+
say
|
334
|
+
say "**************************************************************"
|
335
|
+
say "* Release #{Ferret::VERSION} Complete."
|
336
|
+
say "* Packages ready to upload."
|
337
|
+
say "**************************************************************"
|
338
|
+
say
|
339
|
+
reversion("lib/ferret/version.rb")
|
340
|
+
end
|
341
|
+
|
342
|
+
# Validate that everything is ready to go for a release.
|
343
|
+
task :status_check do
|
344
|
+
# Are all source files checked in?
|
345
|
+
unless `svn -q --ignore-externals status` =~ /^$/
|
346
|
+
fail "'svn -q status' is not clean ... do you have unchecked-in files?"
|
347
|
+
end
|
348
|
+
|
349
|
+
say "No outstanding checkins found ... OK"
|
350
|
+
end
|
351
|
+
|
352
|
+
def reversion(fn)
|
353
|
+
new_version = nil
|
354
|
+
begin
|
355
|
+
print "Ferret is currently at #{Ferret::VERSION}. What version now? "
|
356
|
+
new_version = STDIN.gets.chomp!
|
357
|
+
end until prompt("Change to version #{new_version}?")
|
358
|
+
|
359
|
+
if ENV['RELTEST']
|
360
|
+
say "Would change the version in lib/ferret/version.rb from"
|
361
|
+
say " #{Ferret::VERSION} => #{new_version}"
|
362
|
+
say "and then commit the changes with the command"
|
363
|
+
say " svn ci -m \"Updated to version #{new_version}\" " +
|
364
|
+
"lib/ferret/version.rb"
|
365
|
+
else
|
366
|
+
open(fn) do |ferret_in|
|
367
|
+
open(fn + ".new", "w") do |ferret_out|
|
368
|
+
ferret_in.each do |line|
|
369
|
+
if line =~ /^ VERSION\s*=\s*/
|
370
|
+
ferret_out.puts " VERSION = '#{new_version}'"
|
371
|
+
else
|
372
|
+
ferret_out.puts line
|
373
|
+
end
|
374
|
+
end
|
375
|
+
end
|
306
376
|
end
|
377
|
+
mv fn + ".new", fn
|
378
|
+
sh %{svn ci -m "Updated to version #{new_version}" lib/ferret/version.rb}
|
307
379
|
end
|
308
380
|
end
|
309
|
-
end
|
310
|
-
mv fn + ".new", fn
|
311
|
-
end
|
312
381
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
382
|
+
# Tag all the SVN files with the latest release number
|
383
|
+
task :tag => :status_check do
|
384
|
+
reltag = "REL-#{Ferret::VERSION}"
|
385
|
+
say "Tagging SVN with [#{reltag}]"
|
386
|
+
if ENV['RELTEST']
|
387
|
+
say "Release Task Testing, skipping SVN tagging. Would do;"
|
388
|
+
say %{svn copy -m "creating release #{reltag}" svn://www.davebalmain.com/ferret/trunk svn://www.davebalmain.com/ferret/tags/#{reltag}}
|
389
|
+
else
|
390
|
+
sh %{svn copy -m "creating release #{reltag}" svn://www.davebalmain.com/ferret/trunk svn://www.davebalmain.com/ferret/tags/#{reltag}}
|
391
|
+
end
|
323
392
|
end
|
393
|
+
|
324
394
|
end
|
325
|
-
end
|
326
395
|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
396
|
+
##############################################################################
|
397
|
+
# Publishing
|
398
|
+
##############################################################################
|
399
|
+
|
400
|
+
namespace :publish do
|
401
|
+
PUBLISH_PROMPT = <<-EOF
|
402
|
+
Make sure you updated RELEASE_NOTES and RELEASE_CHANGES and that the
|
403
|
+
package exists. Are you sure you want to continue?
|
404
|
+
EOF
|
405
|
+
desc "Publish gem on rubyforge for download. Will only do the linux version"
|
406
|
+
task :release do
|
407
|
+
exit unless prompt(PUBLISH_PROMPT)
|
408
|
+
require 'rubyforge'
|
409
|
+
require 'rake/contrib/rubyforgepublisher'
|
410
|
+
version = Ferret::VERSION
|
411
|
+
|
412
|
+
packages = %w(gem tgz zip).map {|ext| "pkg/ferret-#{version}.#{ext}"}
|
413
|
+
|
414
|
+
rubyforge = RubyForge.new
|
415
|
+
rubyforge.login
|
416
|
+
rubyforge.add_release('ferret', 'ferret',
|
417
|
+
"ferret-#{version}", *packages)
|
418
|
+
end
|
419
|
+
|
420
|
+
desc "Publish the documentation"
|
421
|
+
task :docs => 'doc:rdoc' do
|
422
|
+
sh %{rsync -rzv --delete -e 'ssh -p 8900' doc/api/ davebalmain.com:/var/www/ferret/api}
|
423
|
+
end
|
424
|
+
|
425
|
+
desc "Publish the documentation and release"
|
426
|
+
task :all => [:doc, :release]
|
337
427
|
end
|
338
428
|
end
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
#
|
434
|
+
# In case I ever need to add another racc parser, here's how
|
435
|
+
#
|
436
|
+
# # Make Parsers ---------------------------------------------------------------
|
437
|
+
#
|
438
|
+
# RACC_SRC = FileList["lib/**/*.y"]
|
439
|
+
#
|
440
|
+
# task :parsers => RACC_OUT
|
441
|
+
# rule(/\.tab\.rb$/ => [proc {|tn| tn.sub(/\.tab\.rb$/, '.y')}]) do |t|
|
442
|
+
# sh "racc #{t.source}"
|
443
|
+
# end
|