xbrlware-ce 1.0.2
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/Copying.txt +13 -0
- data/License.txt +13 -0
- data/Rakefile.rb +124 -0
- data/Readme.txt +15 -0
- data/doc/classes/Edgar.html +144 -0
- data/doc/classes/Edgar/HTMLFeedDownloader.html +199 -0
- data/doc/classes/Edgar/RSSFeedDownloader.html +225 -0
- data/doc/classes/Xbrlware.html +350 -0
- data/doc/classes/Xbrlware/Context.html +429 -0
- data/doc/classes/Xbrlware/Entity.html +323 -0
- data/doc/classes/Xbrlware/Identifier.html +191 -0
- data/doc/classes/Xbrlware/Instance.html +742 -0
- data/doc/classes/Xbrlware/Item.html +278 -0
- data/doc/classes/Xbrlware/LBConstants.html +144 -0
- data/doc/classes/Xbrlware/Linkbase.html +131 -0
- data/doc/classes/Xbrlware/Linkbase/CalculationLinkbase.html +212 -0
- data/doc/classes/Xbrlware/Linkbase/CalculationLinkbase/Calculation.html +172 -0
- data/doc/classes/Xbrlware/Linkbase/CalculationLinkbase/Calculation/CalculationArc.html +166 -0
- data/doc/classes/Xbrlware/Linkbase/DefinitionLinkbase.html +210 -0
- data/doc/classes/Xbrlware/Linkbase/DefinitionLinkbase/Definition.html +204 -0
- data/doc/classes/Xbrlware/Linkbase/DefinitionLinkbase/Definition/DefinitionArc.html +160 -0
- data/doc/classes/Xbrlware/Linkbase/LabelLinkbase.html +239 -0
- data/doc/classes/Xbrlware/Linkbase/LabelLinkbase/Label.html +189 -0
- data/doc/classes/Xbrlware/Linkbase/Linkbase.html +172 -0
- data/doc/classes/Xbrlware/Linkbase/Linkbase/Link.html +217 -0
- data/doc/classes/Xbrlware/Linkbase/Linkbase/Link/Arc.html +284 -0
- data/doc/classes/Xbrlware/Linkbase/PresentationLinkbase.html +224 -0
- data/doc/classes/Xbrlware/Linkbase/PresentationLinkbase/Presentation.html +222 -0
- data/doc/classes/Xbrlware/Linkbase/PresentationLinkbase/Presentation/PresentationArc.html +160 -0
- data/doc/classes/Xbrlware/Taxonomy.html +369 -0
- data/doc/classes/Xbrlware/TaxonomyDefintion.html +177 -0
- data/doc/classes/Xbrlware/Unit.html +179 -0
- data/doc/classes/Xbrlware/Unit/Divide.html +165 -0
- data/doc/created.rid +1 -0
- data/doc/files/Readme_txt.html +124 -0
- data/doc/files/lib/edgar/edgar_data_downloader_rb.html +129 -0
- data/doc/files/lib/edgar/util_rb.html +129 -0
- data/doc/files/lib/edgar_rb.html +141 -0
- data/doc/files/lib/xbrlware/constants_rb.html +129 -0
- data/doc/files/lib/xbrlware/context_rb.html +129 -0
- data/doc/files/lib/xbrlware/date_util_rb.html +129 -0
- data/doc/files/lib/xbrlware/float_patch_rb.html +129 -0
- data/doc/files/lib/xbrlware/hash_util_rb.html +129 -0
- data/doc/files/lib/xbrlware/instance_rb.html +129 -0
- data/doc/files/lib/xbrlware/item_rb.html +129 -0
- data/doc/files/lib/xbrlware/linkbase/calculation_linkbase_rb.html +129 -0
- data/doc/files/lib/xbrlware/linkbase/definition_linkbase_rb.html +129 -0
- data/doc/files/lib/xbrlware/linkbase/label_linkbase_rb.html +129 -0
- data/doc/files/lib/xbrlware/linkbase/linkbase_rb.html +129 -0
- data/doc/files/lib/xbrlware/linkbase/presentation_linkbase_rb.html +129 -0
- data/doc/files/lib/xbrlware/meta_util_rb.html +129 -0
- data/doc/files/lib/xbrlware/taxonomy_rb.html +129 -0
- data/doc/files/lib/xbrlware/unit_rb.html +129 -0
- data/doc/files/lib/xbrlware/util_rb.html +129 -0
- data/doc/files/lib/xbrlware/xml_parser_rb.html +129 -0
- data/doc/files/lib/xbrlware_rb.html +163 -0
- data/doc/fr_class_index.html +55 -0
- data/doc/fr_file_index.html +48 -0
- data/doc/fr_method_index.html +104 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/example/benchmark/instance_parser_benchmark.rb +25 -0
- data/example/case_study/buy_strategy.rb +34 -0
- data/example/case_study/c-20091230.xml +29 -0
- data/example/case_study/c_sell_strategy.rb +29 -0
- data/example/lang_integration/thrift/rating-client.py +21 -0
- data/example/lang_integration/thrift/rating-impl.rb +13 -0
- data/example/lang_integration/thrift/rating-server.rb +25 -0
- data/example/lang_integration/thrift/rating.thrift +52 -0
- data/example/quick_start/foo.rb +10 -0
- data/example/quick_start/foo.xml +29 -0
- data/example/quick_start/print_item.rb +27 -0
- data/lib/edgar.rb +30 -0
- data/lib/edgar/edgar_data_downloader.rb +126 -0
- data/lib/edgar/util.rb +30 -0
- data/lib/xbrlware.rb +65 -0
- data/lib/xbrlware/constants.rb +29 -0
- data/lib/xbrlware/context.rb +148 -0
- data/lib/xbrlware/date_util.rb +35 -0
- data/lib/xbrlware/float_patch.rb +26 -0
- data/lib/xbrlware/hash_util.rb +175 -0
- data/lib/xbrlware/instance.rb +406 -0
- data/lib/xbrlware/item.rb +115 -0
- data/lib/xbrlware/linkbase/calculation_linkbase.rb +137 -0
- data/lib/xbrlware/linkbase/definition_linkbase.rb +186 -0
- data/lib/xbrlware/linkbase/label_linkbase.rb +128 -0
- data/lib/xbrlware/linkbase/linkbase.rb +170 -0
- data/lib/xbrlware/linkbase/presentation_linkbase.rb +160 -0
- data/lib/xbrlware/meta_util.rb +45 -0
- data/lib/xbrlware/taxonomies/us_gaap_taxonomy_20090131.rb +40365 -0
- data/lib/xbrlware/taxonomy.rb +133 -0
- data/lib/xbrlware/unit.rb +42 -0
- data/lib/xbrlware/util.rb +83 -0
- data/lib/xbrlware/xml_parser.rb +122 -0
- data/setup.rb +1585 -0
- data/test/lib/edgar/edgar_data_downloader_test.rb +35 -0
- data/test/lib/edgar/resources/0000930413-09-005485-index.htm +331 -0
- data/test/lib/edgar/resources/usgaap.rss.xml +2861 -0
- data/test/lib/xbrlware/411_footnotes_test.rb +65 -0
- data/test/lib/xbrlware/42_schemaref_test.rb +20 -0
- data/test/lib/xbrlware/46_item_test.rb +253 -0
- data/test/lib/xbrlware/47_context_test.rb +129 -0
- data/test/lib/xbrlware/48_unit_test.rb +45 -0
- data/test/lib/xbrlware/49_tuple_test.rb +12 -0
- data/test/lib/xbrlware/date_util_test.rb +24 -0
- data/test/lib/xbrlware/dimension/context_explicit_dimension_test.rb +40 -0
- data/test/lib/xbrlware/dimension/resources/context_explicit_dimension.xml +84 -0
- data/test/lib/xbrlware/float_patch_test.rb +10 -0
- data/test/lib/xbrlware/hash_util_test.rb +29 -0
- data/test/lib/xbrlware/instance_test.rb +250 -0
- data/test/lib/xbrlware/linkbase/calculation_linkbase_test.rb +39 -0
- data/test/lib/xbrlware/linkbase/definition_linkbase_test.rb +35 -0
- data/test/lib/xbrlware/linkbase/label_linkbase_test.rb +22 -0
- data/test/lib/xbrlware/linkbase/linkbase_test.rb +36 -0
- data/test/lib/xbrlware/linkbase/linkbase_test_util.rb +98 -0
- data/test/lib/xbrlware/linkbase/presentation_linkbase_test.rb +33 -0
- data/test/lib/xbrlware/linkbase/report.html +62 -0
- data/test/lib/xbrlware/linkbase/resources/cal.xml +219 -0
- data/test/lib/xbrlware/linkbase/resources/def.xml +186 -0
- data/test/lib/xbrlware/linkbase/resources/def_with_multiple_dimension.xml +41 -0
- data/test/lib/xbrlware/linkbase/resources/instance.xml +5822 -0
- data/test/lib/xbrlware/linkbase/resources/lab.xml +782 -0
- data/test/lib/xbrlware/linkbase/resources/pre.xml +485 -0
- data/test/lib/xbrlware/linkbase/resources/report_10_q.htm +12327 -0
- data/test/lib/xbrlware/linkbase/resources/taxonomy.xsd +178 -0
- data/test/lib/xbrlware/linkbase/sample_html_report.html +40 -0
- data/test/lib/xbrlware/meta_util_test.rb +23 -0
- data/test/lib/xbrlware/resources/411/411_footnotes.xml +66 -0
- data/test/lib/xbrlware/resources/42/42_schema_ref_with_base.xml +7 -0
- data/test/lib/xbrlware/resources/42/42_schema_ref_without_base.xml +7 -0
- data/test/lib/xbrlware/resources/46/46_item_value.xml +61 -0
- data/test/lib/xbrlware/resources/47/472_period_forever.xml +29 -0
- data/test/lib/xbrlware/resources/47/472_period_instant.xml +24 -0
- data/test/lib/xbrlware/resources/47/472_period_start_dt_and_end_dt.xml +30 -0
- data/test/lib/xbrlware/resources/47/4731_entity_identifier.xml +29 -0
- data/test/lib/xbrlware/resources/47/4732_entity_segment_not_present.xml +24 -0
- data/test/lib/xbrlware/resources/47/4732_entity_segment_present.xml +30 -0
- data/test/lib/xbrlware/resources/47/474_scenario_not_present.xml +26 -0
- data/test/lib/xbrlware/resources/47/474_scenario_present.xml +30 -0
- data/test/lib/xbrlware/resources/47/47_multiple_contexts.xml +36 -0
- data/test/lib/xbrlware/resources/48/482_unit_measure.xml +32 -0
- data/test/lib/xbrlware/resources/48/483_unit_divide.xml +39 -0
- data/test/lib/xbrlware/resources/48/48_multiple_units.xml +43 -0
- data/test/lib/xbrlware/resources/49/49_tuple.xml +61 -0
- data/test/lib/xbrlware/resources/49_tuple.xsd +44 -0
- data/test/lib/xbrlware/resources/instance.xml +128 -0
- data/test/lib/xbrlware/resources/report_test_xbrl_files/cal.xml +219 -0
- data/test/lib/xbrlware/resources/report_test_xbrl_files/def.xml +186 -0
- data/test/lib/xbrlware/resources/report_test_xbrl_files/instance.xml +5822 -0
- data/test/lib/xbrlware/resources/report_test_xbrl_files/lab.xml +782 -0
- data/test/lib/xbrlware/resources/report_test_xbrl_files/pre.xml +485 -0
- data/test/lib/xbrlware/resources/report_test_xbrl_files/report/report_index.html +62 -0
- data/test/lib/xbrlware/resources/report_test_xbrl_files/taxonomy.xsd +178 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/1/cal.xml +223 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/1/def.xml +190 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/1/lab.xml +786 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/1/pre.xml +489 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/1/taxonomy.xsd +177 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/2/linkbases/cal.xml +223 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/2/linkbases/def.xml +190 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/2/linkbases/lab.xml +786 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/2/linkbases/pre.xml +489 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/2/taxonomy.xsd +175 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/3/taxonomy.xsd +175 -0
- data/test/lib/xbrlware/resources/us_gaap_schema.xsd +8 -0
- data/test/lib/xbrlware/resources/us_gaap_schema_local.xsd +10 -0
- data/test/lib/xbrlware/resources/util_test_xbrl_files/cal.xml +219 -0
- data/test/lib/xbrlware/resources/util_test_xbrl_files/def.xml +186 -0
- data/test/lib/xbrlware/resources/util_test_xbrl_files/instance.xml +5822 -0
- data/test/lib/xbrlware/resources/util_test_xbrl_files/lab.xml +782 -0
- data/test/lib/xbrlware/resources/util_test_xbrl_files/pre.xml +485 -0
- data/test/lib/xbrlware/resources/util_test_xbrl_files/taxonomy.xsd +178 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/dei-2009-01-31.xsd +162 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/dei-std-2009-01-31.xsd +23 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/negated-2008-03-31.xsd +23 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/ref-2006-02-27.xsd +121 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/us-gaap-2009-01-31.xsd +13474 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/us-roles-2009-01-31.xsd +2283 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/us-types-2009-01-31.xsd +368 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/xbrl-instance-2003-12-31.xsd +772 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/xbrl-linkbase-2003-12-31.xsd +477 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/xbrldi-2006.xsd +41 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/xbrldt-2005.xsd +53 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/xl-2003-12-31.xsd +246 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/xlink-2003-12-31.xsd +117 -0
- data/test/lib/xbrlware/taxonomy_test.rb +124 -0
- data/test/lib/xbrlware/util_test.rb +18 -0
- data/test/lib/xbrlware/xml_parser_test.rb +142 -0
- data/test/schema_validator_jruby.rb +40 -0
- data/test/schema_validator_ruby.rb +7 -0
- data/test/scratchpad/block.rb +36 -0
- data/test/test_helper.rb +21 -0
- data/xbrlware.iml +30 -0
- metadata +261 -0
data/lib/edgar/util.rb
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
#
|
|
3
|
+
# Author:: xbrlware@bitstat.com
|
|
4
|
+
#
|
|
5
|
+
# Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved.
|
|
6
|
+
#
|
|
7
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
16
|
+
# implied.
|
|
17
|
+
# See the License for the specific language governing permissions and
|
|
18
|
+
# limitations under the License.
|
|
19
|
+
#
|
|
20
|
+
module Edgar
|
|
21
|
+
module FileUtil # :nodoc:
|
|
22
|
+
def mkdir(dir)
|
|
23
|
+
File.makedirs(dir) unless File.directory?(dir)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def dump_to_file(file, content)
|
|
27
|
+
File.open(file, 'w') {|f| f.write(content) }
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
data/lib/xbrlware.rb
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
#
|
|
3
|
+
# Author:: xbrlware@bitstat.com
|
|
4
|
+
#
|
|
5
|
+
# Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved.
|
|
6
|
+
#
|
|
7
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
16
|
+
# implied.
|
|
17
|
+
# See the License for the specific language governing permissions and
|
|
18
|
+
# limitations under the License.
|
|
19
|
+
#
|
|
20
|
+
require 'rubygems'
|
|
21
|
+
gem 'xml-simple', '= 1.0.12'
|
|
22
|
+
require 'xmlsimple'
|
|
23
|
+
|
|
24
|
+
require 'date'
|
|
25
|
+
require 'bigdecimal'
|
|
26
|
+
require 'erb'
|
|
27
|
+
require 'set'
|
|
28
|
+
require "stringio"
|
|
29
|
+
require 'cgi'
|
|
30
|
+
|
|
31
|
+
require 'xbrlware/float_patch'
|
|
32
|
+
require 'xbrlware/meta_util'
|
|
33
|
+
require 'xbrlware/hash_util'
|
|
34
|
+
require 'xbrlware/date_util'
|
|
35
|
+
require 'xbrlware/xml_parser'
|
|
36
|
+
|
|
37
|
+
require 'xbrlware/constants'
|
|
38
|
+
require 'xbrlware/util'
|
|
39
|
+
|
|
40
|
+
require 'xbrlware/taxonomies/us_gaap_taxonomy_20090131'
|
|
41
|
+
require 'xbrlware/taxonomy'
|
|
42
|
+
|
|
43
|
+
require 'xbrlware/context'
|
|
44
|
+
require 'xbrlware/instance'
|
|
45
|
+
require 'xbrlware/unit'
|
|
46
|
+
require 'xbrlware/item'
|
|
47
|
+
|
|
48
|
+
require 'xbrlware/linkbase/linkbase'
|
|
49
|
+
require 'xbrlware/linkbase/label_linkbase'
|
|
50
|
+
require 'xbrlware/linkbase/calculation_linkbase'
|
|
51
|
+
require 'xbrlware/linkbase/definition_linkbase'
|
|
52
|
+
require 'xbrlware/linkbase/presentation_linkbase'
|
|
53
|
+
|
|
54
|
+
require 'logger'
|
|
55
|
+
require 'benchmark'
|
|
56
|
+
|
|
57
|
+
ENV["TAXO_NAME"]="US-GAAP"
|
|
58
|
+
ENV["TAXO_VER"]="20090131"
|
|
59
|
+
|
|
60
|
+
$LOG = Logger.new($stdout)
|
|
61
|
+
$LOG.level = Logger::INFO
|
|
62
|
+
|
|
63
|
+
def bm(title, measure) # :nodoc:
|
|
64
|
+
$LOG.debug title +" [ u :"+measure.utime.to_s+", s :"+measure.stime.to_s+", t :"+measure.total.to_s+", r :"+measure.real.to_s+"]"
|
|
65
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
#
|
|
3
|
+
# Author:: xbrlware@bitstat.com
|
|
4
|
+
#
|
|
5
|
+
# Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved.
|
|
6
|
+
#
|
|
7
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
16
|
+
# implied.
|
|
17
|
+
# See the License for the specific language governing permissions and
|
|
18
|
+
# limitations under the License.
|
|
19
|
+
#
|
|
20
|
+
module Xbrlware
|
|
21
|
+
# Linkbase constants
|
|
22
|
+
module LBConstants
|
|
23
|
+
CALCULATION="http://www.xbrl.org/2003/role/calculationLinkbaseRef"
|
|
24
|
+
DEFINITION="http://www.xbrl.org/2003/role/definitionLinkbaseRef"
|
|
25
|
+
PRESENTATION="http://www.xbrl.org/2003/role/presentationLinkbaseRef"
|
|
26
|
+
LABEL="http://www.xbrl.org/2003/role/labelLinkbaseRef"
|
|
27
|
+
REFERENCE="http://www.xbrl.org/2003/role/referenceLinkbaseRef"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
#
|
|
3
|
+
# Author:: xbrlware@bitstat.com
|
|
4
|
+
#
|
|
5
|
+
# Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved.
|
|
6
|
+
#
|
|
7
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
16
|
+
# implied.
|
|
17
|
+
# See the License for the specific language governing permissions and
|
|
18
|
+
# limitations under the License.
|
|
19
|
+
#
|
|
20
|
+
module Xbrlware
|
|
21
|
+
# This class represents each context in the XBRL instance file.
|
|
22
|
+
# Look at {delaing with instance page on xbrlware wiki}[http://code.google.com/p/xbrlware/wiki/InstanceTaxonomy] for more details.
|
|
23
|
+
class Context
|
|
24
|
+
attr_reader :id,:entity,:period, :scenario
|
|
25
|
+
PERIOD_FOREVER = -1
|
|
26
|
+
def initialize(id,entity,period, scenario=nil)
|
|
27
|
+
@id = id
|
|
28
|
+
@entity = entity
|
|
29
|
+
@period = period
|
|
30
|
+
@scenario=scenario
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def to_s
|
|
34
|
+
"Id [" + id + "], Entity { " + @entity.to_s + " }, period ["+period.to_s+"]"+ (", scenario ["+scenario+"]" unless scenario.nil?).to_s
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def eql?(o)
|
|
38
|
+
o.is_a?(Context) && @id == o.id
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def hash
|
|
42
|
+
@id.hash
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def has_explicit_dimensions?(dimensions=[])
|
|
46
|
+
return @entity.has_explicit_dimensions?(dimensions) unless @entity.nil?
|
|
47
|
+
false
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
alias_method :has_dimensions?, :has_explicit_dimensions?
|
|
51
|
+
|
|
52
|
+
def explicit_dimensions
|
|
53
|
+
return @entity.explicit_dimensions
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
alias_method :dimensions, :explicit_dimensions
|
|
57
|
+
|
|
58
|
+
def explicit_domains(dimensions=[])
|
|
59
|
+
return @entity.explicit_domains(dimensions)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
alias_method :domains, :explicit_domains
|
|
63
|
+
|
|
64
|
+
def explicit_dimensions_domains
|
|
65
|
+
return @entity.explicit_dimensions_domains
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
alias_method :dimensions_domains, :explicit_dimensions_domains
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
class Entity
|
|
73
|
+
attr_reader :identifier,:segment
|
|
74
|
+
def initialize(identifier,segment=nil)
|
|
75
|
+
@identifier = identifier
|
|
76
|
+
@segment = segment
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def to_s
|
|
80
|
+
"Identifier { " + @identifier.to_s + " } " + (", segment [" + segment.to_s + "]" unless segment.nil?).to_s
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def has_explicit_dimensions?(dimensions=[])
|
|
84
|
+
dimensions_set=Set.new
|
|
85
|
+
dimensions_set.merge(dimensions)
|
|
86
|
+
unless @segment.nil? || @segment["explicitMember"].nil?
|
|
87
|
+
|
|
88
|
+
return true if dimensions.size==0
|
|
89
|
+
|
|
90
|
+
dim = Set.new
|
|
91
|
+
@segment["explicitMember"].each do |member|
|
|
92
|
+
dim << member["dimension"]
|
|
93
|
+
end
|
|
94
|
+
return dim.superset?(dimensions_set)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
return false
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def explicit_dimensions
|
|
101
|
+
dim = Set.new
|
|
102
|
+
unless @segment.nil? || @segment["explicitMember"].nil?
|
|
103
|
+
@segment["explicitMember"].each do |member|
|
|
104
|
+
dim << member["dimension"]
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
return dim.to_a
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def explicit_domains(dimensions=[])
|
|
111
|
+
dom = Set.new
|
|
112
|
+
if has_explicit_dimensions?(dimensions)
|
|
113
|
+
@segment["explicitMember"].each do |member|
|
|
114
|
+
dimensions=explicit_dimensions if dimensions.size==0
|
|
115
|
+
dimensions.each do |dim|
|
|
116
|
+
next unless dim==member["dimension"]
|
|
117
|
+
dom << member["content"]
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
return dom.to_a
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def explicit_dimensions_domains
|
|
125
|
+
dim_dom={}
|
|
126
|
+
if has_explicit_dimensions?
|
|
127
|
+
@segment["explicitMember"].each do |member|
|
|
128
|
+
dim_dom[member["dimension"]]=[] if dim_dom[member["dimension"]].nil?
|
|
129
|
+
dim_dom[member["dimension"]] << member["content"]
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
return dim_dom
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
class Identifier
|
|
138
|
+
attr_reader :value,:scheme
|
|
139
|
+
def initialize(scheme,value)
|
|
140
|
+
@scheme = scheme
|
|
141
|
+
@value = value
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def to_s
|
|
145
|
+
"schema [" + @scheme.to_s + "], value [" + @value.to_s + "]"
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
#
|
|
3
|
+
# Author:: xbrlware@bitstat.com
|
|
4
|
+
#
|
|
5
|
+
# Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved.
|
|
6
|
+
#
|
|
7
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
16
|
+
# implied.
|
|
17
|
+
# See the License for the specific language governing permissions and
|
|
18
|
+
# limitations under the License.
|
|
19
|
+
#
|
|
20
|
+
module Xbrlware
|
|
21
|
+
module DateUtil # :nodoc:
|
|
22
|
+
def self.stringify_date (date)
|
|
23
|
+
return "" if date.nil?
|
|
24
|
+
_date=Date.parse(date) if date.is_a?(String)
|
|
25
|
+
_date=date if date.is_a?(Date)
|
|
26
|
+
m=Date::ABBR_MONTHNAMES[_date.month]
|
|
27
|
+
m + " " + _date.day.to_s + ", " + _date.year.to_s
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.months_between(date1=Date.today, date2=Date.today)
|
|
31
|
+
(date1 > date2) ? (recent_date, past_date = date1, date2) : (recent_date, past_date = date2, date1)
|
|
32
|
+
(recent_date.year - past_date.year) * 12 + (recent_date.month - past_date.month)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
#
|
|
3
|
+
# Author:: xbrlware@bitstat.com
|
|
4
|
+
#
|
|
5
|
+
# Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved.
|
|
6
|
+
#
|
|
7
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
16
|
+
# implied.
|
|
17
|
+
# See the License for the specific language governing permissions and
|
|
18
|
+
# limitations under the License.
|
|
19
|
+
#
|
|
20
|
+
class Float # :nodoc:
|
|
21
|
+
def round_at(precision)
|
|
22
|
+
(self * (10 ** precision)).round.to_f / 10 ** precision
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
#
|
|
3
|
+
# Author:: xbrlware@bitstat.com
|
|
4
|
+
#
|
|
5
|
+
# Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved.
|
|
6
|
+
#
|
|
7
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
16
|
+
# implied.
|
|
17
|
+
# See the License for the specific language governing permissions and
|
|
18
|
+
# limitations under the License.
|
|
19
|
+
#
|
|
20
|
+
module Xbrlware
|
|
21
|
+
module HashUtil # :nodoc:
|
|
22
|
+
def self.to_obj(hash)
|
|
23
|
+
o = Object.new()
|
|
24
|
+
hash.each do |k, v|
|
|
25
|
+
v=self.to_obj(v) if v.is_a?(Hash)
|
|
26
|
+
MetaUtil::introduce_instance_var(o, k, v)
|
|
27
|
+
end
|
|
28
|
+
return o
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# In Ruby 1.9, the Hash is ordered by default.
|
|
32
|
+
if RUBY_VERSION >= '1.9'
|
|
33
|
+
OHash = ::Hash
|
|
34
|
+
else
|
|
35
|
+
class OHash < Hash #:nodoc:
|
|
36
|
+
def initialize(*args, &block)
|
|
37
|
+
super
|
|
38
|
+
@keys = []
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.[](*args)
|
|
42
|
+
ordered_hash = new
|
|
43
|
+
|
|
44
|
+
if (args.length == 1 && args.first.is_a?(Array))
|
|
45
|
+
args.first.each do |key_value_pair|
|
|
46
|
+
next unless (key_value_pair.is_a?(Array))
|
|
47
|
+
ordered_hash[key_value_pair[0]] = key_value_pair[1]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
return ordered_hash
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
unless (args.size % 2 == 0)
|
|
54
|
+
raise ArgumentError.new("odd number of arguments for Hash")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
args.each_with_index do |val, ind|
|
|
58
|
+
next if (ind % 2 != 0)
|
|
59
|
+
ordered_hash[val] = args[ind + 1]
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
ordered_hash
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def initialize_copy(other)
|
|
66
|
+
super
|
|
67
|
+
# make a deep copy of keys
|
|
68
|
+
@keys = other.keys
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def []=(key, value)
|
|
72
|
+
@keys << key if !has_key?(key)
|
|
73
|
+
super
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def keys
|
|
77
|
+
@keys.dup
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def values
|
|
81
|
+
@keys.collect { |key| self[key] }
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def delete(key)
|
|
85
|
+
if has_key? key
|
|
86
|
+
index = @keys.index(key)
|
|
87
|
+
@keys.delete_at index
|
|
88
|
+
end
|
|
89
|
+
super
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def delete_if
|
|
93
|
+
super
|
|
94
|
+
sync_keys!
|
|
95
|
+
self
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def reject!
|
|
99
|
+
super
|
|
100
|
+
sync_keys!
|
|
101
|
+
self
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def reject(&block)
|
|
105
|
+
dup.reject!(&block)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def to_hash
|
|
109
|
+
self
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def to_a
|
|
113
|
+
@keys.map { |key| [ key, self[key] ] }
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def each_key
|
|
117
|
+
@keys.each { |key| yield key }
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def each_value
|
|
121
|
+
@keys.each { |key| yield self[key]}
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def each
|
|
125
|
+
@keys.each {|key| yield [key, self[key]]}
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
alias_method :each_pair, :each
|
|
129
|
+
|
|
130
|
+
def clear
|
|
131
|
+
super
|
|
132
|
+
@keys.clear
|
|
133
|
+
self
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def shift
|
|
137
|
+
k = @keys.first
|
|
138
|
+
v = delete(k)
|
|
139
|
+
[k, v]
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def merge!(other_hash)
|
|
143
|
+
other_hash.each {|k, v| self[k] = v }
|
|
144
|
+
self
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def merge(other_hash)
|
|
148
|
+
dup.merge!(other_hash)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# replace with keys from other Hash. The other Hash could be ordered or not ordered.
|
|
152
|
+
def replace(other)
|
|
153
|
+
super
|
|
154
|
+
@keys = other.keys
|
|
155
|
+
self
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def inspect
|
|
159
|
+
"#<OHash #{super}>"
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# XmlSimple's export to xml from Hash depends on instance_of?(Hash)
|
|
163
|
+
def instance_of?(clazz)
|
|
164
|
+
self.is_a?(clazz)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
private
|
|
168
|
+
|
|
169
|
+
def sync_keys!
|
|
170
|
+
@keys.delete_if {|k| !has_key?(k)}
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|