biosphere 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a24435290b475c48cf0a76c9bcb729f4098ae8b0
4
- data.tar.gz: 478204f4a3a5f72effaddbaf00c8269cfda567a6
3
+ metadata.gz: 07a529aa22b0274989393f6105d8ca6e3fda645b
4
+ data.tar.gz: 055f4a5f72c074c03e338d5cd28b3aaf4c2af184
5
5
  SHA512:
6
- metadata.gz: ee55dd0ea82d17978174f90e1dd5f020dcda1e048afd3d11527242cbd9720d9785cdf8e677c0b592138f84638d1d0fd0682b6029eeba3ff0f912ac628a73031c
7
- data.tar.gz: b9a5467ef26202789c73401d31cf35166b96c035edfb15563b49779712477169537b139556c72c64d4b642ad47d8ebf46490d491d50e9b59df08276303f683e1
6
+ metadata.gz: 77f8b8cfaf284f335622fce5f853604cbdd4eccb5e758cb1da3bf98556cc000fea73125ff3bfce4f54d65bbfdbb50cb94d739934f5be61e3ee2654f8d4935da1
7
+ data.tar.gz: 42aea2700cc84a49ac80127ee9762f2c05c74d10883041c81ec3db70902b35e72607d857dc304289f323329bd7d91000c082e01f9f2a919b781d19f225b53f1b
@@ -64,11 +64,21 @@ end
64
64
 
65
65
  if options.src
66
66
  suite = Biosphere::Suite.new(options.src)
67
+ if options.src == "./"
68
+ STDERR.puts "Loading suite from current directory (#{File.expand_path(options.src)}). Use --src to change the path"
69
+ end
70
+
67
71
  suite.load_all()
68
- else
69
- STDERR.puts "No --src set"
70
72
  end
71
73
 
74
+ if options.build
75
+ if !File.directory?(options.build)
76
+ STDERR.puts "Creating build directory #{options.build} because it was missing"
77
+ Dir.mkdir(options.build)
78
+ end
79
+ end
80
+
81
+
72
82
  if ARGV[0] == "json" && options.src
73
83
  suite.evaluate_resources()
74
84
 
@@ -90,7 +100,7 @@ end
90
100
 
91
101
  if ARGV[0] == "plan" && options.src
92
102
  suite.evaluate_plans()
93
- ap suite.node
103
+ ap suite.node, :indent=>-4
94
104
  end
95
105
 
96
106
  if ARGV[0] == "action" && options.src
@@ -98,6 +108,7 @@ if ARGV[0] == "action" && options.src
98
108
 
99
109
  context.build_directory = options.build
100
110
 
111
+ STDERR.puts "Executing action #{ARGV[1]}"
101
112
  suite.call_action(ARGV[1], context)
102
113
 
103
114
  suite.save_node()
@@ -1,4 +1,5 @@
1
1
  require 'pp'
2
+ require 'awesome_print'
2
3
 
3
4
  class Biosphere
4
5
  class Node
@@ -31,4 +32,52 @@ class Biosphere
31
32
  return Marshal.dump(self)
32
33
  end
33
34
  end
34
- end
35
+ end
36
+
37
+ module AwesomePrint
38
+ module Node
39
+ def self.included(base)
40
+ base.send :alias_method, :cast_without_node, :cast
41
+ base.send :alias_method, :cast, :cast_with_node
42
+ end
43
+
44
+ def cast_with_node(object, type)
45
+ cast = cast_without_node(object, type)
46
+ if (defined?(::Biosphere::Node)) && (object.is_a?(::Biosphere::Node))
47
+ cast = :node_instance
48
+ end
49
+ cast
50
+ end
51
+
52
+ def awesome_node_instance(object)
53
+ "#{object.class} #{awesome_hash(object.data)}"
54
+ end
55
+
56
+ end
57
+ end
58
+
59
+ module AwesomePrint
60
+ module IPAddress
61
+ def self.included(base)
62
+ base.send :alias_method, :cast_without_ipaddress, :cast
63
+ base.send :alias_method, :cast, :cast_with_ipaddress
64
+ end
65
+
66
+ def cast_with_ipaddress(object, type)
67
+ cast = cast_without_ipaddress(object, type)
68
+ if (defined?(::IPAddress)) && (object.is_a?(::IPAddress))
69
+ cast = :ipaddress_instance
70
+ end
71
+ cast
72
+ end
73
+
74
+ def awesome_ipaddress_instance(object)
75
+ "#{object.class}(#{object.to_string})"
76
+ end
77
+
78
+ end
79
+ end
80
+
81
+ AwesomePrint::Formatter.send(:include, AwesomePrint::Node)
82
+ AwesomePrint::Formatter.send(:include, AwesomePrint::IPAddress)
83
+
@@ -1,3 +1,3 @@
1
1
  class Biosphere
2
- Version = "0.0.3"
2
+ Version = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: biosphere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juho Mäkinen