djnml 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +19 -0
- data/LICENSE.txt +24 -0
- data/README.rdoc +35 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/djnml.gemspec +79 -0
- data/lib/djnml/codes.rb +3127 -0
- data/lib/djnml/delete.rb +13 -0
- data/lib/djnml/modification.rb +244 -0
- data/lib/djnml.rb +417 -0
- data/spec/data/20120716155056208LL000587.NML +28 -0
- data/spec/data/20120716161436878LL001634.NML +117 -0
- data/spec/data/20120716162053366LL005062.NML +115 -0
- data/spec/data/20120720222918942LL007284.NML +26 -0
- data/spec/data/DN20080506000741.nml +72 -0
- data/spec/data/DN20080506000785.nml +212 -0
- data/spec/data/DN20080506000839.nml +57 -0
- data/spec/djnml_codes_spec.rb +47 -0
- data/spec/djnml_spec.rb +477 -0
- data/spec/spec_helper.rb +12 -0
- metadata +157 -0
data/spec/djnml_spec.rb
ADDED
@@ -0,0 +1,477 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'djnml'
|
5
|
+
require 'digest/sha1'
|
6
|
+
require 'singleton'
|
7
|
+
|
8
|
+
|
9
|
+
class LanguageDetector
|
10
|
+
include Singleton
|
11
|
+
end
|
12
|
+
|
13
|
+
data_base = File.join(File.dirname(__FILE__), 'data')
|
14
|
+
story_file_en = File.join(data_base, 'DN20080506000785.nml')
|
15
|
+
story_file_de = File.join(data_base, '20120716162053366LL005062.NML')
|
16
|
+
story_file_internet = File.join(data_base, '20120716161436878LL001634.NML')
|
17
|
+
story_file_govt = File.join(data_base, 'DN20080506000839.nml')
|
18
|
+
story_file_admin = File.join(data_base, '20120716155056208LL000587.NML')
|
19
|
+
story_file_modify_replace_meta = File.join(data_base, 'DN20080506000741.nml')
|
20
|
+
story_file_modify_replace_headline = File.join(data_base, '20120720222918942LL007284.NML')
|
21
|
+
invalid_file = File.join(data_base, 'doesnt_exist.nml')
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
describe "DJNML raises errors when loading a file that doesn't exist" do
|
26
|
+
it "DJNML.load('#{invalid_file}') raises an DJNML::FileError" do
|
27
|
+
expect { DJNML.load(invalid_file) }.to raise_error(DJNML::FileError)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "load('#{invalid_file}') raises an DJNML::FileError" do
|
31
|
+
expect { DJNML.new.load(invalid_file) }.to raise_error(DJNML::FileError)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "DJNML.load('#{story_file_modify_replace_headline}') loads a Dow jones NML administration modify-replace story and parses it." do
|
36
|
+
before(:all) {
|
37
|
+
@djnml = DJNML.load(story_file_modify_replace_headline)
|
38
|
+
}
|
39
|
+
subject { @djnml }
|
40
|
+
|
41
|
+
let(:mod_0) { @djnml.modifications[0] }
|
42
|
+
let(:mod_1) { @djnml.modifications[1] }
|
43
|
+
let(:mod_2) { @djnml.modifications[2] }
|
44
|
+
let(:mod_3) { @djnml.modifications[3] }
|
45
|
+
let(:mod_4) { @djnml.modifications[4] }
|
46
|
+
let(:headline) { mod_0.headline }
|
47
|
+
let(:press_cutout) { mod_1.press_cutout }
|
48
|
+
let(:urgency) { mod_2.urgency }
|
49
|
+
let(:summary) { mod_4.summary }
|
50
|
+
let(:text) { mod_3.text }
|
51
|
+
|
52
|
+
it { should be }
|
53
|
+
its(:'modifications.size') { should == 5 }
|
54
|
+
|
55
|
+
it "subject.modifications.each.doc_date.should == #{Time.parse('20120720')}" do
|
56
|
+
mod_0.doc_date.should == Time.parse('20120720')
|
57
|
+
mod_1.doc_date.should == Time.parse('20120720')
|
58
|
+
mod_2.doc_date.should == Time.parse('20120720')
|
59
|
+
end
|
60
|
+
|
61
|
+
it "subject.modifications.each.product.should == 'LL'" do
|
62
|
+
mod_0.product.should == 'LL'
|
63
|
+
mod_1.product.should == 'LL'
|
64
|
+
mod_2.product.should == 'LL'
|
65
|
+
end
|
66
|
+
|
67
|
+
it "subject.modifications.each.publisher.should == 'DJN'" do
|
68
|
+
mod_0.publisher.should == 'DJN'
|
69
|
+
mod_1.publisher.should == 'DJN'
|
70
|
+
mod_2.publisher.should == 'DJN'
|
71
|
+
end
|
72
|
+
|
73
|
+
it "subject.modifications.each.seq.should == 7150" do
|
74
|
+
mod_0.seq.should == 7150
|
75
|
+
mod_1.seq.should == 7150
|
76
|
+
mod_2.seq.should == 7150
|
77
|
+
end
|
78
|
+
|
79
|
+
it "subject.modifications[0].headline.class.should == String" do
|
80
|
+
headline.class.should == String
|
81
|
+
end
|
82
|
+
|
83
|
+
it "subject.modifications[0].headline.should == 'Gobierno Brasil rebaja proyección crecimiento 2012 a 3,0%'" do
|
84
|
+
headline.should == 'Gobierno Brasil rebaja proyección crecimiento 2012 a 3,0%'
|
85
|
+
end
|
86
|
+
|
87
|
+
it "subject.modifications[2].urgency.class.should == String" do
|
88
|
+
urgency.class.should == String
|
89
|
+
end
|
90
|
+
|
91
|
+
it "subject.modifications[2].urgency.should == '0'" do
|
92
|
+
urgency.should == '0'
|
93
|
+
end
|
94
|
+
|
95
|
+
it "subject.modifications[1].press_cutout.class.should == String" do
|
96
|
+
press_cutout.class.should == String
|
97
|
+
end
|
98
|
+
|
99
|
+
it "subject.modifications[1].press_cutout.should == ''" do
|
100
|
+
press_cutout.should == ''
|
101
|
+
end
|
102
|
+
|
103
|
+
it "subject.modifications[4].xpath.should == ''" do
|
104
|
+
mod_4.xpath.should == 'djnml/body/summary'
|
105
|
+
end
|
106
|
+
|
107
|
+
it "subject.modifications[4].summary.text.should == 'test summary'" do
|
108
|
+
summary.text.should == 'test summary'
|
109
|
+
end
|
110
|
+
|
111
|
+
it "subject.modifications[4].summary.html.should == '<p>test summary</p>'" do
|
112
|
+
summary.html.should == '<p>test summary</p>'
|
113
|
+
end
|
114
|
+
|
115
|
+
it "subject.modifications[3].xpath.should == ''" do
|
116
|
+
mod_3.xpath.should == 'djnml/body/text'
|
117
|
+
end
|
118
|
+
|
119
|
+
it "subject.modifications[3].text.should == 'test paragraph'" do
|
120
|
+
text.text.should == 'test paragraph'
|
121
|
+
end
|
122
|
+
|
123
|
+
it "subject.modifications[3].html.should == '<p>test paragraph</p>'" do
|
124
|
+
text.html.should == '<p>test paragraph</p>'
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
describe "DJNML.load('#{story_file_modify_replace_meta}') loads a Dow jones NML administration modify-replace story and parses it." do
|
130
|
+
before(:all) {
|
131
|
+
@djnml = DJNML.load(story_file_modify_replace_meta)
|
132
|
+
}
|
133
|
+
subject { @djnml }
|
134
|
+
|
135
|
+
let(:mod) { @djnml.modifications[0] }
|
136
|
+
let(:mdata) { mod.mdata }
|
137
|
+
|
138
|
+
it { should be }
|
139
|
+
|
140
|
+
its(:'modifications.size') { should == 1 }
|
141
|
+
|
142
|
+
it "subject.modifications[0].xpath.should == 'djnml/head/docdata/djn/djn-newswires/djn-mdata'" do
|
143
|
+
mod.xpath.should == 'djnml/head/docdata/djn/djn-newswires/djn-mdata'
|
144
|
+
end
|
145
|
+
|
146
|
+
it "subject.modifications[0].doc_date.should == #{Time.parse('20080506')}" do
|
147
|
+
mod.doc_date.should == Time.parse('20080506')
|
148
|
+
end
|
149
|
+
|
150
|
+
it "subject.modifications[0].product.should == 'DN'" do
|
151
|
+
mod.product.should == 'DN'
|
152
|
+
end
|
153
|
+
|
154
|
+
it "subject.modifications[0].publisher.should == 'DJN'" do
|
155
|
+
mod.publisher.should == 'DJN'
|
156
|
+
end
|
157
|
+
|
158
|
+
it "subject.modifications[0].seq.should == 741" do
|
159
|
+
mod.seq.should == 741
|
160
|
+
end
|
161
|
+
|
162
|
+
it "subject.modifications[0].mdata.should be" do
|
163
|
+
mdata.class.should be
|
164
|
+
end
|
165
|
+
|
166
|
+
it "subject.modifications[0].mdata.class should == ::DJNML::Modification::Mdata" do
|
167
|
+
mdata.class.should == ::DJNML::Modification::Mdata
|
168
|
+
end
|
169
|
+
|
170
|
+
it "subject.modifications[0].mdata.company_code.should == %w(ADEN.VX)" do
|
171
|
+
mdata.company_code.should == %w(ADEN.VX)
|
172
|
+
end
|
173
|
+
|
174
|
+
it "subject.modifications[0].mdata.isin_code.should == %w(CH0012138605)" do
|
175
|
+
mdata.isin_code.should == %w(CH0012138605)
|
176
|
+
end
|
177
|
+
|
178
|
+
it "subject.modifications[0].mdata.industry_code.should == %w(I/EAG I/SVC I/XDJGI I/XSMI)" do
|
179
|
+
mdata.industry_code.map { |c| c.symbol }.should == %w(I/EAG I/SVC I/XDJGI I/XSMI)
|
180
|
+
end
|
181
|
+
|
182
|
+
it "subject.modifications[0].mdata.subject_code.should == %w(N/CMDI N/CMR N/DJCB N/DJEI N/DJEP N/DJGP N/DJGV N/DJI N/DJIN N/DJIV N/DJMO N/DJN N/DJPT N/DJWB N/ECR N/EUCM N/EWR N/WER N/BNEU N/CAC N/CNW N/DJPN N/DJS N/DJSS N/DJWI N/ERN N/FCTV N/TNW N/TSY N/WEI)" do
|
183
|
+
mdata.subject_code.map { |c| c.symbol }.should == %w(N/CMDI N/CMR N/DJCB N/DJEI N/DJEP N/DJGP N/DJGV N/DJI N/DJIN N/DJIV N/DJMO N/DJN N/DJPT N/DJWB N/ECR N/EUCM N/EWR N/WER N/BNEU N/CAC N/CNW N/DJPN N/DJS N/DJSS N/DJWI N/ERN N/FCTV N/TNW N/TSY N/WEI)
|
184
|
+
end
|
185
|
+
|
186
|
+
it "subject.modifications[0].mdata.market_code.should == %w(M/IDU M/NND)" do
|
187
|
+
mdata.market_code.map { |c| c.symbol }.should == %w(M/IDU M/NND)
|
188
|
+
end
|
189
|
+
|
190
|
+
it "subject.modifications[0].mdata.product_code.should == %w(P/RTRS)" do
|
191
|
+
mdata.product_code.map { |c| c.symbol }.should == %w(P/RTRS)
|
192
|
+
end
|
193
|
+
|
194
|
+
it "subject.modifications[0].mdata.geo_code.should == %w(R/EU R/SZ R/WEU)" do
|
195
|
+
mdata.geo_code.map { |c| c.symbol }.should == %w(R/EU R/SZ R/WEU)
|
196
|
+
end
|
197
|
+
|
198
|
+
it "subject.modifications[0].mdata.government_code.should == []" do
|
199
|
+
mdata.government_code.should == []
|
200
|
+
end
|
201
|
+
|
202
|
+
it "subject.modifications[0].mdata.page_code.should == []" do
|
203
|
+
mdata.page_code.should == []
|
204
|
+
end
|
205
|
+
|
206
|
+
it "subject.modifications[0].mdata.stat_code.should == []" do
|
207
|
+
mdata.stat_code.should == []
|
208
|
+
end
|
209
|
+
|
210
|
+
it "subject.modifications[0].mdata.journal_code.should == []" do
|
211
|
+
mdata.journal_code.should == []
|
212
|
+
end
|
213
|
+
|
214
|
+
it "subject.modifications[0].mdata.routing_code.should == []" do
|
215
|
+
mdata.routing_code.should == []
|
216
|
+
end
|
217
|
+
|
218
|
+
it "subject.modifications[0].mdata.content_code.should == []" do
|
219
|
+
mdata.content_code.should == []
|
220
|
+
end
|
221
|
+
|
222
|
+
it "subject.modifications[0].mdata.function_code.should == []" do
|
223
|
+
mdata.function_code.should == []
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
describe "DJNML.load('#{story_file_de}') loads a Dow jones NML story and parses it." do
|
228
|
+
before(:all) {
|
229
|
+
@djnml = DJNML.load(story_file_de)
|
230
|
+
}
|
231
|
+
subject { @djnml }
|
232
|
+
|
233
|
+
it { should be }
|
234
|
+
|
235
|
+
it "Language should be 'de'" do
|
236
|
+
subject.language.should == 'de'
|
237
|
+
end
|
238
|
+
|
239
|
+
its(:copyright_year) { should == 2012 }
|
240
|
+
its(:copyright_holder) { should == 'Dow Jones & Company, Inc.'}
|
241
|
+
|
242
|
+
it "should have content" do
|
243
|
+
subject.has_content?.should == true
|
244
|
+
end
|
245
|
+
|
246
|
+
end
|
247
|
+
|
248
|
+
describe "DJNML.load('#{story_file_internet}') loads a Dow jones NML story and parses it." do
|
249
|
+
before(:all) {
|
250
|
+
@djnml = DJNML.load(story_file_internet)
|
251
|
+
}
|
252
|
+
subject { @djnml }
|
253
|
+
|
254
|
+
it { should be }
|
255
|
+
|
256
|
+
it "Language should be 'en'" do
|
257
|
+
subject.language.should == 'en'
|
258
|
+
end
|
259
|
+
|
260
|
+
its(:website) { should == 'www.vossloh.com' }
|
261
|
+
its(:company_name) { should == 'Vossloh AG' }
|
262
|
+
its(:company_address) { should == 'Vosslohstr. 4' }
|
263
|
+
its(:company_zip) { should == '58791'}
|
264
|
+
its(:company_city) { should == 'Werdohl' }
|
265
|
+
end
|
266
|
+
|
267
|
+
describe "DJNML.load('#{story_file_en}') loads a Dow Jones NML story and parses it." do
|
268
|
+
before(:all) {
|
269
|
+
@djnml = DJNML.load(story_file_en)
|
270
|
+
}
|
271
|
+
subject { @djnml }
|
272
|
+
|
273
|
+
let(:html_sha1sum) {
|
274
|
+
Digest::SHA1.hexdigest(subject.html)
|
275
|
+
}
|
276
|
+
|
277
|
+
let(:text_sha1sum) {
|
278
|
+
Digest::SHA1.hexdigest(subject.text)
|
279
|
+
}
|
280
|
+
|
281
|
+
it { should be }
|
282
|
+
|
283
|
+
# doc
|
284
|
+
#
|
285
|
+
its(:msize) { should == 11410 }
|
286
|
+
its(:md5) { should == '7abbf5047fee493e144efefbdf28c9f0' }
|
287
|
+
its(:sys_id) { should == 'dcmn2p1' }
|
288
|
+
its(:destination) { should == 'AW' }
|
289
|
+
its(:dist_id) { should == 'AMD6' }
|
290
|
+
its(:transmission_date) { should == Time.parse('20080506T053501Z') }
|
291
|
+
|
292
|
+
# djnml
|
293
|
+
#
|
294
|
+
its(:publisher) { should == 'DJN' }
|
295
|
+
its(:doc_date) { should == Time.parse('2008-05-06') }
|
296
|
+
its(:product) { should == 'DN' }
|
297
|
+
its(:seq) { should == 785 }
|
298
|
+
its(:lang) { should == 'en-us' }
|
299
|
+
|
300
|
+
# djn-newswires
|
301
|
+
#
|
302
|
+
its(:news_source) { should == 'DJDN' }
|
303
|
+
its(:origin) { should == 'DJ' }
|
304
|
+
its(:service_id) { should == 'CO' }
|
305
|
+
|
306
|
+
# djn-urgency
|
307
|
+
#
|
308
|
+
its(:urgency) { should == 0 }
|
309
|
+
|
310
|
+
# djn-mdata
|
311
|
+
#
|
312
|
+
its(:brand) { should == 'DJ' }
|
313
|
+
its(:temp_perm) { should == 'P' }
|
314
|
+
its(:retention) { should == 'N' }
|
315
|
+
its(:hot) { should == 'N' }
|
316
|
+
its(:original_source) { should == 'T' }
|
317
|
+
its(:accession_number) { should == '20080506000785' }
|
318
|
+
its(:page_citation) { should == '' }
|
319
|
+
its(:display_date) { should == Time.parse('20080506T0535Z') }
|
320
|
+
|
321
|
+
# codes / company
|
322
|
+
#
|
323
|
+
its(:company_code) { should == %w(ADDYY ADS.XE) }
|
324
|
+
|
325
|
+
# codes / isin
|
326
|
+
#
|
327
|
+
its(:isin_code) { should == %w(DE0005003404) }
|
328
|
+
|
329
|
+
# codes / page
|
330
|
+
#
|
331
|
+
its(:page_code) { should == [] }
|
332
|
+
|
333
|
+
# code / industry
|
334
|
+
#
|
335
|
+
it "industry_code should consist of these symbols: I/FOT I/TEX I/XDAX I/XDJGI I/XISL." do
|
336
|
+
subject.industry_code.map { |c| c.symbol }.should == %w(I/FOT I/TEX I/XDAX I/XDJGI I/XISL)
|
337
|
+
end
|
338
|
+
|
339
|
+
it "industry_code[0].name.should == 'Footwear'" do
|
340
|
+
subject.industry_code[0].name.should == 'Footwear'
|
341
|
+
end
|
342
|
+
|
343
|
+
# code / subject
|
344
|
+
#
|
345
|
+
it "subject_code should consist of these symbols: N/DJCB N/DJEI N/DJEP N/DJFP N/DJGP N/DJGS N/DJGV N/DJI N/DJIN N/DJIV N/DJN N/DJPT N/DJWB N/WER N/ADR N/CAC N/CNW N/DJPN N/DJWI N/ERN N/PRL N/TPCT N/WEI." do
|
346
|
+
subject.subject_code.map { |c| c.symbol }.should == %w(N/DJCB N/DJEI N/DJEP N/DJFP N/DJGP N/DJGS N/DJGV N/DJI N/DJIN N/DJIV N/DJN
|
347
|
+
N/DJPT N/DJWB N/WER N/ADR N/CAC N/CNW N/DJPN N/DJWI N/ERN N/PRL N/TPCT N/WEI )
|
348
|
+
end
|
349
|
+
|
350
|
+
it "subject_code[0].name.should == 'Dow Jones Corporate Bond Service'" do
|
351
|
+
subject.subject_code[0].name.should == 'Dow Jones Corporate Bond Service'
|
352
|
+
end
|
353
|
+
|
354
|
+
# code / market
|
355
|
+
#
|
356
|
+
it "market_code should consist of these symbols: M/MMR M/NCY M/TPX" do
|
357
|
+
subject.market_code.map { |c| c.symbol }.should == %w(M/MMR M/NCY M/TPX)
|
358
|
+
end
|
359
|
+
|
360
|
+
it "market_code[0].name.should == 'More News to Follow'" do
|
361
|
+
subject.market_code[0].name.should == 'More News to Follow'
|
362
|
+
end
|
363
|
+
|
364
|
+
# code / product
|
365
|
+
#
|
366
|
+
it "product_code should consist of these symbols: P/TAP" do
|
367
|
+
subject.product_code.map { |c| c.symbol }.should == %w(P/TAP)
|
368
|
+
end
|
369
|
+
|
370
|
+
it "product_code[0].name.should == 'Press Releases Auto-Published on Ticker'" do
|
371
|
+
subject.product_code[0].name.should == 'Press Releases Auto-Published on Ticker'
|
372
|
+
end
|
373
|
+
|
374
|
+
# code / geo
|
375
|
+
#
|
376
|
+
it "geo_code should consist of these symbols: R/EC R/EU R/GE R/WEU" do
|
377
|
+
subject.geo_code.map { |c| c.symbol }.should == %w(R/EC R/EU R/GE R/WEU)
|
378
|
+
end
|
379
|
+
|
380
|
+
it "geo_code[0].name.should == 'European Union'" do
|
381
|
+
subject.geo_code[0].name.should == 'European Union'
|
382
|
+
end
|
383
|
+
|
384
|
+
# empty codes
|
385
|
+
#
|
386
|
+
its(:stat_code) { should == [] }
|
387
|
+
its(:journal_code) { should == [] }
|
388
|
+
its(:routing_code) { should == [] }
|
389
|
+
its(:content_code) { should == [] }
|
390
|
+
its(:function_code) { should == [] }
|
391
|
+
|
392
|
+
# body / headline
|
393
|
+
#
|
394
|
+
its(:headline) { should == 'PRESS RELEASE: adidas Group: First Quarter 2008 Results' }
|
395
|
+
its(:headline_brand) { should == nil }
|
396
|
+
|
397
|
+
|
398
|
+
# body / text as html
|
399
|
+
#
|
400
|
+
it "html checksum should be 143f70beac7ca84f3d5f320afe602603e728ee72" do
|
401
|
+
html_sha1sum.should == '5b2f356bb4bff2c6ccbe6ad70754952aff926235'
|
402
|
+
end
|
403
|
+
|
404
|
+
# body / text as plain text
|
405
|
+
#
|
406
|
+
it "text checksum should be 27a547372614d04b81c4334bb3902a8a7d980bd4" do
|
407
|
+
text_sha1sum.should == '27a547372614d04b81c4334bb3902a8a7d980bd4'
|
408
|
+
end
|
409
|
+
|
410
|
+
it "Language should be 'en'" do
|
411
|
+
subject.language.should == 'en'
|
412
|
+
end
|
413
|
+
|
414
|
+
end
|
415
|
+
|
416
|
+
describe "DJNML.load('#{story_file_admin}') loads an Dow Jones admin NML file and parses it." do
|
417
|
+
before(:all) {
|
418
|
+
@djnml = DJNML.load(story_file_admin)
|
419
|
+
}
|
420
|
+
subject { @djnml }
|
421
|
+
|
422
|
+
let(:delete_0) { @djnml.delete.first }
|
423
|
+
let(:delete_1) { @djnml.delete.last }
|
424
|
+
|
425
|
+
it { should be }
|
426
|
+
its(:msize) { should == 1968 }
|
427
|
+
its(:md5) { should == '88d754f61ba4361c72a6a6dd0d2d00d5' }
|
428
|
+
its(:seq) { should == 587 }
|
429
|
+
its(:doc_date) { should == Time.parse('20120713') }
|
430
|
+
|
431
|
+
its(:"delete.size") { should == 20 }
|
432
|
+
|
433
|
+
it "should not have content" do
|
434
|
+
subject.has_content?.should == false
|
435
|
+
end
|
436
|
+
|
437
|
+
it "delete.first.product should == 'LL'" do
|
438
|
+
delete_0.product.should == 'LL'
|
439
|
+
end
|
440
|
+
|
441
|
+
it "delete.first.doc_date should == #{Time.parse('20110608')}" do
|
442
|
+
delete_0.doc_date.should == Time.parse('20110608')
|
443
|
+
end
|
444
|
+
|
445
|
+
it "delete.first.seq should == 1579" do
|
446
|
+
delete_0.seq.should == 1579
|
447
|
+
end
|
448
|
+
|
449
|
+
it "delete.first.publisher should == 'DJN'" do
|
450
|
+
delete_0.publisher.should == 'DJN'
|
451
|
+
end
|
452
|
+
|
453
|
+
it "delete.first.reason should == 'expire'" do
|
454
|
+
delete_0.reason.should == 'expire'
|
455
|
+
end
|
456
|
+
|
457
|
+
it "delete.last.product should == 'LL'" do
|
458
|
+
delete_1.product.should == 'LL'
|
459
|
+
end
|
460
|
+
|
461
|
+
it "delete.last.doc_date should == #{Time.parse('20110608')}" do
|
462
|
+
delete_1.doc_date.should == Time.parse('20110608')
|
463
|
+
end
|
464
|
+
|
465
|
+
it "delete.last.seq should == 1598" do
|
466
|
+
delete_1.seq.should == 1598
|
467
|
+
end
|
468
|
+
|
469
|
+
it "delete.last.publisher should == 'DJN'" do
|
470
|
+
delete_1.publisher.should == 'DJN'
|
471
|
+
end
|
472
|
+
|
473
|
+
it "delete.last.reason should == 'expire'" do
|
474
|
+
delete_1.reason.should == 'expire'
|
475
|
+
end
|
476
|
+
|
477
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'djnml'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: djnml
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.2
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tobias Begalke
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2012-07-30 00:00:00 +02:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: nokogiri
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: language_detector
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: rspec
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.8.0
|
46
|
+
type: :development
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: rdoc
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "3.12"
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: bundler
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 1.0.0
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: *id005
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: jeweler
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ~>
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.8.4
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: *id006
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: simplecov
|
84
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: "0"
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: *id007
|
93
|
+
description: This ruby library parses Dow Jones NML files into a DJNML object
|
94
|
+
email: elcamino@spyz.org
|
95
|
+
executables: []
|
96
|
+
|
97
|
+
extensions: []
|
98
|
+
|
99
|
+
extra_rdoc_files:
|
100
|
+
- LICENSE.txt
|
101
|
+
- README.rdoc
|
102
|
+
files:
|
103
|
+
- .document
|
104
|
+
- .rspec
|
105
|
+
- Gemfile
|
106
|
+
- LICENSE.txt
|
107
|
+
- README.rdoc
|
108
|
+
- Rakefile
|
109
|
+
- VERSION
|
110
|
+
- djnml.gemspec
|
111
|
+
- lib/djnml.rb
|
112
|
+
- lib/djnml/codes.rb
|
113
|
+
- lib/djnml/delete.rb
|
114
|
+
- lib/djnml/modification.rb
|
115
|
+
- spec/data/20120716155056208LL000587.NML
|
116
|
+
- spec/data/20120716161436878LL001634.NML
|
117
|
+
- spec/data/20120716162053366LL005062.NML
|
118
|
+
- spec/data/20120720222918942LL007284.NML
|
119
|
+
- spec/data/DN20080506000741.nml
|
120
|
+
- spec/data/DN20080506000785.nml
|
121
|
+
- spec/data/DN20080506000839.nml
|
122
|
+
- spec/djnml_codes_spec.rb
|
123
|
+
- spec/djnml_spec.rb
|
124
|
+
- spec/spec_helper.rb
|
125
|
+
has_rdoc: true
|
126
|
+
homepage: http://github.com/elcamino/djnml
|
127
|
+
licenses:
|
128
|
+
- BSD
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
hash: 4435593055381432029
|
140
|
+
segments:
|
141
|
+
- 0
|
142
|
+
version: "0"
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: "0"
|
149
|
+
requirements: []
|
150
|
+
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 1.6.2
|
153
|
+
signing_key:
|
154
|
+
specification_version: 3
|
155
|
+
summary: A ruby library to parse Dow Jones NML newsfeed files
|
156
|
+
test_files: []
|
157
|
+
|