Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimlindstrom committed Mar 31, 2012
0 parents commit d5bd43f
Show file tree
Hide file tree
Showing 29 changed files with 51,368 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in xbrlware-ruby19.gemspec
gemspec
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2012 Jim Lindstrom

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Xbrlware::Ruby19

TODO: Write a gem description

## Installation

Add this line to your application's Gemfile:

gem 'xbrlware-ruby19'

And then execute:

$ bundle

Or install it yourself as:

$ gem install xbrlware-ruby19

## Usage

TODO: Write usage instructions here

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
73 changes: 73 additions & 0 deletions lib/xbrlware-ruby19.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/ruby
#
# Author:: [email protected]
#
# Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved.
#
# License:: Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#require 'rubygems'
#gem 'xml-simple'#, '= 1.0.12'
#require 'xmlsimple'
#
#require 'date'
#require 'bigdecimal'
#require 'erb'
#require 'set'
#require "stringio"
#require 'cgi'

require 'xbrlware-ruby19/version'
require 'xbrlware-ruby19/float_patch'
require 'xbrlware-ruby19/cgi_patch'
require 'xbrlware-ruby19/meta_util'
require 'xbrlware-ruby19/hash_util'
require 'xbrlware-ruby19/date_util'
require 'xbrlware-ruby19/xml_parser'

require 'xbrlware-ruby19/constants'
require 'xbrlware-ruby19/util'

require 'xbrlware-ruby19/taxonomies/us_gaap_taxonomy_20090131'

module Xbrlware; module Taxonomies
autoload :IFRS20090401, 'xbrlware-ruby19/taxonomies/ifrs_taxonomy_20090401'
end; end;

require 'xbrlware-ruby19/taxonomy'

require 'xbrlware-ruby19/ns_aware'
require 'xbrlware-ruby19/context'
require 'xbrlware-ruby19/instance'
require 'xbrlware-ruby19/unit'
require 'xbrlware-ruby19/item'

require 'xbrlware-ruby19/linkbase/linkbase'
require 'xbrlware-ruby19/linkbase/label_linkbase'
require 'xbrlware-ruby19/linkbase/calculation_linkbase'
require 'xbrlware-ruby19/linkbase/definition_linkbase'
require 'xbrlware-ruby19/linkbase/presentation_linkbase'

#require 'logger'
#require 'benchmark'

ENV["TAXO_NAME"]="US-GAAP"
ENV["TAXO_VER"]="20090131"

$LOG = Logger.new($stdout)
$LOG.level = Logger::INFO

def bm(title, measure) # :nodoc:
$LOG.debug title +" [ u :"+measure.utime.to_s+", s :"+measure.stime.to_s+", t :"+measure.total.to_s+", r :"+measure.real.to_s+"]"
end
58 changes: 58 additions & 0 deletions lib/xbrlware-ruby19/cgi_patch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# This patch is to fix a bug in Ruby 1.8.x CGI::unescapeHTML
# Till we upgrade to Ruby 1.9, we will use this patch. Ruby 1.9 handles it properly.
# Other alternative is using htmlentities - http://htmlentities.rubyforge.org/
#
# Bug explanation,
# CGI::unescapeHTML("Equity in Earnings of") returns "Equity in Earnings\240of" instead of "Equity in Earnings of"
# CGI::unescapeHTML is not handling HTML numbers bigger than ~
#
# Fix explanation
# If HTML number is bigger than ~ treat them as   (32 is for space)

# below method copied from ruby-1.8.7-p248, ruby 1.8.7 (2009-12-24 patchlevel 248) for patching.


class CGI
# Unescape a string that has been HTML-escaped
# CGI::unescapeHTML("Usage: foo "bar" <baz>")
# # => "Usage: foo \"bar\" <baz>"
def CGI::unescapeHTML(string)
string.gsub(/&(amp|quot|gt|lt|\#[0-9]+|\#x[0-9A-Fa-f]+);/n) do
match = $1.dup
case match
when 'amp' then
'&'
when 'quot' then
'"'
when 'gt' then
'>'
when 'lt' then
'<'
when /\A#0*(\d+)\z/n then
if Integer($1) < 256
32.chr if Integer($1) > 126
Integer($1).chr if Integer($1) <= 126
else
if Integer($1) < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U)
[Integer($1)].pack("U")
else
"&##{$1};"
end
end
when /\A#x([0-9a-f]+)\z/ni then
if $1.hex < 128
$1.hex.chr
else
if $1.hex < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U)
[$1.hex].pack("U")
else
"&#x#{$1};"
end
end
else
"&#{match};"
end
end
end

end
29 changes: 29 additions & 0 deletions lib/xbrlware-ruby19/constants.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/ruby
#
# Author:: [email protected]
#
# Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved.
#
# License:: Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
module Xbrlware
# Linkbase constants
module LBConstants
CALCULATION="http://www.xbrl.org/2003/role/calculationLinkbaseRef"
DEFINITION="http://www.xbrl.org/2003/role/definitionLinkbaseRef"
PRESENTATION="http://www.xbrl.org/2003/role/presentationLinkbaseRef"
LABEL="http://www.xbrl.org/2003/role/labelLinkbaseRef"
REFERENCE="http://www.xbrl.org/2003/role/referenceLinkbaseRef"
end
end
Loading

0 comments on commit d5bd43f

Please sign in to comment.