folder_template 0.1.1
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.
- checksums.yaml +7 -0
- data/Gemfile +11 -0
- data/LICENSE +22 -0
- data/README.md +55 -0
- data/folder_template.gemspec +38 -0
- data/lib/folder_template.rb +20 -0
- data/lib/folder_template/fs_adapter.rb +64 -0
- data/lib/folder_template/template_folder.rb +58 -0
- data/lib/folder_template/template_folder_entry.rb +59 -0
- data/lib/folder_template/template_string.rb +68 -0
- data/lib/folder_template/version.rb +12 -0
- data/rakefile.rb +42 -0
- data/test/_test_env.rb +31 -0
- data/test/data/test1/actual_output/lib/project_aaa.rb +1 -0
- data/test/data/test1/actual_output/lib/project_aaa/cls_fn.rb +13 -0
- data/test/data/test1/actual_output/test_/_test_cls_fn.rb +20 -0
- data/test/data/test1/expected_output/lib/project_aaa.rb +1 -0
- data/test/data/test1/expected_output/lib/project_aaa/cls_fn.rb +13 -0
- data/test/data/test1/expected_output/test_/_test_cls_fn.rb +20 -0
- data/test/data/test1/template/lib/>>{{project_name}}.rb +1 -0
- data/test/data/test1/template/lib/{{project_name}}/{{class_filename}}.rb +13 -0
- data/test/data/test1/template/test_/_test_{{class_filename}}.rb +20 -0
- data/test/data/test_append/actual_output/lib/project_aaa.rb +3 -0
- data/test/data/test_append/actual_output/lib/project_aaa/cls1_fn.rb +13 -0
- data/test/data/test_append/actual_output/lib/project_aaa/cls2_fn.rb +13 -0
- data/test/data/test_append/actual_output/lib/project_aaa/cls3_fn.rb +13 -0
- data/test/data/test_append/actual_output/test_/_test_cls1_fn.rb +20 -0
- data/test/data/test_append/actual_output/test_/_test_cls2_fn.rb +20 -0
- data/test/data/test_append/actual_output/test_/_test_cls3_fn.rb +20 -0
- data/test/data/test_append/expected_output/lib/project_aaa.rb +3 -0
- data/test/data/test_append/expected_output/lib/project_aaa/cls1_fn.rb +13 -0
- data/test/data/test_append/expected_output/lib/project_aaa/cls2_fn.rb +13 -0
- data/test/data/test_append/expected_output/lib/project_aaa/cls3_fn.rb +13 -0
- data/test/data/test_append/expected_output/test_/_test_cls1_fn.rb +20 -0
- data/test/data/test_append/expected_output/test_/_test_cls2_fn.rb +20 -0
- data/test/data/test_append/expected_output/test_/_test_cls3_fn.rb +20 -0
- data/test/data/test_append/template/lib/>>{{project_name}}.rb +1 -0
- data/test/data/test_append/template/lib/{{project_name}}/{{class_filename}}.rb +13 -0
- data/test/data/test_append/template/test_/_test_{{class_filename}}.rb +20 -0
- data/test/test_fs_adapter.rb +56 -0
- data/test/test_template_folder.rb +62 -0
- data/test/test_template_folder_entry.rb +147 -0
- data/test/test_template_string.rb +94 -0
- metadata +175 -0
data/test/_test_env.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : test/_test_env.rb
|
4
|
+
# PROJECT : RubyProjectGenerator
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) 2016, Marc-Antoine Argenton. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
require 'minitest/autorun'
|
11
|
+
require 'fileutils'
|
12
|
+
require 'pp'
|
13
|
+
require 'rr'
|
14
|
+
|
15
|
+
require 'lib/folder_template.rb'
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
module Minitest::Assertions
|
20
|
+
def assert_folders_match( expected_folder, actual_folder )
|
21
|
+
diffs = _diff_folders( expected_folder, actual_folder )
|
22
|
+
assert diffs.empty?,
|
23
|
+
"Expected folders content to match:\n#{diffs}\n"
|
24
|
+
# "Expected folders to match:\nexpected: #{expected_folder.inspect}\nactual: #{expected_folder.inspect}\ndiffs:\n#{diffs}"
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def _diff_folders( expected_folder, actual_folder )
|
29
|
+
`diff -r -u --exclude=.DS_Store #{expected_folder} #{actual_folder}`
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'project_aaa/cls_fn.rb'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : lib/project_aaa/cls_fn.rb
|
4
|
+
# PROJECT : ProjectAaa
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) YEAR, Me. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module ProjectAaa
|
11
|
+
class ClsName
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : test/project_aaa/test_cls_fn.rb
|
4
|
+
# PROJECT : ProjectAaa
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) YEAR, Me. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module ProjectAaa
|
11
|
+
|
12
|
+
describe ClsName do
|
13
|
+
subject { ClsName.new }
|
14
|
+
|
15
|
+
it "passes this one" do
|
16
|
+
subject.must_be_instance_of ClsName
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'project_aaa/cls_fn.rb'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : lib/project_aaa/cls_fn.rb
|
4
|
+
# PROJECT : ProjectAaa
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) YEAR, Me. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module ProjectAaa
|
11
|
+
class ClsName
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : test/project_aaa/test_cls_fn.rb
|
4
|
+
# PROJECT : ProjectAaa
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) YEAR, Me. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module ProjectAaa
|
11
|
+
|
12
|
+
describe ClsName do
|
13
|
+
subject { ClsName.new }
|
14
|
+
|
15
|
+
it "passes this one" do
|
16
|
+
subject.must_be_instance_of ClsName
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative '{{project_name}}/{{class_filename}}.rb'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : lib/{{project_name}}/{{class_filename}}.rb
|
4
|
+
# PROJECT : {{project_namespace}}
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) {{copyright_year}}, {{copyright_owner}}. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module {{project_namespace}}
|
11
|
+
class {{class_name}}
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : test/{{project_name}}/test_{{class_filename}}.rb
|
4
|
+
# PROJECT : {{project_namespace}}
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) {{copyright_year}}, {{copyright_owner}}. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module {{project_namespace}}
|
11
|
+
|
12
|
+
describe {{class_name}} do
|
13
|
+
subject { {{class_name}}.new }
|
14
|
+
|
15
|
+
it "passes this one" do
|
16
|
+
subject.must_be_instance_of {{class_name}}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : lib/project_aaa/cls1_fn.rb
|
4
|
+
# PROJECT : ProjectAaa
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) YEAR, Me. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module ProjectAaa
|
11
|
+
class Cls1Name
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : lib/project_aaa/cls2_fn.rb
|
4
|
+
# PROJECT : ProjectAaa
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) YEAR, Me. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module ProjectAaa
|
11
|
+
class Cls2Name
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : lib/project_aaa/cls3_fn.rb
|
4
|
+
# PROJECT : ProjectAaa
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) YEAR, Me. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module ProjectAaa
|
11
|
+
class Cls3Name
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : test/project_aaa/test_cls1_fn.rb
|
4
|
+
# PROJECT : ProjectAaa
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) YEAR, Me. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module ProjectAaa
|
11
|
+
|
12
|
+
describe Cls1Name do
|
13
|
+
subject { Cls1Name.new }
|
14
|
+
|
15
|
+
it "passes this one" do
|
16
|
+
subject.must_be_instance_of Cls1Name
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : test/project_aaa/test_cls2_fn.rb
|
4
|
+
# PROJECT : ProjectAaa
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) YEAR, Me. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module ProjectAaa
|
11
|
+
|
12
|
+
describe Cls2Name do
|
13
|
+
subject { Cls2Name.new }
|
14
|
+
|
15
|
+
it "passes this one" do
|
16
|
+
subject.must_be_instance_of Cls2Name
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : test/project_aaa/test_cls3_fn.rb
|
4
|
+
# PROJECT : ProjectAaa
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) YEAR, Me. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module ProjectAaa
|
11
|
+
|
12
|
+
describe Cls3Name do
|
13
|
+
subject { Cls3Name.new }
|
14
|
+
|
15
|
+
it "passes this one" do
|
16
|
+
subject.must_be_instance_of Cls3Name
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : lib/project_aaa/cls1_fn.rb
|
4
|
+
# PROJECT : ProjectAaa
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) YEAR, Me. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module ProjectAaa
|
11
|
+
class Cls1Name
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : lib/project_aaa/cls2_fn.rb
|
4
|
+
# PROJECT : ProjectAaa
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) YEAR, Me. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module ProjectAaa
|
11
|
+
class Cls2Name
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : lib/project_aaa/cls3_fn.rb
|
4
|
+
# PROJECT : ProjectAaa
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) YEAR, Me. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module ProjectAaa
|
11
|
+
class Cls3Name
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : test/project_aaa/test_cls1_fn.rb
|
4
|
+
# PROJECT : ProjectAaa
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) YEAR, Me. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module ProjectAaa
|
11
|
+
|
12
|
+
describe Cls1Name do
|
13
|
+
subject { Cls1Name.new }
|
14
|
+
|
15
|
+
it "passes this one" do
|
16
|
+
subject.must_be_instance_of Cls1Name
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : test/project_aaa/test_cls2_fn.rb
|
4
|
+
# PROJECT : ProjectAaa
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) YEAR, Me. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module ProjectAaa
|
11
|
+
|
12
|
+
describe Cls2Name do
|
13
|
+
subject { Cls2Name.new }
|
14
|
+
|
15
|
+
it "passes this one" do
|
16
|
+
subject.must_be_instance_of Cls2Name
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : test/project_aaa/test_cls3_fn.rb
|
4
|
+
# PROJECT : ProjectAaa
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) YEAR, Me. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module ProjectAaa
|
11
|
+
|
12
|
+
describe Cls3Name do
|
13
|
+
subject { Cls3Name.new }
|
14
|
+
|
15
|
+
it "passes this one" do
|
16
|
+
subject.must_be_instance_of Cls3Name
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative '{{project_name}}/{{class_filename}}.rb'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : lib/{{project_name}}/{{class_filename}}.rb
|
4
|
+
# PROJECT : {{project_namespace}}
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) {{copyright_year}}, {{copyright_owner}}. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module {{project_namespace}}
|
11
|
+
class {{class_name}}
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : test/{{project_name}}/test_{{class_filename}}.rb
|
4
|
+
# PROJECT : {{project_namespace}}
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) {{copyright_year}}, {{copyright_owner}}. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
module {{project_namespace}}
|
11
|
+
|
12
|
+
describe {{class_name}} do
|
13
|
+
subject { {{class_name}}.new }
|
14
|
+
|
15
|
+
it "passes this one" do
|
16
|
+
subject.must_be_instance_of {{class_name}}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# =============================================================================
|
2
|
+
#
|
3
|
+
# MODULE : lib/ruby_project_generator/test_fs_adapter.rb
|
4
|
+
# PROJECT : RubyProjectGenerator
|
5
|
+
# DESCRIPTION :
|
6
|
+
#
|
7
|
+
# Copyright (c) 2016, Marc-Antoine Argenton. All rights reserved.
|
8
|
+
# =============================================================================
|
9
|
+
|
10
|
+
|
11
|
+
require '_test_env.rb'
|
12
|
+
|
13
|
+
|
14
|
+
module FolderTemplate
|
15
|
+
|
16
|
+
describe FsAdapter do
|
17
|
+
let( :tmpdir ) { "tmp" }
|
18
|
+
subject { FsAdapter.new( tmpdir ) }
|
19
|
+
|
20
|
+
before do
|
21
|
+
stub(FileUtils).makedirs()
|
22
|
+
stub(File).open()
|
23
|
+
stub(File).write()
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "when calling makedirs()" do
|
27
|
+
it "expands filename and calls FileUtils.makedirs()" do
|
28
|
+
mock(FileUtils).makedirs( File.join( tmpdir, "aaa/bbb" ) )
|
29
|
+
subject.makedirs( "aaa/bbb" )
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "when calling write_to_file()" do
|
34
|
+
it "expands filename, creates containing folder and calls File.write()" do
|
35
|
+
expected_filename = File.join( tmpdir, "aaa/bbb" )
|
36
|
+
mock(FileUtils).makedirs( File.dirname( expected_filename ) )
|
37
|
+
mock(File).write( expected_filename, "bbb" )
|
38
|
+
|
39
|
+
subject.write_to_file( "aaa/bbb", "bbb" )
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "when calling append_to_file()" do
|
44
|
+
it "expands filename, opens file for append and appends content" do
|
45
|
+
expected_filename = File.join( tmpdir, "aaa/bbb" )
|
46
|
+
mock(FileUtils).makedirs( File.dirname( expected_filename ) )
|
47
|
+
mock(File).open( expected_filename, "a" )
|
48
|
+
|
49
|
+
subject.append_to_file( "aaa/bbb", "bbb" )
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
|