taxplorer 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTk3MTg4NzQ1NmE1ZDIyZGRhMmJiOTkyZjYwNjJhYTBjOGYyODE3Mw==
4
+ MjY0ODQ1ZTVjMjUwYjhkYWI2MjQ4MzY2M2IxM2RlYTE1ODYzNTY1MQ==
5
5
  data.tar.gz: !binary |-
6
- Mjk3MzIxZjc3YzE0OTcxMDJhNWFkNzk2YzM5YTVhMjc3Y2QzZTI3Yw==
6
+ OWU0OTNlOWNmYmQ1MzM0ZWFkZjM2ZDhmNmQ5MWQ3ODAyZDM2ODE0Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTdlMjEyNDEzZmRiZDQ3Zjk0NGU5MDAzMGQ2OTE1OTU5MjVjZmUwODNkZmFh
10
- NDdhNTlmM2UzYzU5OWQ1MmQ5Mzc5NzU3ZDZlYjVhMGUyYTdiYTA3MzJhMTAy
11
- ZDRkOGEyOTIyM2M4NzAyMzVlYWVhYmE3MjBiM2IwMWI3NWYxMzU=
9
+ ODM3OTFmM2FhMWQ4YzhkMjVmNGI4Y2FhZmRhNjY5YWIyMjAwM2Q2Yzk3YTdj
10
+ NWI2YTdiY2JmYWE4MzkxYjliNGQwYWNjNjhjMTY0ZmIwMGQ5ODIzY2EyY2Uz
11
+ NzNhNTM0NmQ2MDdlNGY5MDU3Nzk3YjYwNWVlMjRlYTdlYjQ5ZGY=
12
12
  data.tar.gz: !binary |-
13
- YmJjYTQwYjdjNDliYjNkYTg5NDA2MzI1ZDNhODdjNWVkNTRhYWIyNWM2ZTQ3
14
- NGNkZDFmNjkwMmE4NzVmMWJkYzEzNWUzODIyOTJhNTAzNGJhZjBkYzdmNDQx
15
- YWJlYmQ3YTI3ZWVhNzFkYzg1YjJmZjJjYjcxMzQ4Zjk1ZWQ0ZDE=
13
+ ODkxODRkMDdkOWYyMmRkMjYxYmFkMjdmOTU3NTQyMWVhMDIzOTRjMzg5NmM4
14
+ NDRlOWQyYTFmMDc0ZWUyYWFmMWUwMzBlYjllY2ZkZWQyM2U3MDk3ODY0MzIx
15
+ NGQ1M2Y5ZTU0NWZkMTVhYmQxMTRhYTkxMGFhMjM0NGViMTQ5ZjU=
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # Taxplorer
2
2
 
3
- [![Build Status](https://travis-ci.org/seocahill/taxplorer.svg?branch=v0.1.4)](https://travis-ci.org/seocahill/taxplorer) [![Coverage Status](https://coveralls.io/repos/seocahill/taxplorer/badge.svg?branch=master)](https://coveralls.io/r/seocahill/taxplorer?branch=master)
3
+ [![Gem Version](https://badge.fury.io/rb/taxplorer.svg)](http://badge.fury.io/rb/taxplorer)
4
+ [![Build Status](https://travis-ci.org/seocahill/taxplorer.svg?branch=master)](https://travis-ci.org/seocahill/taxplorer)
5
+ [![Code Climate](https://codeclimate.com/github/seocahill/taxplorer/badges/gpa.svg)](https://codeclimate.com/github/seocahill/taxplorer)
6
+ [![Test Coverage](https://codeclimate.com/github/seocahill/taxplorer/badges/coverage.svg)](https://codeclimate.com/github/seocahill/taxplorer/coverage)
4
7
 
5
8
  Taxplorer is a command line tool to view the content of XBRL taxonomy Schemas.
6
9
 
@@ -12,7 +12,7 @@ module Taxplorer
12
12
  def welcome_prompt
13
13
  choose do |menu|
14
14
  menu.prompt = "Choose preferred taxonomy"
15
- ["Uk GAAP", "UK IFRS"].each do |t|
15
+ ["UK GAAP", "UK IFRS"].each do |t|
16
16
  menu.choice(t) { |c| say("have a glass of whiskey while we load up #{c} for you"); load_taxonomy }
17
17
  end
18
18
  end
@@ -61,7 +61,7 @@ module Taxplorer
61
61
  menu_prompt
62
62
  when "tree"
63
63
  clear
64
- tree_view(node)
64
+ puts tree_view(node)
65
65
  puts "\n\n"
66
66
  node_commands(node)
67
67
  when "quit"
@@ -19,11 +19,7 @@ module Taxplorer
19
19
  def get_parent(node)
20
20
  child = @section[:elements].values.find {|e| e[:label] == node}
21
21
  parent = @section[:elements].values.find {|p| p[:label] == child[:parent]} if child
22
- if parent
23
- node_commands(parent[:label])
24
- else
25
- menu_prompt
26
- end
22
+ parent ? node_commands(parent[:label]) : menu_prompt
27
23
  end
28
24
 
29
25
  def get_children(node_id)
@@ -1,3 +1,3 @@
1
1
  module Taxplorer
2
- VERSION = "0.1.6"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,21 +1,21 @@
1
1
  module Taxplorer
2
2
  module View
3
3
 
4
- def table_view(node)
5
- if node[:details]
6
- puts Hirb::Helpers::AutoTable.render(info[:details])
7
- else
8
- puts "no information"
9
- end
10
- end
11
-
12
- def tree_view(node, links="")
4
+ def build_tree(node, level)
5
+ leaf = {value: node, level: level}
6
+ @nodes << leaf
13
7
  children = @section[:elements].values.select {|e| e[:parent] == node}
14
- puts links + node
15
- links = links + " "
8
+ level += 1
16
9
  children.map do |child|
17
- tree_view(child[:label], links)
10
+ build_tree(child[:label], level)
18
11
  end
12
+ @nodes
13
+ end
14
+
15
+ def tree_view(node)
16
+ @nodes = []
17
+ build_tree(node, 0)
18
+ Hirb::Helpers::Tree.render(@nodes, type: :directory)
19
19
  end
20
20
  end
21
21
  end
data/lib/taxplorer.rb CHANGED
@@ -17,6 +17,7 @@ class Application
17
17
  attr_reader :records, :run
18
18
 
19
19
  def initialize
20
+ @nodes = []
20
21
  @records ||= Hash.new
21
22
  @records["sections"] ||= []
22
23
  @records["elements"] ||= []
data/test/test_helper.rb CHANGED
@@ -1,6 +1,19 @@
1
1
  require 'simplecov'
2
- SimpleCov.start
3
2
  require "codeclimate-test-reporter"
3
+ SimpleCov.start do
4
+ add_filter "test"
5
+ add_filter "taxplorer/command.rb"
6
+ end
4
7
  CodeClimate::TestReporter.start
5
8
  require 'minitest/autorun'
6
9
 
10
+ module Helpers
11
+ def with_stdin
12
+ stdin = $stdin
13
+ $stdin, write = IO.pipe
14
+ yield write
15
+ ensure
16
+ write.close
17
+ $stdin = stdin
18
+ end
19
+ end
data/test/view_test.rb CHANGED
@@ -4,39 +4,48 @@ require 'taxplorer'
4
4
 
5
5
  class TestView < Minitest::Test
6
6
  def setup
7
- @section = {
8
- elements: {
9
- "root": {label: "root"},
10
- "A": {label: "A", parent: "root"},
11
- "B": {label: "B", parent: "root"},
12
- "C": {label: "C", parent: "root"},
13
- "D": {label: "D", parent: "B"},
14
- "E": {label: "E", parent: "D"},
15
- "F": {label: "F", parent: "D"}
16
- }
17
- }
7
+ @mockapp = Class.new do
8
+ include Taxplorer::View
9
+ def initialize
10
+ @nodes = []
11
+ @section = {
12
+ elements: {
13
+ "root": {label: "root"},
14
+ "A": {label: "A", parent: "root"},
15
+ "B": {label: "B", parent: "root"},
16
+ "C": {label: "C", parent: "root"},
17
+ "D": {label: "D", parent: "B"},
18
+ "E": {label: "E", parent: "D"},
19
+ "F": {label: "F", parent: "D"}
20
+ }
21
+ }
22
+ end
23
+ def clear;end
24
+ end.new
18
25
  end
19
26
 
20
- def tree_view(node, links="")
21
- children = @section[:elements].values.select {|e| e[:parent] == node}
22
- puts links + node
23
- links = links + " "
24
- children.map do |child|
25
- tree_view(child[:label], links)
26
- end
27
+ def test_build_tree
28
+ tree_hash = [
29
+ {value: "root", level:0},
30
+ {value: "A", level:1},
31
+ {value: "B", level:1},
32
+ {value: "D", level:2},
33
+ {value: "E", level:3},
34
+ {value: "F", level:3},
35
+ {value: "C", level:1},
36
+ ]
37
+ assert_equal tree_hash, @mockapp.build_tree("root", 0)
27
38
  end
28
39
 
29
40
  def test_tree_view
30
- skip
31
- result = "
32
- root
33
- |_A
34
- |_B
35
- | |_D
36
- | |_E
37
- | |_F
38
- |_C
39
- "
40
- assert_equal result, tree_view("root")
41
+ result =
42
+ "root\n"+
43
+ "|-- A\n"+
44
+ "|-- B\n"+
45
+ "| `-- D\n"+
46
+ "| |-- E\n"+
47
+ "| `-- F\n"+
48
+ "`-- C"
49
+ assert_equal result, @mockapp.tree_view("root")
41
50
  end
42
51
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taxplorer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seosamh Cahill
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-02 00:00:00.000000000 Z
11
+ date: 2015-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -130,7 +130,6 @@ executables:
130
130
  extensions: []
131
131
  extra_rdoc_files: []
132
132
  files:
133
- - .coveralls.yml
134
133
  - .gitignore
135
134
  - .travis.yml
136
135
  - Gemfile
@@ -165,7 +164,6 @@ files:
165
164
  - lib/taxplorer/version.rb
166
165
  - lib/taxplorer/view.rb
167
166
  - taxplorer.gemspec
168
- - test/command_test.rb
169
167
  - test/find_test.rb
170
168
  - test/parse_test.rb
171
169
  - test/taxplorer_test.rb
@@ -196,7 +194,6 @@ signing_key:
196
194
  specification_version: 4
197
195
  summary: XBRL taxonomy parser
198
196
  test_files:
199
- - test/command_test.rb
200
197
  - test/find_test.rb
201
198
  - test/parse_test.rb
202
199
  - test/taxplorer_test.rb
data/.coveralls.yml DELETED
@@ -1 +0,0 @@
1
- service_name: travis-ci
data/test/command_test.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'test_helper'
2
- require 'taxplorer'
3
-
4
- class TestCommand < Minitest::Test
5
- #test highline commands?
6
- end