mokuji 0.2.2 → 1.0.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.
- data/Mokuji.gemspec +2 -2
- data/README +0 -1
- data/Rakefile +6 -13
- data/bin/mokuji +24 -71
- data/lib/mokuji.rb +75 -8
- data/lib/mokuji/converter.rb +158 -171
- data/lib/mokuji/exporter.rb +42 -54
- data/lib/mokuji/scanner.rb +82 -130
- data/lib/mokuji/validators.rb +67 -0
- data/lib/mokuji/version.rb +3 -7
- data/spec/converter_spec.rb +31 -59
- data/spec/exporter_spec.rb +27 -44
- data/spec/scanner_spec.rb +31 -48
- metadata +5 -7
- data/lib/mokuji/initializer.rb +0 -95
- data/spec/initializer_spec.rb +0 -42
data/spec/exporter_spec.rb
CHANGED
@@ -1,49 +1,32 @@
|
|
1
1
|
require 'mokuji/exporter'
|
2
2
|
|
3
|
-
|
4
3
|
describe 'Exporter' do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
# JSON
|
34
|
-
it do
|
35
|
-
|
36
|
-
@dfe_json.should be_an_instance_of File
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
# HTML
|
42
|
-
it do
|
43
|
-
|
44
|
-
@dfe_html.should be_an_instance_of File
|
45
|
-
|
46
|
-
end
|
47
|
-
|
4
|
+
before do
|
5
|
+
@data_from_converter = 'Wait what, aaarrrrspeccaaaahhh!'
|
6
|
+
@export_path = File.expand_path('~/') + '/Desktop/'
|
7
|
+
|
8
|
+
@exporter = Mokuji::Exporter.new
|
9
|
+
Mokuji.configure 'list_name' => 'Desktop'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should include the validators module" do
|
13
|
+
@exporter.methods.should include :validate_configuration
|
14
|
+
end
|
15
|
+
|
16
|
+
it do
|
17
|
+
Mokuji.configure 'output_type' => 'json'
|
18
|
+
@df_json = @exporter.export @data_from_converter, @export_path
|
19
|
+
|
20
|
+
@df_json.should be_an_instance_of File
|
21
|
+
File::delete(@df_json)
|
22
|
+
end
|
23
|
+
|
24
|
+
it do
|
25
|
+
Mokuji.configure 'output_type' => 'html'
|
26
|
+
@df_html = @exporter.export @data_from_converter, @export_path
|
27
|
+
|
28
|
+
@df_html.should be_an_instance_of File
|
29
|
+
File::delete(@df_html)
|
30
|
+
end
|
48
31
|
|
49
32
|
end
|
data/spec/scanner_spec.rb
CHANGED
@@ -1,52 +1,35 @@
|
|
1
1
|
require 'mokuji/scanner'
|
2
2
|
|
3
|
-
|
4
3
|
describe 'Scanner' do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
# HTML
|
38
|
-
it do
|
39
|
-
|
40
|
-
@dfs_html.should be_an_instance_of Hash
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
|
45
|
-
it do
|
46
|
-
|
47
|
-
@dfs_html['contents'].should have_at_least(1).items
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
|
4
|
+
before do
|
5
|
+
@path_to_scan = File.expand_path('~/') + '/Downloads/'
|
6
|
+
@directory_name = File.basename(@path_to_scan)
|
7
|
+
|
8
|
+
@scanner = Mokuji::Scanner.new
|
9
|
+
@results = @scanner.scan @path_to_scan
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should include the validators module" do
|
13
|
+
@scanner.methods.should include :validate_configuration
|
14
|
+
end
|
15
|
+
|
16
|
+
it do
|
17
|
+
@results.should be_an_instance_of Hash
|
18
|
+
end
|
19
|
+
|
20
|
+
it do
|
21
|
+
@results['type'].should == 'directory'
|
22
|
+
end
|
23
|
+
|
24
|
+
it do
|
25
|
+
@results['name'].should == @directory_name
|
26
|
+
end
|
27
|
+
|
28
|
+
it do
|
29
|
+
@results['contents'][0]['name'].should_not == '.'
|
30
|
+
end
|
31
|
+
|
32
|
+
it do
|
33
|
+
@results['contents'].should have_at_least(1).items
|
34
|
+
end
|
52
35
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: mokuji
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 1.0.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Icid Asset
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-04-19 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
version: "2.5"
|
47
47
|
type: :development
|
48
48
|
version_requirements: *id003
|
49
|
-
description: Make a list from
|
49
|
+
description: Make a recursive list from a directory its contents and export it in html, json or plain-text
|
50
50
|
email:
|
51
51
|
- icid.asset@gmail.com
|
52
52
|
executables:
|
@@ -68,12 +68,11 @@ files:
|
|
68
68
|
- lib/mokuji/assets/stylesheet.css
|
69
69
|
- lib/mokuji/converter.rb
|
70
70
|
- lib/mokuji/exporter.rb
|
71
|
-
- lib/mokuji/initializer.rb
|
72
71
|
- lib/mokuji/scanner.rb
|
72
|
+
- lib/mokuji/validators.rb
|
73
73
|
- lib/mokuji/version.rb
|
74
74
|
- spec/converter_spec.rb
|
75
75
|
- spec/exporter_spec.rb
|
76
|
-
- spec/initializer_spec.rb
|
77
76
|
- spec/scanner_spec.rb
|
78
77
|
- spec/spec.opts
|
79
78
|
- spec/spec_helper.rb
|
@@ -104,11 +103,10 @@ rubyforge_project: mokuji
|
|
104
103
|
rubygems_version: 1.6.0
|
105
104
|
signing_key:
|
106
105
|
specification_version: 3
|
107
|
-
summary: Mokuji
|
106
|
+
summary: Mokuji recursively lists a directory by its path.
|
108
107
|
test_files:
|
109
108
|
- spec/converter_spec.rb
|
110
109
|
- spec/exporter_spec.rb
|
111
|
-
- spec/initializer_spec.rb
|
112
110
|
- spec/scanner_spec.rb
|
113
111
|
- spec/spec.opts
|
114
112
|
- spec/spec_helper.rb
|
data/lib/mokuji/initializer.rb
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
require 'mokuji/scanner'
|
2
|
-
require 'mokuji/converter'
|
3
|
-
require 'mokuji/exporter'
|
4
|
-
|
5
|
-
module Mokuji
|
6
|
-
|
7
|
-
#
|
8
|
-
# INITIALIZER
|
9
|
-
# - Initialises the whole thing
|
10
|
-
#
|
11
|
-
|
12
|
-
class Initializer
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
attr_accessor :path_to_scan, :converting_method, :list_name, :time, :export_path
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def execute
|
21
|
-
|
22
|
-
# Validation
|
23
|
-
fail_msg = "You forgot to set some variables."
|
24
|
-
fail_msg << "Make sure you've set the path to scan and the converting method."
|
25
|
-
|
26
|
-
raise fail_msg unless path_to_scan || converting_method
|
27
|
-
|
28
|
-
# List name
|
29
|
-
unless list_name then
|
30
|
-
|
31
|
-
rindex = path_to_scan.chomp('/').rindex('/') + 1
|
32
|
-
@list_name = path_to_scan.chomp('/').slice(rindex..-1)
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
# Time
|
37
|
-
@time = Time.now.strftime('%d %B %Y (%I:%M%p)')
|
38
|
-
|
39
|
-
# Export path
|
40
|
-
@export_path = path_to_scan unless export_path
|
41
|
-
|
42
|
-
# Let's begin
|
43
|
-
data_from_scanner = scan(path_to_scan)
|
44
|
-
file_contents = convert(data_from_scanner)
|
45
|
-
export(file_contents)
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
protected
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
def scan path
|
56
|
-
|
57
|
-
scanner = Mokuji::Scanner.new
|
58
|
-
scanner.path_to_scan = path
|
59
|
-
scanner.converting_method = converting_method
|
60
|
-
scanner.execute
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
def convert data_from_scanner
|
67
|
-
|
68
|
-
converter = Mokuji::Converter.new
|
69
|
-
converter.data_from_scanner = data_from_scanner
|
70
|
-
converter.converting_method = converting_method
|
71
|
-
converter.list_name = list_name
|
72
|
-
converter.time = time
|
73
|
-
converter.execute
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
def export file_contents
|
80
|
-
|
81
|
-
exporter = Mokuji::Exporter.new
|
82
|
-
exporter.file_data = file_contents
|
83
|
-
exporter.converting_method = converting_method
|
84
|
-
exporter.file_name = list_name + '_-_' + time.gsub(' ', '_').gsub(':', '-')
|
85
|
-
exporter.export_path = export_path
|
86
|
-
exporter.execute
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end # </Initializer>
|
93
|
-
|
94
|
-
end
|
95
|
-
|
data/spec/initializer_spec.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'mokuji'
|
2
|
-
|
3
|
-
|
4
|
-
describe 'Initializer' do
|
5
|
-
|
6
|
-
|
7
|
-
before do
|
8
|
-
|
9
|
-
# Set paths
|
10
|
-
path_to_scan = File.expand_path('~/')
|
11
|
-
export_path = File.expand_path('~/')
|
12
|
-
|
13
|
-
# Go!
|
14
|
-
m = Mokuji::Initializer.new
|
15
|
-
m.path_to_scan = path_to_scan
|
16
|
-
m.export_path = export_path
|
17
|
-
m.converting_method = :json
|
18
|
-
@dfi_json = m.execute
|
19
|
-
|
20
|
-
m.converting_method = :html
|
21
|
-
@dfi_html = m.execute
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
# JSON
|
27
|
-
it do
|
28
|
-
|
29
|
-
@dfi_json.should be_an_instance_of File
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
# HTML
|
35
|
-
it do
|
36
|
-
|
37
|
-
@dfi_html.should be_an_instance_of File
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
end
|