syllabus 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4012747bcc3f4369b0a20f30051bbc5bf226346
4
- data.tar.gz: 755672d82968498ce8d5d4fefd0b5b3b84d8db4e
3
+ metadata.gz: f5b5883a98d5bf257cfcad935a27669565efde0e
4
+ data.tar.gz: 5baf224cc77f0319f1aca69dcc96d11d1443e19c
5
5
  SHA512:
6
- metadata.gz: adab2311b152819ccfb88ac76cbe4521a484b5276f1e5260ec0016ab0dcd5e135945002e59e694e10913a7b05f3ff072c8f1521a5962f67fdd2555d0df717e94
7
- data.tar.gz: 84bb6879c1f1c27e33033bb9ac344eb54ff354b310afa354bbcd541c98b7de217762dcb06f61f9bb70606d34a848c30a7c91b015967faf9553e5c506b17db0ea
6
+ metadata.gz: 6144c146067206f896b080e52cdedec6e23db8e60a4a25157958a8971e6d220b3b65d5b21f4141490c8b93a1ff9fcb745dfd8a6b7914e01778958bdb7b1e9ef2
7
+ data.tar.gz: 3c5130a794977a9f9b4aca4a89778aa17ce0cbdc944bc541a605a0deffcad852eb1f7f6b9ce84db78daa7d4bb3ed65d2000fefdd5d8cf65cb3ec3066eece64f0
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Syllabus [![BuildStatus](https://travis-ci.org/kentaro/syllabus.png)](http://travis-ci.org/kentaro/syllabus)
1
+ # Syllabus [![BuildStatus](https://travis-ci.org/serverspec/syllabus.png)](http://travis-ci.org/serverspec/syllabus)
2
2
 
3
3
  Syllabus is a configuration management tool for the era of "immutable infrastructure." which just provides a thin abstraction layer onto plain shell script.
4
4
 
@@ -1,4 +1,3 @@
1
- os_type 'Darwin'
2
1
  hosts %w[localhost]
3
2
  path ENV['PATH']
4
3
  install 'git'
@@ -2,15 +2,6 @@ module Syllabus
2
2
  require 'syllabus/version'
3
3
  require 'syllabus/cli'
4
4
  require 'syllabus/core'
5
- require 'syllabus/logger'
6
5
  require 'syllabus/config'
7
- require 'syllabus/backend'
8
- require 'syllabus/command'
9
- require 'syllabus/command/base'
10
- require 'syllabus/command/darwin'
11
- require 'syllabus/command/linux'
12
- require 'syllabus/command/redhat'
6
+ require 'syllabus/logger'
13
7
  end
14
-
15
- require 'specinfra'
16
-
@@ -1,16 +1,16 @@
1
1
  class Syllabus::Config
2
2
  attr_reader :commands
3
3
 
4
- def self.new_from_file(file)
5
- configuration = File.read(file)
6
- new(configuration, file)
4
+ def self.new_from_file(args)
5
+ config = File.read(args[:file])
6
+ new(config: config, file: args[:file], backend: args[:backend])
7
7
  end
8
8
 
9
- def initialize(configuration, file = '')
9
+ def initialize(args)
10
+ @backend = args[:backend]
10
11
  @hosts = nil
11
- @os_type = nil
12
12
  @commands = []
13
- instance_eval(configuration, file)
13
+ instance_eval(args[:config], args[:file] || '')
14
14
  end
15
15
 
16
16
  def hosts(arg = nil)
@@ -21,29 +21,16 @@ class Syllabus::Config
21
21
  @hosts
22
22
  end
23
23
 
24
- def os_type(arg = nil)
25
- if arg
26
- @os_type = arg.kind_of?(Proc) ? arg.call : arg
27
- end
28
-
29
- @os_type
30
- end
31
-
32
24
  def path(arg = nil)
33
25
  if arg
34
- @path = arg.kind_of?(Proc) ? arg.call : arg
35
- SpecInfra::Configuration.path = @path
26
+ @path = arg.kind_of?(Array) ? arg : arg.split(':')
36
27
  end
37
28
 
38
29
  @path
39
30
  end
40
31
 
41
32
  def method_missing(name, *args)
42
- command = Syllabus::Command.new(
43
- os_type: os_type,
44
- name: name,
45
- args: args,
46
- )
33
+ command = @backend.commands.send(name, *args)
47
34
  @commands.push(command)
48
35
  end
49
36
  end
@@ -1,11 +1,16 @@
1
+ require 'specinfra'
2
+
1
3
  class Syllabus::Core
4
+ extend SpecInfra::Helper::Backend
5
+ extend SpecInfra::Helper::DetectOS
6
+
2
7
  def self.run(args)
3
- config = Syllabus::Config.new_from_file(args[:file])
4
- backend = Syllabus::Backend.new(type: args[:type])
8
+ backend = backend_for(args[:type])
9
+ config = Syllabus::Config.new_from_file(file: args[:file], backend: backend)
5
10
  logger = Syllabus::Logger.new(level: args[:level])
6
11
 
7
12
  config.commands.each do |command|
8
- result = backend.run_command(command.to_s)
13
+ result = backend.run_command(command)
9
14
  logger.log(command, result)
10
15
  end
11
16
  end
@@ -1,3 +1,3 @@
1
1
  module Syllabus
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,6 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Syllabus::Config do
4
+ let(:backend) {
5
+ backend = SpecInfra::Backend.backend_for('Exec')
6
+ commands = SpecInfra::Command::RedHat.new
7
+ backend.set_commands(commands)
8
+ backend
9
+ }
10
+
4
11
  describe '#hosts' do
5
12
  context 'Hosts are passed as an Array' do
6
13
  let(:config) {
@@ -9,7 +16,7 @@ hosts %w[foo bar baz]
9
16
  EOS
10
17
  }
11
18
  subject {
12
- described_class.new(config)
19
+ described_class.new(backend: backend, config: config)
13
20
  }
14
21
 
15
22
  it { expect(subject.hosts).to be == %w[foo bar baz] }
@@ -22,38 +29,38 @@ hosts -> { %w[foo bar baz] }
22
29
  EOS
23
30
  }
24
31
  subject {
25
- described_class.new(config)
32
+ described_class.new(backend: backend, config: config)
26
33
  }
27
34
 
28
35
  it { expect(subject.hosts).to be == %w[foo bar baz] }
29
36
  end
30
37
  end
31
38
 
32
- describe '#os_type' do
33
- context 'os_type are passed as a String' do
39
+ describe '#path' do
40
+ context 'path are passed as an Array' do
34
41
  let(:config) {
35
42
  <<EOS
36
- os_type 'RedHat'
43
+ path %w[/bin /usr/bin]
37
44
  EOS
38
45
  }
39
46
  subject {
40
- described_class.new(config)
47
+ described_class.new(backend: backend, config: config)
41
48
  }
42
49
 
43
- it { expect(subject.os_type).to be == 'RedHat' }
50
+ it { expect(subject.path).to be == %w[/bin /usr/bin] }
44
51
  end
45
52
 
46
- context 'os_type are passed as a Proc' do
53
+ context 'path are passed as a String' do
47
54
  let(:config) {
48
55
  <<EOS
49
- os_type -> { 'RedHat' }
56
+ path '/bin:/usr/bin'
50
57
  EOS
51
58
  }
52
59
  subject {
53
- described_class.new(config)
60
+ described_class.new(backend: backend, config: config)
54
61
  }
55
62
 
56
- it { expect(subject.os_type).to be == 'RedHat' }
63
+ it { expect(subject.path).to be == %w[/bin /usr/bin] }
57
64
  end
58
65
  end
59
66
 
@@ -64,12 +71,12 @@ install 'httpd'
64
71
  EOS
65
72
  }
66
73
  subject {
67
- described_class.new(config)
74
+ described_class.new(backend: backend, config: config)
68
75
  }
69
76
 
70
77
  it {
71
78
  expect(subject.commands.length).to be == 1
72
- expect(subject.commands.first).to be_an_instance_of Syllabus::Command
79
+ expect(subject.commands.first).to be_an_instance_of String
73
80
  }
74
81
  end
75
82
  end
@@ -19,10 +19,10 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_dependency 'specinfra'
22
- spec.add_dependency 'configspec'
23
22
  spec.add_dependency 'thor'
24
23
  spec.add_dependency 'term-ansicolor'
25
24
 
26
25
  spec.add_development_dependency 'bundler', '~> 1.3'
27
26
  spec.add_development_dependency 'rake'
27
+ spec.add_development_dependency 'rspec'
28
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syllabus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kentaro Kuribayashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-02 00:00:00.000000000 Z
11
+ date: 2013-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: specinfra
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: configspec
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: thor
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +80,20 @@ dependencies:
94
80
  - - '>='
95
81
  - !ruby/object:Gem::Version
96
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
97
  description: Yet Another Configuration Management Tool in the Era of Immutable Infrastructure
98
98
  email:
99
99
  - kentarok@gmail.com
@@ -111,19 +111,11 @@ files:
111
111
  - bin/syllabus
112
112
  - examples/mac.rb
113
113
  - lib/syllabus.rb
114
- - lib/syllabus/backend.rb
115
114
  - lib/syllabus/cli.rb
116
- - lib/syllabus/command.rb
117
- - lib/syllabus/command/base.rb
118
- - lib/syllabus/command/darwin.rb
119
- - lib/syllabus/command/linux.rb
120
- - lib/syllabus/command/redhat.rb
121
115
  - lib/syllabus/config.rb
122
116
  - lib/syllabus/core.rb
123
117
  - lib/syllabus/logger.rb
124
118
  - lib/syllabus/version.rb
125
- - spec/lib/syllabus/backend_spec.rb
126
- - spec/lib/syllabus/command_spec.rb
127
119
  - spec/lib/syllabus/config_spec.rb
128
120
  - spec/spec_helper.rb
129
121
  - syllabus.gemspec
@@ -152,7 +144,5 @@ signing_key:
152
144
  specification_version: 4
153
145
  summary: Yet Another Configuration Management Tool in the Era of Immutable Infrastructure
154
146
  test_files:
155
- - spec/lib/syllabus/backend_spec.rb
156
- - spec/lib/syllabus/command_spec.rb
157
147
  - spec/lib/syllabus/config_spec.rb
158
148
  - spec/spec_helper.rb
@@ -1,25 +0,0 @@
1
- require 'delegate'
2
- require 'specinfra/backend'
3
-
4
- class Syllabus::Backend < Delegator
5
- attr_reader :backend_type
6
-
7
- class NotImplementedError < StandardError; end
8
-
9
- def initialize(args)
10
- @backend_type = args[:type]
11
- @backend = backend_class.instance
12
- end
13
-
14
- def backend_class
15
- if SpecInfra::Backend.const_defined?(backend_type.to_sym)
16
- SpecInfra::Backend.const_get(backend_type.to_sym)
17
- else
18
- raise NotImplementedError.new("Backend for #{backend_type} has not been implemented yet")
19
- end
20
- end
21
-
22
- def __getobj__
23
- @backend
24
- end
25
- end
@@ -1,28 +0,0 @@
1
- require 'configspec/commands/base'
2
- require 'configspec/commands/linux'
3
- require 'configspec/commands/redhat'
4
-
5
- class Syllabus::Command
6
- attr_reader :os_type, :name, :args
7
-
8
- class NotImplementedError < StandardError; end
9
-
10
- def initialize(args)
11
- @os_type = args[:os_type]
12
- @name = args[:name]
13
- @args = args[:args]
14
- end
15
-
16
- def command_class
17
- if Syllabus::Command.const_defined?(os_type.to_sym)
18
- Syllabus::Command.const_get(os_type.to_sym)
19
- else
20
- raise NotImplementedError.new("Command for #{os_type} has not been implemented yet")
21
- end
22
- end
23
-
24
- def to_s
25
- command = command_class.new
26
- command.send(name.to_sym, args.first)
27
- end
28
- end
@@ -1,2 +0,0 @@
1
- class Syllabus::Command::Base < Configspec::Commands::Base
2
- end
@@ -1,5 +0,0 @@
1
- class Syllabus::Command::Darwin < Configspec::Commands::Base
2
- def install(package)
3
- cmd = "brew install '#{package}'"
4
- end
5
- end
@@ -1,2 +0,0 @@
1
- class Syllabus::Command::Linux < Configspec::Commands::Linux
2
- end
@@ -1,2 +0,0 @@
1
- class Syllabus::Command::RedHat < Configspec::Commands::RedHat
2
- end
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Syllabus::Backend do
4
- describe '#backend_class' do
5
- context 'when a backend class found' do
6
- subject {
7
- Syllabus::Backend.new(type: 'Exec')
8
- }
9
-
10
- it { expect(subject.backend_class).to be == SpecInfra::Backend::Exec }
11
- end
12
-
13
- context 'when no command class found' do
14
- subject {
15
- Syllabus::Backend.new(type: 'NoSuchType')
16
- }
17
-
18
- it {
19
- expect { subject.backend_class }.to raise_error Syllabus::Backend::NotImplementedError
20
- }
21
- end
22
- end
23
- end
@@ -1,59 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Syllabus::Command do
4
- describe '#command_class' do
5
- context 'when a command class found' do
6
- subject {
7
- Syllabus::Command.new(
8
- os_type: 'RedHat',
9
- name: :install,
10
- args: %w['httpd'],
11
- )
12
- }
13
-
14
- it { expect(subject.command_class).to be == Syllabus::Command::RedHat }
15
- end
16
-
17
- context 'when no command class found' do
18
- subject {
19
- Syllabus::Command.new(
20
- os_type: 'NoSuchType',
21
- name: :install,
22
- args: %w['httpd'],
23
- )
24
- }
25
-
26
- it {
27
- expect { subject.command_class }.to raise_error Syllabus::Command::NotImplementedError
28
- }
29
- end
30
- end
31
-
32
- describe '#to_s' do
33
- context 'when a command class found' do
34
- subject {
35
- Syllabus::Command.new(
36
- os_type: 'RedHat',
37
- name: :install,
38
- args: %w['httpd'],
39
- )
40
- }
41
-
42
- it { expect(subject.to_s).to be == "yum -y install 'httpd'" }
43
- end
44
-
45
- context 'when no command class found' do
46
- subject {
47
- Syllabus::Command.new(
48
- os_type: 'NoSuchType',
49
- name: :install,
50
- args: %w['httpd'],
51
- )
52
- }
53
-
54
- it {
55
- expect { subject.to_s }.to raise_error Syllabus::Command::NotImplementedError
56
- }
57
- end
58
- end
59
- end