flat_kit 0.3.0 → 1.1.0
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.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +1 -2
- data/HISTORY.md +13 -0
- data/Manifest.txt +3 -42
- data/README.md +2 -0
- data/{bin → exe}/fk +2 -1
- data/flat_kit.gemspec +33 -0
- data/lib/flat_kit/cli.rb +46 -32
- data/lib/flat_kit/command/cat.rb +34 -32
- data/lib/flat_kit/command/merge.rb +37 -36
- data/lib/flat_kit/command/sort.rb +37 -37
- data/lib/flat_kit/command/stats.rb +41 -39
- data/lib/flat_kit/command.rb +10 -11
- data/lib/flat_kit/descendant_tracker.rb +9 -6
- data/lib/flat_kit/error.rb +4 -0
- data/lib/flat_kit/event_emitter.rb +6 -3
- data/lib/flat_kit/field_stats.rb +31 -26
- data/lib/flat_kit/field_type/boolean_type.rb +9 -5
- data/lib/flat_kit/field_type/date_type.rb +19 -17
- data/lib/flat_kit/field_type/float_type.rb +15 -9
- data/lib/flat_kit/field_type/guess_type.rb +9 -6
- data/lib/flat_kit/field_type/integer_type.rb +6 -4
- data/lib/flat_kit/field_type/null_type.rb +5 -1
- data/lib/flat_kit/field_type/string_type.rb +8 -6
- data/lib/flat_kit/field_type/timestamp_type.rb +11 -10
- data/lib/flat_kit/field_type/unknown_type.rb +12 -8
- data/lib/flat_kit/field_type.rb +52 -44
- data/lib/flat_kit/format.rb +11 -5
- data/lib/flat_kit/input/file.rb +11 -9
- data/lib/flat_kit/input/io.rb +18 -21
- data/lib/flat_kit/input.rb +8 -7
- data/lib/flat_kit/internal_node.rb +22 -19
- data/lib/flat_kit/jsonl/format.rb +6 -2
- data/lib/flat_kit/jsonl/reader.rb +7 -4
- data/lib/flat_kit/jsonl/record.rb +15 -18
- data/lib/flat_kit/jsonl/writer.rb +8 -10
- data/lib/flat_kit/jsonl.rb +8 -4
- data/lib/flat_kit/leaf_node.rb +6 -5
- data/lib/flat_kit/log_formatter.rb +20 -0
- data/lib/flat_kit/logger.rb +13 -21
- data/lib/flat_kit/merge.rb +21 -18
- data/lib/flat_kit/merge_tree.rb +5 -6
- data/lib/flat_kit/output/file.rb +13 -9
- data/lib/flat_kit/output/io.rb +40 -35
- data/lib/flat_kit/output.rb +8 -7
- data/lib/flat_kit/position.rb +3 -4
- data/lib/flat_kit/reader.rb +8 -8
- data/lib/flat_kit/record.rb +12 -12
- data/lib/flat_kit/sentinel_internal_node.rb +6 -5
- data/lib/flat_kit/sentinel_leaf_node.rb +4 -1
- data/lib/flat_kit/sort.rb +8 -13
- data/lib/flat_kit/stat_type/nominal_stats.rb +13 -7
- data/lib/flat_kit/stat_type/numerical_stats.rb +18 -18
- data/lib/flat_kit/stat_type/ordinal_stats.rb +8 -13
- data/lib/flat_kit/stat_type.rb +18 -13
- data/lib/flat_kit/stats.rb +12 -15
- data/lib/flat_kit/writer.rb +5 -6
- data/lib/flat_kit/xsv/format.rb +6 -2
- data/lib/flat_kit/xsv/reader.rb +8 -6
- data/lib/flat_kit/xsv/record.rb +22 -18
- data/lib/flat_kit/xsv/writer.rb +13 -10
- data/lib/flat_kit/xsv.rb +7 -4
- data/lib/flat_kit.rb +31 -26
- metadata +20 -161
- data/Rakefile +0 -21
- data/examples/stream-active-record-to-csv.rb +0 -42
- data/tasks/default.rake +0 -242
- data/tasks/extension.rake +0 -38
- data/tasks/man.rake +0 -7
- data/tasks/this.rb +0 -208
- data/test/device_dataset.rb +0 -117
- data/test/field_type/test_boolean_type.rb +0 -65
- data/test/field_type/test_date_type.rb +0 -71
- data/test/field_type/test_float_type.rb +0 -56
- data/test/field_type/test_guess_type.rb +0 -14
- data/test/field_type/test_integer_type.rb +0 -52
- data/test/field_type/test_null_type.rb +0 -41
- data/test/field_type/test_string_type.rb +0 -18
- data/test/field_type/test_timestamp_type.rb +0 -108
- data/test/field_type/test_unknown_type.rb +0 -35
- data/test/input/test_file.rb +0 -73
- data/test/input/test_io.rb +0 -93
- data/test/jsonl/test_format.rb +0 -22
- data/test/jsonl/test_reader.rb +0 -49
- data/test/jsonl/test_record.rb +0 -61
- data/test/jsonl/test_writer.rb +0 -86
- data/test/output/test_file.rb +0 -60
- data/test/output/test_io.rb +0 -104
- data/test/run +0 -23
- data/test/stat_type/test_nominal_stats.rb +0 -69
- data/test/stat_type/test_numerical_stats.rb +0 -118
- data/test/stat_type/test_ordinal_stats.rb +0 -92
- data/test/test_conversions.rb +0 -45
- data/test/test_event_emitter.rb +0 -89
- data/test/test_field_stats.rb +0 -134
- data/test/test_field_type.rb +0 -34
- data/test/test_format.rb +0 -24
- data/test/test_helper.rb +0 -26
- data/test/test_merge.rb +0 -40
- data/test/test_merge_tree.rb +0 -64
- data/test/test_version.rb +0 -11
- data/test/xsv/test_format.rb +0 -22
- data/test/xsv/test_reader.rb +0 -61
- data/test/xsv/test_record.rb +0 -69
- data/test/xsv/test_writer.rb +0 -89
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: flat_kit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jeremy Hinegardner
|
|
8
|
-
|
|
9
|
-
bindir: bin
|
|
8
|
+
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 2026-05-23 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: oj
|
|
@@ -39,89 +38,19 @@ dependencies:
|
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
39
|
version: '3.0'
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
41
|
+
name: csv
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
44
43
|
requirements:
|
|
45
44
|
- - "~>"
|
|
46
45
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
48
|
-
type: :
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '2.16'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: rake
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - "~>"
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '13.0'
|
|
62
|
-
type: :development
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - "~>"
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '13.0'
|
|
69
|
-
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: minitest
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - "~>"
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: '5.11'
|
|
76
|
-
type: :development
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - "~>"
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: '5.11'
|
|
83
|
-
- !ruby/object:Gem::Dependency
|
|
84
|
-
name: minitest-focus
|
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
|
86
|
-
requirements:
|
|
87
|
-
- - "~>"
|
|
88
|
-
- !ruby/object:Gem::Version
|
|
89
|
-
version: '1.2'
|
|
90
|
-
type: :development
|
|
91
|
-
prerelease: false
|
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
-
requirements:
|
|
94
|
-
- - "~>"
|
|
95
|
-
- !ruby/object:Gem::Version
|
|
96
|
-
version: '1.2'
|
|
97
|
-
- !ruby/object:Gem::Dependency
|
|
98
|
-
name: rdoc
|
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
|
100
|
-
requirements:
|
|
101
|
-
- - "~>"
|
|
102
|
-
- !ruby/object:Gem::Version
|
|
103
|
-
version: '6.3'
|
|
104
|
-
type: :development
|
|
105
|
-
prerelease: false
|
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
-
requirements:
|
|
108
|
-
- - "~>"
|
|
109
|
-
- !ruby/object:Gem::Version
|
|
110
|
-
version: '6.3'
|
|
111
|
-
- !ruby/object:Gem::Dependency
|
|
112
|
-
name: simplecov
|
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
|
114
|
-
requirements:
|
|
115
|
-
- - "~>"
|
|
116
|
-
- !ruby/object:Gem::Version
|
|
117
|
-
version: '0.21'
|
|
118
|
-
type: :development
|
|
46
|
+
version: '3.3'
|
|
47
|
+
type: :runtime
|
|
119
48
|
prerelease: false
|
|
120
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
50
|
requirements:
|
|
122
51
|
- - "~>"
|
|
123
52
|
- !ruby/object:Gem::Version
|
|
124
|
-
version: '
|
|
53
|
+
version: '3.3'
|
|
125
54
|
description: A library and commandline program for reading, writing, indexing, sorting,
|
|
126
55
|
and merging CSV, TSV, JSON and other flat-file formats.
|
|
127
56
|
email: jeremy@copiousfreetime.org
|
|
@@ -140,9 +69,8 @@ files:
|
|
|
140
69
|
- LICENSE.txt
|
|
141
70
|
- Manifest.txt
|
|
142
71
|
- README.md
|
|
143
|
-
-
|
|
144
|
-
-
|
|
145
|
-
- examples/stream-active-record-to-csv.rb
|
|
72
|
+
- exe/fk
|
|
73
|
+
- flat_kit.gemspec
|
|
146
74
|
- lib/flat_kit.rb
|
|
147
75
|
- lib/flat_kit/cli.rb
|
|
148
76
|
- lib/flat_kit/command.rb
|
|
@@ -175,6 +103,7 @@ files:
|
|
|
175
103
|
- lib/flat_kit/jsonl/record.rb
|
|
176
104
|
- lib/flat_kit/jsonl/writer.rb
|
|
177
105
|
- lib/flat_kit/leaf_node.rb
|
|
106
|
+
- lib/flat_kit/log_formatter.rb
|
|
178
107
|
- lib/flat_kit/logger.rb
|
|
179
108
|
- lib/flat_kit/merge.rb
|
|
180
109
|
- lib/flat_kit/merge_tree.rb
|
|
@@ -198,50 +127,16 @@ files:
|
|
|
198
127
|
- lib/flat_kit/xsv/reader.rb
|
|
199
128
|
- lib/flat_kit/xsv/record.rb
|
|
200
129
|
- lib/flat_kit/xsv/writer.rb
|
|
201
|
-
- tasks/default.rake
|
|
202
|
-
- tasks/extension.rake
|
|
203
|
-
- tasks/man.rake
|
|
204
|
-
- tasks/this.rb
|
|
205
|
-
- test/device_dataset.rb
|
|
206
|
-
- test/field_type/test_boolean_type.rb
|
|
207
|
-
- test/field_type/test_date_type.rb
|
|
208
|
-
- test/field_type/test_float_type.rb
|
|
209
|
-
- test/field_type/test_guess_type.rb
|
|
210
|
-
- test/field_type/test_integer_type.rb
|
|
211
|
-
- test/field_type/test_null_type.rb
|
|
212
|
-
- test/field_type/test_string_type.rb
|
|
213
|
-
- test/field_type/test_timestamp_type.rb
|
|
214
|
-
- test/field_type/test_unknown_type.rb
|
|
215
|
-
- test/input/test_file.rb
|
|
216
|
-
- test/input/test_io.rb
|
|
217
|
-
- test/jsonl/test_format.rb
|
|
218
|
-
- test/jsonl/test_reader.rb
|
|
219
|
-
- test/jsonl/test_record.rb
|
|
220
|
-
- test/jsonl/test_writer.rb
|
|
221
|
-
- test/output/test_file.rb
|
|
222
|
-
- test/output/test_io.rb
|
|
223
|
-
- test/run
|
|
224
|
-
- test/stat_type/test_nominal_stats.rb
|
|
225
|
-
- test/stat_type/test_numerical_stats.rb
|
|
226
|
-
- test/stat_type/test_ordinal_stats.rb
|
|
227
|
-
- test/test_conversions.rb
|
|
228
|
-
- test/test_event_emitter.rb
|
|
229
|
-
- test/test_field_stats.rb
|
|
230
|
-
- test/test_field_type.rb
|
|
231
|
-
- test/test_format.rb
|
|
232
|
-
- test/test_helper.rb
|
|
233
|
-
- test/test_merge.rb
|
|
234
|
-
- test/test_merge_tree.rb
|
|
235
|
-
- test/test_version.rb
|
|
236
|
-
- test/xsv/test_format.rb
|
|
237
|
-
- test/xsv/test_reader.rb
|
|
238
|
-
- test/xsv/test_record.rb
|
|
239
|
-
- test/xsv/test_writer.rb
|
|
240
130
|
homepage: http://github.com/copiousfreetime/flat_kit
|
|
241
131
|
licenses:
|
|
242
132
|
- MIT
|
|
243
|
-
metadata:
|
|
244
|
-
|
|
133
|
+
metadata:
|
|
134
|
+
bug_tracker_uri: https://github.com/copiousfreetime/flat_kit/issues
|
|
135
|
+
changelog_uri: https://github.com/copiousfreetime/flat_kit/blob/master/HISTORY.md
|
|
136
|
+
homepage_uri: https://github.com/copiousfreetime/flat_kit
|
|
137
|
+
source_code_uri: https://github.com/copiousfreetime/flat_kit
|
|
138
|
+
label: flat_kit
|
|
139
|
+
rubygems_mfa_required: 'true'
|
|
245
140
|
rdoc_options:
|
|
246
141
|
- "--main"
|
|
247
142
|
- README.md
|
|
@@ -253,51 +148,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
253
148
|
requirements:
|
|
254
149
|
- - ">="
|
|
255
150
|
- !ruby/object:Gem::Version
|
|
256
|
-
version:
|
|
151
|
+
version: 3.0.0
|
|
257
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
258
153
|
requirements:
|
|
259
154
|
- - ">="
|
|
260
155
|
- !ruby/object:Gem::Version
|
|
261
156
|
version: '0'
|
|
262
157
|
requirements: []
|
|
263
|
-
rubygems_version:
|
|
264
|
-
signing_key:
|
|
158
|
+
rubygems_version: 4.0.10
|
|
265
159
|
specification_version: 4
|
|
266
160
|
summary: A library and commandline program for reading, writing, indexing, sorting,
|
|
267
161
|
and merging CSV, TSV, JSON and other flat-file formats.
|
|
268
|
-
test_files:
|
|
269
|
-
- test/device_dataset.rb
|
|
270
|
-
- test/field_type/test_boolean_type.rb
|
|
271
|
-
- test/field_type/test_date_type.rb
|
|
272
|
-
- test/field_type/test_float_type.rb
|
|
273
|
-
- test/field_type/test_guess_type.rb
|
|
274
|
-
- test/field_type/test_integer_type.rb
|
|
275
|
-
- test/field_type/test_null_type.rb
|
|
276
|
-
- test/field_type/test_string_type.rb
|
|
277
|
-
- test/field_type/test_timestamp_type.rb
|
|
278
|
-
- test/field_type/test_unknown_type.rb
|
|
279
|
-
- test/input/test_file.rb
|
|
280
|
-
- test/input/test_io.rb
|
|
281
|
-
- test/jsonl/test_format.rb
|
|
282
|
-
- test/jsonl/test_reader.rb
|
|
283
|
-
- test/jsonl/test_record.rb
|
|
284
|
-
- test/jsonl/test_writer.rb
|
|
285
|
-
- test/output/test_file.rb
|
|
286
|
-
- test/output/test_io.rb
|
|
287
|
-
- test/run
|
|
288
|
-
- test/stat_type/test_nominal_stats.rb
|
|
289
|
-
- test/stat_type/test_numerical_stats.rb
|
|
290
|
-
- test/stat_type/test_ordinal_stats.rb
|
|
291
|
-
- test/test_conversions.rb
|
|
292
|
-
- test/test_event_emitter.rb
|
|
293
|
-
- test/test_field_stats.rb
|
|
294
|
-
- test/test_field_type.rb
|
|
295
|
-
- test/test_format.rb
|
|
296
|
-
- test/test_helper.rb
|
|
297
|
-
- test/test_merge.rb
|
|
298
|
-
- test/test_merge_tree.rb
|
|
299
|
-
- test/test_version.rb
|
|
300
|
-
- test/xsv/test_format.rb
|
|
301
|
-
- test/xsv/test_reader.rb
|
|
302
|
-
- test/xsv/test_record.rb
|
|
303
|
-
- test/xsv/test_writer.rb
|
|
162
|
+
test_files: []
|
data/Rakefile
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# vim: syntax=ruby
|
|
2
|
-
load 'tasks/this.rb'
|
|
3
|
-
|
|
4
|
-
This.name = "flat_kit"
|
|
5
|
-
This.author = "Jeremy Hinegardner"
|
|
6
|
-
This.email = "jeremy@copiousfreetime.org"
|
|
7
|
-
This.homepage = "http://github.com/copiousfreetime/#{ This.name }"
|
|
8
|
-
|
|
9
|
-
This.ruby_gemspec do |spec|
|
|
10
|
-
spec.add_dependency('oj', '~> 3.0')
|
|
11
|
-
spec.add_dependency('optimist', '~> 3.0')
|
|
12
|
-
|
|
13
|
-
spec.add_development_dependency( 'faker' , '~> 2.16')
|
|
14
|
-
spec.add_development_dependency( 'rake' , '~> 13.0')
|
|
15
|
-
spec.add_development_dependency( 'minitest' , '~> 5.11' )
|
|
16
|
-
spec.add_development_dependency( 'minitest-focus' , '~> 1.2' )
|
|
17
|
-
spec.add_development_dependency( 'rdoc' , '~> 6.3' )
|
|
18
|
-
spec.add_development_dependency( 'simplecov', '~> 0.21')
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
load 'tasks/default.rake'
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
|
|
3
|
-
#------------------------------------------------------------------------------
|
|
4
|
-
# This is an example to show how to stream an active record scope to a CSV file
|
|
5
|
-
# using FlatKit.
|
|
6
|
-
#------------------------------------------------------------------------------
|
|
7
|
-
|
|
8
|
-
require 'flat_kit' # gem 'flat_kit'
|
|
9
|
-
require 'progress_bar' # gem 'progress-bar'
|
|
10
|
-
|
|
11
|
-
# get an appropriate scope from one of your models - or any scope for that
|
|
12
|
-
# matter
|
|
13
|
-
scope = MyActiveRecordModel.all
|
|
14
|
-
|
|
15
|
-
# Output to a file that is csv, and automatically gzipped
|
|
16
|
-
#
|
|
17
|
-
output_csv = ::FlatKit::Xsv::Writer.new(destination: "export.csv.gz")
|
|
18
|
-
|
|
19
|
-
# handy progress bar
|
|
20
|
-
bar = ProgressBar.new(scope.count)
|
|
21
|
-
|
|
22
|
-
# using active record in batches to not pull all the recors from the database at
|
|
23
|
-
# once
|
|
24
|
-
#
|
|
25
|
-
# https://api.rubyonrails.org/classes/ActiveRecord/Batches.html#method-i-find_each
|
|
26
|
-
scope.find_each do |record|
|
|
27
|
-
|
|
28
|
-
# generate an XSV Record by pulling hte attributes out of the active record
|
|
29
|
-
# model. You may also want to generate a hash from a query or something
|
|
30
|
-
# along those lines. In any case pass in a Hash to complete_structured_data:
|
|
31
|
-
# and nil to data.
|
|
32
|
-
xsv_record = ::FlatKit::Xsv::Record.new(data: nil, complete_structured_data: record.attributes)
|
|
33
|
-
|
|
34
|
-
# FlatKit will automatically handle writing out the header line based upon
|
|
35
|
-
# the fields in the first record.
|
|
36
|
-
output_csv.write(xsv_record)
|
|
37
|
-
|
|
38
|
-
bar.increment!
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# close the output file explicitly
|
|
42
|
-
output_csv.close
|
data/tasks/default.rake
DELETED
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
# vim: syntax=ruby
|
|
2
|
-
require 'rake/clean'
|
|
3
|
-
require 'digest'
|
|
4
|
-
#------------------------------------------------------------------------------
|
|
5
|
-
# If you want to Develop on this project just run 'rake develop' and you'll
|
|
6
|
-
# have all you need to get going. If you want to use bundler for development,
|
|
7
|
-
# then run 'rake develop:using_bundler'
|
|
8
|
-
#------------------------------------------------------------------------------
|
|
9
|
-
namespace :develop do
|
|
10
|
-
|
|
11
|
-
# Install all the development and runtime dependencies of this gem using the
|
|
12
|
-
# gemspec.
|
|
13
|
-
task :default => 'Gemfile' do
|
|
14
|
-
require 'rubygems/dependency_installer'
|
|
15
|
-
installer = ::Gem::DependencyInstaller.new
|
|
16
|
-
puts "Installing bundler..."
|
|
17
|
-
installer.install 'bundler'
|
|
18
|
-
sh 'bundle install'
|
|
19
|
-
puts "\n\nNow run 'rake test'"
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# Create a Gemfile that just references the gemspec
|
|
23
|
-
file 'Gemfile' => :gemspec do
|
|
24
|
-
File.open( "Gemfile", "w+" ) do |f|
|
|
25
|
-
f.puts "# DO NOT EDIT - This file is automatically generated"
|
|
26
|
-
f.puts "# Make changes to Manifest.txt and/or Rakefile and regenerate"
|
|
27
|
-
f.puts 'source "https://rubygems.org"'
|
|
28
|
-
f.puts 'gemspec'
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
desc "Bootstrap development"
|
|
33
|
-
task :develop => "develop:default"
|
|
34
|
-
|
|
35
|
-
#------------------------------------------------------------------------------
|
|
36
|
-
# Minitest - standard TestTask
|
|
37
|
-
#------------------------------------------------------------------------------
|
|
38
|
-
begin
|
|
39
|
-
require 'rake/testtask'
|
|
40
|
-
Rake::TestTask.new( :test ) do |t|
|
|
41
|
-
t.ruby_opts = %w[ -w ]
|
|
42
|
-
t.libs = %w[ lib spec test ]
|
|
43
|
-
t.pattern = "{test,spec}/**/{test_*,*_spec}.rb"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
task :test_requirements
|
|
47
|
-
task :test => :test_requirements
|
|
48
|
-
task :default => :test
|
|
49
|
-
rescue LoadError
|
|
50
|
-
This.task_warning( 'test' )
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
#------------------------------------------------------------------------------
|
|
54
|
-
# RDoc - standard rdoc rake task, although we must make sure to use a more
|
|
55
|
-
# recent version of rdoc since it is the one that has 'tomdoc' markup
|
|
56
|
-
#------------------------------------------------------------------------------
|
|
57
|
-
begin
|
|
58
|
-
gem 'rdoc' # otherwise we get the wrong task from stdlib
|
|
59
|
-
require 'rdoc/task'
|
|
60
|
-
RDoc::Task.new do |t|
|
|
61
|
-
t.markup = 'tomdoc'
|
|
62
|
-
t.rdoc_dir = 'doc'
|
|
63
|
-
t.main = 'README.md'
|
|
64
|
-
t.title = "#{This.name} #{This.version}"
|
|
65
|
-
t.rdoc_files.include( FileList['*.{rdoc,md,txt}'], FileList['ext/**/*.c'],
|
|
66
|
-
FileList['lib/**/*.rb'] )
|
|
67
|
-
end
|
|
68
|
-
rescue StandardError, LoadError
|
|
69
|
-
This.task_warning( 'rdoc' )
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
#------------------------------------------------------------------------------
|
|
73
|
-
# Coverage - optional code coverage, rcov for 1.8 and simplecov for 1.9, so
|
|
74
|
-
# for the moment only rcov is listed.
|
|
75
|
-
#------------------------------------------------------------------------------
|
|
76
|
-
begin
|
|
77
|
-
require 'simplecov'
|
|
78
|
-
desc 'Run tests with code coverage'
|
|
79
|
-
task :coverage do
|
|
80
|
-
ENV['COVERAGE'] = 'true'
|
|
81
|
-
Rake::Task[:test].execute
|
|
82
|
-
end
|
|
83
|
-
CLOBBER << 'coverage' if File.directory?( 'coverage' )
|
|
84
|
-
rescue LoadError
|
|
85
|
-
This.task_warning( 'simplecov' )
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
#------------------------------------------------------------------------------
|
|
89
|
-
# Manifest - We want an explicit list of thos files that are to be packaged in
|
|
90
|
-
# the gem. Most of this is from Hoe.
|
|
91
|
-
#------------------------------------------------------------------------------
|
|
92
|
-
namespace 'manifest' do
|
|
93
|
-
desc "Check the manifest"
|
|
94
|
-
task :check => :clean do
|
|
95
|
-
files = FileList["**/*", ".*"].exclude( This.exclude_from_manifest ).to_a.sort
|
|
96
|
-
files = files.select{ |f| File.file?( f ) }
|
|
97
|
-
|
|
98
|
-
tmp = "Manifest.tmp"
|
|
99
|
-
File.open( tmp, 'w' ) do |f|
|
|
100
|
-
f.puts files.join("\n")
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
begin
|
|
104
|
-
sh "diff -du Manifest.txt #{tmp}"
|
|
105
|
-
ensure
|
|
106
|
-
rm tmp
|
|
107
|
-
end
|
|
108
|
-
puts "Manifest looks good"
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
desc "Generate the manifest"
|
|
112
|
-
task :generate => :clean do
|
|
113
|
-
files = %x[ git ls-files ].split("\n").sort
|
|
114
|
-
files.reject! { |f| f =~ This.exclude_from_manifest }
|
|
115
|
-
File.open( "Manifest.txt", "w" ) do |f|
|
|
116
|
-
f.puts files.join("\n")
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
#------------------------------------------------------------------------------
|
|
122
|
-
# Fixme - look for fixmes and report them
|
|
123
|
-
#------------------------------------------------------------------------------
|
|
124
|
-
namespace :fixme do
|
|
125
|
-
task :default => 'manifest:check' do
|
|
126
|
-
This.manifest.each do |file|
|
|
127
|
-
next if file == __FILE__
|
|
128
|
-
next unless file =~ %r/(txt|rb|md|rdoc|css|html|xml|css)\Z/
|
|
129
|
-
puts "FIXME: Rename #{file}" if file =~ /fixme/i
|
|
130
|
-
IO.readlines( file ).each_with_index do |line, idx|
|
|
131
|
-
prefix = "FIXME: #{file}:#{idx+1}".ljust(42)
|
|
132
|
-
puts "#{prefix} => #{line.strip}" if line =~ /fixme/i
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
def fixme_project_root
|
|
138
|
-
This.project_path( '../fixme' )
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
def fixme_project_path( subtree )
|
|
142
|
-
fixme_project_root.join( subtree )
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
def local_fixme_files
|
|
146
|
-
This.manifest.select { |p| p =~ %r|^tasks/| }
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
def outdated_fixme_files
|
|
150
|
-
local_fixme_files.select do |local|
|
|
151
|
-
upstream = fixme_project_path( local )
|
|
152
|
-
upstream.exist? &&
|
|
153
|
-
( Digest::SHA256.file( local ) != Digest::SHA256.file( upstream ) )
|
|
154
|
-
end
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
def fixme_up_to_date?
|
|
158
|
-
outdated_fixme_files.empty?
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
desc "See if the fixme tools are outdated"
|
|
162
|
-
task :outdated do
|
|
163
|
-
if fixme_up_to_date? then
|
|
164
|
-
puts "Fixme files are up to date."
|
|
165
|
-
else
|
|
166
|
-
outdated_fixme_files.each do |f|
|
|
167
|
-
puts "#{f} is outdated"
|
|
168
|
-
end
|
|
169
|
-
end
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
desc "Update outdated fixme files"
|
|
173
|
-
task :update do
|
|
174
|
-
if fixme_up_to_date? then
|
|
175
|
-
puts "Fixme files are already up to date."
|
|
176
|
-
else
|
|
177
|
-
puts "Updating fixme files:"
|
|
178
|
-
outdated_fixme_files.each do |local|
|
|
179
|
-
upstream = fixme_project_path( local )
|
|
180
|
-
puts " * #{local}"
|
|
181
|
-
FileUtils.cp( upstream, local )
|
|
182
|
-
end
|
|
183
|
-
puts "Use your git commands as appropriate."
|
|
184
|
-
end
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
desc "Look for fixmes and report them"
|
|
188
|
-
task :fixme => "fixme:default"
|
|
189
|
-
|
|
190
|
-
#------------------------------------------------------------------------------
|
|
191
|
-
# Gem Specification
|
|
192
|
-
#------------------------------------------------------------------------------
|
|
193
|
-
# Really this is only here to support those who use bundler
|
|
194
|
-
desc "Build the #{This.name}.gemspec file"
|
|
195
|
-
task :gemspec do
|
|
196
|
-
File.open( This.gemspec_file, "wb+" ) do |f|
|
|
197
|
-
f.puts "# DO NOT EDIT - This file is automatically generated"
|
|
198
|
-
f.puts "# Make changes to Manifest.txt and/or Rakefile and regenerate"
|
|
199
|
-
f.write This.platform_gemspec.to_ruby
|
|
200
|
-
end
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
# .rbc files from ruby 2.0
|
|
204
|
-
CLOBBER << FileList["**/*.rbc"]
|
|
205
|
-
|
|
206
|
-
# The standard gem packaging task, everyone has it.
|
|
207
|
-
require 'rubygems/package_task'
|
|
208
|
-
::Gem::PackageTask.new( This.platform_gemspec ) do
|
|
209
|
-
# nothing
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
#------------------------------------------------------------------------------
|
|
213
|
-
# Release - the steps we go through to do a final release, this is pulled from
|
|
214
|
-
# a compbination of mojombo's rakegem, hoe and hoe-git
|
|
215
|
-
#
|
|
216
|
-
# 1) make sure we are on the main branch
|
|
217
|
-
# 2) make sure there are no uncommitted items
|
|
218
|
-
# 3) check the manifest and make sure all looks good
|
|
219
|
-
# 4) build the gem
|
|
220
|
-
# 5) do an empty commit to have the commit message of the version
|
|
221
|
-
# 6) tag that commit as the version
|
|
222
|
-
# 7) push main
|
|
223
|
-
# 8) push the tag
|
|
224
|
-
# 7) pus the gem
|
|
225
|
-
#------------------------------------------------------------------------------
|
|
226
|
-
task :release_check do
|
|
227
|
-
unless `git branch` =~ /^\* main/
|
|
228
|
-
abort "You must be on the main branch to release!"
|
|
229
|
-
end
|
|
230
|
-
unless `git status` =~ /^nothing to commit/m
|
|
231
|
-
abort "Nope, sorry, you have unfinished business"
|
|
232
|
-
end
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
desc "Create tag v#{This.version}, build and push #{This.platform_gemspec.full_name} to rubygems.org"
|
|
236
|
-
task :release => [ :release_check, 'manifest:check', :gem ] do
|
|
237
|
-
sh "git commit --allow-empty -a -m 'Release #{This.version}'"
|
|
238
|
-
sh "git tag -a -m 'v#{This.version}' v#{This.version}"
|
|
239
|
-
sh "git push origin main"
|
|
240
|
-
sh "git push origin v#{This.version}"
|
|
241
|
-
sh "gem push pkg/#{This.platform_gemspec.full_name}.gem"
|
|
242
|
-
end
|
data/tasks/extension.rake
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# To be used if the gem has extensions.
|
|
2
|
-
# If this task set is inclueded then you will need to also have
|
|
3
|
-
#
|
|
4
|
-
# spec.add_development_dependency( 'rake-compiler', '~> 0.8.1' )
|
|
5
|
-
#
|
|
6
|
-
# in your top level rakefile
|
|
7
|
-
begin
|
|
8
|
-
require 'rake/extensiontask'
|
|
9
|
-
require 'rake/javaextensiontask'
|
|
10
|
-
|
|
11
|
-
if RUBY_PLATFORM == "java" then
|
|
12
|
-
|
|
13
|
-
Rake::JavaExtensionTask.new( This.name) do |ext|
|
|
14
|
-
ext.ext_dir = File.join( 'ext', This.name, "java" )
|
|
15
|
-
ext.lib_dir = File.join( 'lib', This.name )
|
|
16
|
-
ext.gem_spec = This.java_gemspec
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
else
|
|
20
|
-
|
|
21
|
-
Rake::ExtensionTask.new( This.name ) do |ext|
|
|
22
|
-
ext.ext_dir = File.join( 'ext', This.name, "c" )
|
|
23
|
-
ext.lib_dir = File.join( 'lib', This.name )
|
|
24
|
-
ext.gem_spec = This.ruby_gemspec
|
|
25
|
-
|
|
26
|
-
ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
|
|
27
|
-
ext.cross_platform = %w[x86-mingw32 x64-mingw32] # forces the Windows platform instead of the default one
|
|
28
|
-
# configure options only for cross compile
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
task :test_requirements => :compile
|
|
33
|
-
rescue LoadError
|
|
34
|
-
This.task_warning( 'extension' )
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
CLOBBER << FileList["lib/**/*.{jar,so,bundle}"]
|
|
38
|
-
CLOBBER << FileList["lib/#{This.name}/{1,2}.*/"]
|
data/tasks/man.rake
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
#------------------------------------------------------------------------------
|
|
2
|
-
# man pages
|
|
3
|
-
#------------------------------------------------------------------------------
|
|
4
|
-
desc "Create the man pages"
|
|
5
|
-
task :man do
|
|
6
|
-
sh "ronn --roff #{FileList["man/*.ronn"]}"
|
|
7
|
-
end
|