stevenson 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/assets/stevenson_dotfile.yml +29 -0
  4. data/lib/stevenson/application.rb +34 -29
  5. data/lib/stevenson/dotfile.rb +26 -0
  6. data/lib/stevenson/output_filter/generator.rb +30 -0
  7. data/lib/stevenson/output_filter.rb +42 -0
  8. data/lib/stevenson/output_filters/jekyll.rb +6 -13
  9. data/lib/stevenson/output_filters/zip.rb +12 -14
  10. data/lib/stevenson/template/loader.rb +36 -0
  11. data/lib/stevenson/template.rb +35 -0
  12. data/lib/stevenson/templates/git.rb +16 -17
  13. data/lib/stevenson/templates/local.rb +21 -0
  14. data/lib/stevenson/version.rb +1 -1
  15. data/lib/stevenson.rb +9 -7
  16. data/spec/bin/.gitkeep +0 -0
  17. data/spec/lib/output_filter/generator_spec.rb +37 -0
  18. data/spec/lib/output_filter_spec.rb +57 -0
  19. data/spec/lib/output_filters/jekyll_spec.rb +23 -0
  20. data/spec/lib/output_filters/zip_spec.rb +19 -0
  21. data/spec/lib/template/loader_spec.rb +35 -0
  22. data/spec/lib/template_spec.rb +20 -0
  23. data/spec/lib/templates/git_spec.rb +43 -0
  24. data/spec/lib/templates/local_spec.rb +42 -0
  25. data/stevenson.gemspec +3 -2
  26. metadata +44 -40
  27. data/assets/template_aliases.yml +0 -36
  28. data/lib/stevenson/configurators/yaml_configurator.rb +0 -79
  29. data/lib/stevenson/input/email.rb +0 -19
  30. data/lib/stevenson/input/password.rb +0 -19
  31. data/lib/stevenson/input/select.rb +0 -69
  32. data/lib/stevenson/input/text.rb +0 -28
  33. data/lib/stevenson/input/url.rb +0 -19
  34. data/lib/stevenson/input.rb +0 -51
  35. data/lib/stevenson/template_loader.rb +0 -50
  36. data/lib/stevenson/templates/base.rb +0 -45
  37. data/lib/stevenson/templates/invalid_template_exception.rb +0 -6
  38. data/spec/configurators/yaml_configurator_spec.rb +0 -12
  39. data/spec/input/email_spec.rb +0 -12
  40. data/spec/input/password_spec.rb +0 -12
  41. data/spec/input/select_spec.rb +0 -12
  42. data/spec/input/text_spec.rb +0 -12
  43. data/spec/input/url_spec.rb +0 -12
  44. data/spec/input_spec.rb +0 -38
  45. data/spec/output_filters/jekyll_spec.rb +0 -17
  46. data/spec/output_filters/zip_spec.rb +0 -17
  47. data/spec/template_loader_spec.rb +0 -51
  48. data/spec/templates/base_spec.rb +0 -83
  49. data/spec/templates/git_spec.rb +0 -37
@@ -1,6 +0,0 @@
1
- module Stevenson
2
- module Templates
3
- class InvalidTemplateException < StandardError
4
- end
5
- end
6
- end
@@ -1,12 +0,0 @@
1
- describe Stevenson::Configurator::YAMLConfigurator do
2
- describe '#initialize' do
3
- let(:temporary_directory) { Dir.mktmpdir }
4
- let(:yaml_configurator) { Stevenson::Configurator::YAMLConfigurator.new temporary_directory }
5
-
6
- it 'creates a new configurator' do
7
- expect(yaml_configurator).to be_an_instance_of Stevenson::Configurator::YAMLConfigurator
8
- end
9
-
10
- after { FileUtils.remove_entry_secure temporary_directory }
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- describe Stevenson::Input::Email do
2
- describe '#initialize' do
3
- let(:text_input) { Stevenson::Input::Email.new({}) }
4
-
5
- it 'creates a new email input' do
6
- expect(text_input).to be_an_instance_of Stevenson::Input::Email
7
- end
8
- end
9
-
10
- describe '#collect!' do
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- describe Stevenson::Input::Password do
2
- describe '#initialize' do
3
- let(:text_input) { Stevenson::Input::Password.new({}) }
4
-
5
- it 'creates a new password input' do
6
- expect(text_input).to be_an_instance_of Stevenson::Input::Password
7
- end
8
- end
9
-
10
- describe '#collect!' do
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- describe Stevenson::Input::Select do
2
- describe '#initialize' do
3
- let(:text_input) { Stevenson::Input::Select.new({}) }
4
-
5
- it 'creates a new selection input' do
6
- expect(text_input).to be_an_instance_of Stevenson::Input::Select
7
- end
8
- end
9
-
10
- describe '#collect!' do
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- describe Stevenson::Input::Text do
2
- describe '#initialize' do
3
- let(:text_input) { Stevenson::Input::Text.new({}) }
4
-
5
- it 'creates a new text input' do
6
- expect(text_input).to be_an_instance_of Stevenson::Input::Text
7
- end
8
- end
9
-
10
- describe '#collect!' do
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- describe Stevenson::Input::Url do
2
- describe '#initialize' do
3
- let(:text_input) { Stevenson::Input::Url.new({}) }
4
-
5
- it 'creates a new url input' do
6
- expect(text_input).to be_an_instance_of Stevenson::Input::Url
7
- end
8
- end
9
-
10
- describe '#collect!' do
11
- end
12
- end
data/spec/input_spec.rb DELETED
@@ -1,38 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Stevenson::Input
4
- class Test
5
- include Base
6
- end
7
- end
8
-
9
- describe Stevenson::Input do
10
- let(:input) { double(:test_input) }
11
- let(:options) { Hash['type' => :test] }
12
- before { allow(Stevenson::Input::Test).to receive(:new).and_return(input) }
13
-
14
- describe ".input_for()" do
15
- context "when the input has been registered previously" do
16
- it "should return the input class from Stevenson.inputs" do
17
- expect(Stevenson::Input.input_for(options)).to eq(input)
18
- end
19
- end
20
-
21
- context "when the input has not been registered previously" do
22
- it "should return the fetched class from Stevenson" do
23
- allow(Stevenson).to receive(:inputs).and_return({})
24
- expect(Stevenson::Input.input_for(options)).to eq(input)
25
- end
26
- end
27
-
28
- context "when the input doesn't exist" do
29
- it "should raise a NameError with a descriptive error message" do
30
- expect { Stevenson::Input.input_for('type' => :bad_input) }.to raise_error do |error|
31
- expect(error).to be_a(NameError)
32
- expect(error.message).to eq("Type 'bad_input' is not a valid input type.")
33
- expect(error.cause).to be_a(NameError)
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,17 +0,0 @@
1
- describe Stevenson::OutputFilters::JekyllFilter do
2
- describe '#output' do
3
- let(:temporary_directory) { Dir.mktmpdir }
4
- let(:template) { Stevenson::TemplateLoader.load 'hyde-base' }
5
-
6
- before do
7
- template.extend(subject)
8
- template.output temporary_directory
9
- end
10
-
11
- it 'outputs a jekyll compiled directory' do
12
- expect(File.exists? File.join(temporary_directory, '_config.yml')).to eq false
13
- end
14
-
15
- after { FileUtils.remove_entry_secure temporary_directory }
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- describe Stevenson::OutputFilters::ZipFilter do
2
- describe '#output' do
3
- let(:temporary_directory) { Dir.mktmpdir }
4
- let(:template) { Stevenson::Templates::GitTemplate.new 'https://github.com/RootsRated/stevenson-base-template.git' }
5
-
6
- before do
7
- template.extend(subject)
8
- template.output File.join(temporary_directory, 'archive.zip')
9
- end
10
-
11
- it 'outputs a zipped directory' do
12
- expect(File.exists? File.join(temporary_directory, 'archive.zip')).to eq true
13
- end
14
-
15
- after { FileUtils.remove_entry_secure temporary_directory }
16
- end
17
- end
@@ -1,51 +0,0 @@
1
- describe Stevenson::TemplateLoader do
2
- subject { Stevenson::TemplateLoader }
3
-
4
- describe '.load' do
5
- context 'when given a template alias' do
6
- let(:template_alias) { 'hyde-base' }
7
- let(:template) { subject.load template_alias }
8
-
9
- it 'returns the appropriate template' do
10
- expect(template).to be_an_instance_of Stevenson::Templates::GitTemplate
11
- end
12
-
13
- after do
14
- Dir.mktmpdir do |dir|
15
- template.output dir
16
- end
17
- end
18
- end
19
-
20
- context 'when given a git url' do
21
- let(:url) { 'https://github.com/RootsRated/stevenson-base-template.git' }
22
- let(:template) { subject.load url }
23
-
24
- it 'returns the appropriate template' do
25
- expect(template).to be_an_instance_of Stevenson::Templates::GitTemplate
26
- end
27
-
28
- after do
29
- Dir.mktmpdir do |dir|
30
- template.output dir
31
- end
32
- end
33
- end
34
-
35
- context 'when given a path' do
36
- let(:path) { Dir.mktmpdir }
37
- let(:template) { subject.load path }
38
-
39
- it 'returns the appropriate template' do
40
- expect(template).to be_an_instance_of Stevenson::Templates::Base
41
- end
42
-
43
- after do
44
- FileUtils.remove_entry_secure path
45
- Dir.mktmpdir do |dir|
46
- template.output dir
47
- end
48
- end
49
- end
50
- end
51
- end
@@ -1,83 +0,0 @@
1
- describe Stevenson::Templates::Base do
2
- subject { Stevenson::Templates::Base }
3
-
4
- describe '#initialize' do
5
- context 'with a valid path' do
6
- let(:path) { Dir.mktmpdir }
7
-
8
- before { FileUtils.touch File.join(path, '_stevenson.yml') }
9
-
10
- it 'creates a new Template' do
11
- expect( subject.new path ).to be_an_instance_of Stevenson::Templates::Base
12
- end
13
-
14
- after { FileUtils.remove_entry_secure path }
15
- end
16
-
17
- context 'with an invalid path' do
18
- let(:path) { Dir.mktmpdir }
19
-
20
- it 'raises an invalid template exception' do
21
- expect{ subject.new File.join(path, 'not-a-path') }.to raise_exception Stevenson::Templates::InvalidTemplateException
22
- end
23
-
24
- after { FileUtils.remove_entry_secure path }
25
- end
26
- end
27
-
28
- describe '#path' do
29
- let(:path) { Dir.mktmpdir }
30
- let(:template) { subject.new path }
31
-
32
- before do
33
- FileUtils.touch File.join(path, '_stevenson.yml')
34
- end
35
-
36
- it 'returns the path of the template' do
37
- expect(File.exists? File.join(template.path, '_stevenson.yml')).to eq true
38
- end
39
-
40
- after { FileUtils.remove_entry_secure path }
41
- end
42
-
43
- describe '#select_subdirectory' do
44
- let(:path) { Dir.mktmpdir }
45
- let(:subdirectory) { 'subdirectory' }
46
- let(:template) { subject.new path }
47
-
48
- before do
49
- Dir.mkdir File.join(path, subdirectory)
50
- FileUtils.touch File.join(path, subdirectory, '_stevenson.yml')
51
- end
52
-
53
- it 'changes the path of the template to a given subdirectory' do
54
- template.select_subdirectory subdirectory
55
- expect(File.exists? File.join(template.path, '_stevenson.yml')).to eq true
56
- end
57
-
58
- after do
59
- template.output path
60
- FileUtils.remove_entry_secure path
61
- end
62
- end
63
-
64
- describe '#output' do
65
- let(:path) { Dir.mktmpdir }
66
- let(:template) { subject.new path }
67
- let(:temporary_directory) { Dir.mktmpdir }
68
-
69
- before { template.output File.join(temporary_directory, 'output') }
70
-
71
- it 'outputs the finished template to the directory' do
72
- expect(File.exists? File.join(temporary_directory, 'output')).to eq true
73
- end
74
-
75
- it 'destroys the temporary directory' do
76
- expect(File.exists? template.path).to eq false
77
- end
78
-
79
- after do
80
- FileUtils.remove_entry_secure temporary_directory
81
- end
82
- end
83
- end
@@ -1,37 +0,0 @@
1
- describe Stevenson::Templates::GitTemplate do
2
- subject { Stevenson::Templates::GitTemplate }
3
-
4
- describe '#initialize' do
5
- context 'with a valid URL' do
6
- let(:template) { subject.new 'https://github.com/RootsRated/stevenson-base-template.git' }
7
-
8
- it 'creates a new GitTemplate' do
9
- expect(template).to be_an_instance_of Stevenson::Templates::GitTemplate
10
- end
11
-
12
- it 'clones the given repository to the working template path' do
13
- expect(File.exists? File.join(template.path, 'base', '_config.yml')).to eq true
14
- end
15
- end
16
-
17
- context 'with an invalid URL' do
18
- let(:invalid_url) { 'https://github.com/RootsRated/not-a-repo.git' }
19
-
20
- it 'raises an invalid template exception' do
21
- expect{ subject.new invalid_url }.to raise_exception(Stevenson::Templates::InvalidTemplateException)
22
- end
23
- end
24
- end
25
-
26
- describe '#switch_branch' do
27
- let(:branch) { 'master' }
28
- let(:template) { subject.new 'https://github.com/RootsRated/stevenson-base-template.git' }
29
-
30
- before { template.switch_branch branch }
31
-
32
- it 'checksout the repo to the given branch' do
33
- repo = Git::Base.open(template.path)
34
- expect(repo.current_branch).to eq branch
35
- end
36
- end
37
- end