outline 0.1.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.
@@ -0,0 +1,26 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ outline (0.1.0)
5
+ meta_tools (~> 0.2.6)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.1.3)
11
+ meta_tools (0.2.6)
12
+ rspec (2.6.0)
13
+ rspec-core (~> 2.6.0)
14
+ rspec-expectations (~> 2.6.0)
15
+ rspec-mocks (~> 2.6.0)
16
+ rspec-core (2.6.4)
17
+ rspec-expectations (2.6.0)
18
+ diff-lcs (~> 1.1.2)
19
+ rspec-mocks (2.6.0)
20
+
21
+ PLATFORMS
22
+ ruby
23
+
24
+ DEPENDENCIES
25
+ outline!
26
+ rspec (~> 2.6.0)
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,61 @@
1
+ require 'bundler/setup'
2
+ require 'meta_tools'
3
+
4
+ class Outline
5
+ class ArgumentWithBlockError < StandardError
6
+ def to_s; "You cannot give an argument with a block"; end
7
+ end
8
+
9
+ include MetaTools
10
+
11
+ attr_reader :parent
12
+
13
+ def initialize(opts={}, &blk)
14
+ raise(TypeError, "opts must respond to :to_hash or be nil") unless opts.nil? || opts.respond_to?(:to_hash)
15
+ raise(TypeError, "opts[:data] must respond to :to_h or :to_hash or be nil") unless opts.nil? || opts.respond_to?(:to_hash) || opts.respond_to?(:to_h)
16
+
17
+ opts = opts.to_hash
18
+ data = opts[:data].respond_to?(:to_hash) ? opts[:data].to_hash : opts[:data].to_h unless opts[:data].nil?
19
+
20
+ @parent, @data = opts[:parent], data
21
+
22
+ instance_eval(&blk) if block_given?
23
+ end
24
+
25
+ def method_missing(meth, *args, &blk)
26
+ meth = meth.to_s.gsub(/=$/, '').to_sym if meth =~ /=$/
27
+
28
+ meta_def(meth) do |value=nil, &blk|
29
+ block_given, value_given = !blk.nil?, !value.nil?
30
+ @data ||= {}
31
+
32
+ if !block_given && !value_given
33
+ @data[meth] = Outline.new(parent: self) unless @data.has_key?(meth)
34
+
35
+ @data[meth]
36
+ elsif block_given && value_given
37
+ raise ArgumentWithBlockError
38
+ elsif !block_given && value_given
39
+ @data[meth] = value
40
+ elsif block_given && !value_given
41
+ @data[meth] = Outline.new(parent: self, &blk)
42
+ end
43
+
44
+ end unless methods.include?(meth)
45
+
46
+ meta_def("#{meth}=") { |value| send(meth, value) }
47
+
48
+ send(meth, *args, &blk)
49
+ end
50
+
51
+ def to_h
52
+ @data.inject({}) do |memo, (key, value)|
53
+ memo[key] = value.respond_to?(:to_h) ? value.to_h : value
54
+ memo
55
+ end
56
+ end
57
+
58
+ # def to_json; end
59
+ # def to_xml; end
60
+ # def to_yaml; end
61
+ end
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+
3
+ describe Outline do
4
+ let(:config) do
5
+ Outline.new(:data => { :testing => 'testing' }) do
6
+ foo "foo"
7
+ self.timestamp_format = "%Y%m%d%H%M%S"
8
+
9
+ web do
10
+ server "my-proj.com"
11
+ branch "master"
12
+ remote "origin"
13
+ end
14
+
15
+ commands do
16
+ ssh "ssh deployer@#{parent.web.server}"
17
+ end
18
+
19
+ some.deep.indented.config 'foo'
20
+ end
21
+ end
22
+
23
+ describe "getters" do
24
+ it "should work" do
25
+ config.testing.should == "testing"
26
+ config.foo.should == "foo"
27
+ proc { config.foo = "bar" }.call.should == "bar"
28
+ config.timestamp_format.should == "%Y%m%d%H%M%S"
29
+ config.some.deep.indented.config.should == 'foo'
30
+ end
31
+ end
32
+
33
+ describe "#web" do
34
+ subject { config.web }
35
+ it { should be_a(Outline) }
36
+
37
+ it "should return the correct values" do
38
+ subject.server.should == "my-proj.com"
39
+ subject.branch.should == "master"
40
+ subject.remote.should == "origin"
41
+ end
42
+ end
43
+
44
+ describe "#commands" do
45
+ subject { config.commands }
46
+ it { should be_a(Outline) }
47
+
48
+ describe "#ssh" do
49
+ subject { config.commands.ssh }
50
+ it { should == "ssh deployer@my-proj.com" }
51
+ end
52
+ end
53
+
54
+ describe "#to_h" do
55
+ it "should return the correct Hash output" do
56
+ config.to_h.should == {
57
+ :testing => 'testing',
58
+ :foo => 'foo',
59
+ :timestamp_format => "%Y%m%d%H%M%S",
60
+ :web => {
61
+ :server => "my-proj.com",
62
+ :branch => "master",
63
+ :remote => "origin"
64
+ },
65
+ :commands => {
66
+ :ssh => "ssh deployer@my-proj.com"
67
+ },
68
+ :some => {
69
+ :deep => {
70
+ :indented => {
71
+ :config => 'foo'
72
+ }
73
+ }
74
+ }
75
+ }
76
+ end
77
+ end
78
+
79
+ end
@@ -0,0 +1,3 @@
1
+ require 'outline'
2
+
3
+ system('clear')
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: outline
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ryan Scott Lewis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-22 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: meta_tools
16
+ requirement: &70132294995180 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.2.6
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70132294995180
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70132294994700 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.6.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70132294994700
36
+ description: Easily set configurations on your Ruby apps.
37
+ email: c00lryguy@gmail.com
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files:
41
+ - VERSION
42
+ files:
43
+ - VERSION
44
+ - Gemfile.lock
45
+ - lib/outline.rb
46
+ - spec/outline_spec.rb
47
+ - spec/spec_helper.rb
48
+ homepage: http://github.com/c00lryguy/outline
49
+ licenses: []
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 1.8.10
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: Simplify your configurations.
72
+ test_files:
73
+ - spec/outline_spec.rb
74
+ - spec/spec_helper.rb
75
+ has_rdoc: