klipp 0.0.1 → 0.2.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.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.travis.yml +5 -0
- data/README.md +13 -26
- data/bin/klipp +1 -1
- data/klipp.gemspec +11 -6
- data/lib/klipp/configuration.rb +0 -4
- data/lib/klipp/creator.rb +78 -0
- data/lib/klipp/parameter_list.rb +3 -3
- data/lib/klipp/version.rb +1 -1
- data/lib/klipp.rb +148 -92
- data/lib/template/spec.rb +231 -0
- data/lib/template/token.rb +81 -0
- data/lib/template.rb +59 -0
- data/spec/fixtures/ambiguous-repo/Ambiguous/Ambiguous.klippspec +5 -0
- data/spec/fixtures/projects/Klippfile +26 -0
- data/spec/fixtures/projects/Klippfile-after-prepare +27 -0
- data/spec/fixtures/projects/Klippfile-ambiguous +1 -0
- data/spec/fixtures/projects/Klippfile-bad-ruby +3 -0
- data/spec/fixtures/projects/Klippfile-minimal +1 -0
- data/spec/fixtures/projects/Klippfile-unambiguous +1 -0
- data/spec/fixtures/template-repository/Ambiguous/Ambiguous.klippspec +5 -0
- data/spec/fixtures/template-repository/Another-Template/Another-Template.klippspec +20 -0
- data/spec/fixtures/template-repository/BadExample/BadExample.klippspec +35 -0
- data/spec/fixtures/template-repository/Empty/Empty.klippspec +20 -0
- data/spec/fixtures/template-repository/Example/.gitignore +10 -0
- data/spec/fixtures/template-repository/Example/Example.klippspec +40 -0
- data/spec/fixtures/template-repository/Example/Podfile +10 -0
- data/spec/fixtures/template-repository/Example/XXBLANKXX.hidden +10 -0
- data/spec/fixtures/template-repository/Example/XXPROJECT_IDXX/Config/Base.xcconfig +8 -0
- data/spec/fixtures/template-repository/Example/XXPROJECT_IDXX/Images/Default-568h@2x.png +0 -0
- data/spec/fixtures/template-repository/Example/XXPROJECT_IDXX/Images/Default.png +0 -0
- data/spec/fixtures/template-repository/Example/XXPROJECT_IDXX/Images/Default@2x.png +0 -0
- data/spec/fixtures/template-repository/Example/XXPROJECT_IDXX/Source/XXCLASS_PREFIXXXAppDelegate.h +13 -0
- data/spec/fixtures/template-repository/Example/XXPROJECT_IDXX/Source/XXCLASS_PREFIXXXAppDelegate.m +30 -0
- data/spec/fixtures/template-repository/Example/XXPROJECT_IDXX/Source/XXCLASS_PREFIXXXRootViewController.h +11 -0
- data/spec/fixtures/template-repository/Example/XXPROJECT_IDXX/Source/XXCLASS_PREFIXXXRootViewController.m +30 -0
- data/spec/fixtures/template-repository/Example/XXPROJECT_IDXX/XXPROJECT_TITLEXX-Info.plist +38 -0
- data/spec/fixtures/template-repository/Example/XXPROJECT_IDXX/XXPROJECT_TITLEXX-Prefix.pch +14 -0
- data/spec/fixtures/template-repository/Example/XXPROJECT_IDXX/en.lproj/Localizable.strings +1 -0
- data/spec/fixtures/template-repository/Example/XXPROJECT_IDXX/main.m +17 -0
- data/spec/fixtures/template-repository/Example/XXPROJECT_IDXX/nl.lproj/Localizable.strings +1 -0
- data/spec/fixtures/template-repository/Example/XXPROJECT_IDXX.xcodeproj/project.pbxproj +466 -0
- data/spec/fixtures/template-repository/Example/XXPROJECT_IDXX.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/spec/fixtures/template-repository/Example/XXPROJECT_IDXXTests/XXPROJECT_TITLEXXTests.m +22 -0
- data/spec/fixtures/template-repository/Interactive/Interactive.klippspec +15 -0
- data/spec/fixtures/template-repository/Interactive/XXSUBJECT_UNDER_TESTXXTests.m +15 -0
- data/spec/klipp/configuration_spec.rb +8 -0
- data/spec/klipp/creator_spec.rb +120 -0
- data/spec/klipp_spec.rb +80 -85
- data/spec/spec_helper.rb +8 -2
- data/spec/template/spec_spec.rb +225 -0
- data/spec/template/token_spec.rb +100 -0
- data/spec/template_spec.rb +82 -0
- metadata +118 -43
- data/lib/klipp/buffered_output.rb +0 -17
- data/lib/klipp/project.rb +0 -46
- data/lib/klipp/template.rb +0 -50
- data/lib/klipp/token.rb +0 -35
- data/spec/fixtures/klipps/Example.klippfile +0 -4
- data/spec/fixtures/klipps/ExcessiveExample.klippfile +0 -5
- data/spec/fixtures/klipps/Generated.klippfile +0 -11
- data/spec/fixtures/klipps/LackingExample.klippfile +0 -3
- data/spec/fixtures/klipps/MalformedExample.klippfile +0 -4
- data/spec/fixtures/klipps/single-token.yml +0 -5
- data/spec/fixtures/templates/Example/RegularFileWithContents.txt +0 -3
- data/spec/fixtures/templates/Example/XXCLASS_PREFIXXXPrefixedFile.txt +0 -3
- data/spec/fixtures/templates/Example/XXPROJECT_IDXX/BinaryFile.png +0 -0
- data/spec/fixtures/templates/Example/XXPROJECT_IDXX/XXCLASS_PREFIXXXPrefixedFileInDirectory.txt +0 -3
- data/spec/fixtures/templates/Example.yml +0 -29
- data/spec/klipp/project_spec.rb +0 -46
- data/spec/klipp/template_spec.rb +0 -80
- data/spec/klipp/token_spec.rb +0 -86
data/spec/klipp/template_spec.rb
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Klipp::Template do
|
|
4
|
-
|
|
5
|
-
it 'raises an error when initialized with an invalid path or name' do
|
|
6
|
-
expect {
|
|
7
|
-
Klipp::Template.new('bull', 'shit')
|
|
8
|
-
}.to raise_error(RuntimeError)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
context 'with a valid path and name' do
|
|
12
|
-
|
|
13
|
-
before do
|
|
14
|
-
@templates_dir = File.join(__dir__, '..', 'fixtures', 'templates')
|
|
15
|
-
@klipps_dir = File.join(__dir__, '..', 'fixtures', 'klipps')
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it 'initializes' do
|
|
19
|
-
Klipp::Template.new(@templates_dir, 'Example').should be_a Klipp::Template
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
xit 'validates the template yml' do
|
|
23
|
-
true.should eq false
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
context 'with a template object' do
|
|
27
|
-
|
|
28
|
-
before do
|
|
29
|
-
@template = Klipp::Template.new(@templates_dir, 'Example')
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it 'knows the name of the corresponding .klippfile' do
|
|
33
|
-
@template.klippfile.should eq 'Example.klippfile'
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it 'can generate stubbed contents for a .klippfile' do
|
|
37
|
-
@template.generated_klippfile.should eq File.read(File.join(@klipps_dir,'Generated.klippfile'))
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it 'contains a matching number of tokens' do
|
|
41
|
-
@template.tokens.should have_exactly(4).items
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it 'loads the token values from a valid Klippfile' do
|
|
45
|
-
@template.load_klippfile File.join(@klipps_dir, 'Example.klippfile')
|
|
46
|
-
@template['PARTNER'].should eq 'The Prestigeous Partner'
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it 'raises an error when the Klippfile is malformed' do
|
|
50
|
-
expect { @template.load_klippfile File.join(@klipps_dir, 'MalformedExample.klippfile') }.to raise_error RuntimeError
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it 'raises an error when the Klippfile contains excess tokens' do
|
|
54
|
-
expect { @template.load_klippfile File.join(@klipps_dir, 'ExcessiveExample.klippfile') }.to raise_error RuntimeError
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it 'raises an error when the Klippfile contains too few tokens' do
|
|
58
|
-
expect { @template.load_klippfile File.join(@klipps_dir, 'LackingExample.klippfile') }.to raise_error RuntimeError
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
context 'with a template object and token values' do
|
|
64
|
-
|
|
65
|
-
before do
|
|
66
|
-
@template = Klipp::Template.new(@templates_dir, 'Example')
|
|
67
|
-
@template['CLASS_PREFIX'] = 'PJX'
|
|
68
|
-
@template['PROJECT_ID'] = 'ProjectX'
|
|
69
|
-
@template['PROJECT_TITLE'] = 'Project X'
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
it 'replaces delimited tokens in a string' do
|
|
73
|
-
@template.replace_tokens('XXCLASS_PREFIXXX XXPROJECT_IDXX XXPROJECT_TITLEXX').should eq 'PJX ProjectX Project X'
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
end
|
data/spec/klipp/token_spec.rb
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'highline/import'
|
|
3
|
-
|
|
4
|
-
describe Klipp::Token do
|
|
5
|
-
|
|
6
|
-
context 'with a single token yaml' do
|
|
7
|
-
|
|
8
|
-
before do
|
|
9
|
-
@token = Klipp::Token.new read_fixture('klipps/single-token.yml')
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it 'has a title' do
|
|
13
|
-
@token.title.should eq 'Partner name'
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it 'has a subtitle' do
|
|
17
|
-
@token.subtitle.should eq "e.g. 'FC Utrecht'"
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'has a default value' do
|
|
21
|
-
@token.default.should eq 'Qwerty'
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it 'has a validate regex' do
|
|
25
|
-
@token.validate.should eq /^[A-Z][A-Za-z0-9 ]{2,}$/
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it 'has a response when not valid' do
|
|
29
|
-
@token.not_valid_response.should eq 'Should be at least three characters long and start with a capital character'
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
context 'with a valid token object' do
|
|
35
|
-
|
|
36
|
-
before do
|
|
37
|
-
@input = StringIO.new
|
|
38
|
-
@output = StringIO.new
|
|
39
|
-
@terminal = HighLine.new(@input, @output)
|
|
40
|
-
@token = Klipp::Token.new read_fixture('klipps/single-token.yml')
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it 'can ask a question' do
|
|
44
|
-
simulate_input 'Something'
|
|
45
|
-
|
|
46
|
-
@token.ask_for_input @terminal
|
|
47
|
-
|
|
48
|
-
@output.string.should include 'Partner name'
|
|
49
|
-
@output.string.should include "e.g. 'FC Utrecht'"
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
it 'records the answer' do
|
|
53
|
-
name = 'Qwerty'
|
|
54
|
-
simulate_input name
|
|
55
|
-
|
|
56
|
-
@token.ask_for_input @terminal
|
|
57
|
-
|
|
58
|
-
@token.value.should eq name
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
it 'uses highline validation' do
|
|
62
|
-
simulate_input 'Qw'
|
|
63
|
-
|
|
64
|
-
expect {
|
|
65
|
-
@token.ask_for_input @terminal
|
|
66
|
-
}.to raise_error(EOFError)
|
|
67
|
-
|
|
68
|
-
@output.string.should include 'Should be at least three characters long and start with a capital character'
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it 'prefills a default value' do
|
|
72
|
-
simulate_input
|
|
73
|
-
|
|
74
|
-
@token.ask_for_input @terminal
|
|
75
|
-
|
|
76
|
-
@token.value.should eq 'Qwerty'
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def simulate_input(value = '')
|
|
80
|
-
@input << value << "\n"
|
|
81
|
-
@input.rewind
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
end
|