osx_provision 0.9.5 → 0.9.6

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: 172e6b6dc672db164ae68d7e8159382c6fb8b1c5
4
- data.tar.gz: 02625a468084a21a7d3438b02300ee6967a1b4e9
3
+ metadata.gz: e8a6f0c727bfe2456a12a469d9f01a94b4149062
4
+ data.tar.gz: 6d6fbd395803b7c2697daacecc1551f31f89c405
5
5
  SHA512:
6
- metadata.gz: 0f0a63e5afe741760cf26208ceaeca3b61733d079c0930d2d5632b7816971aaafe844a59fa0b00a8e27654b9327a2c1f03f3590269e2b5321ef71d28904a7073
7
- data.tar.gz: 5e0850d86bc7ab3a074948f1dd9d0b6a733683c4d954530aaf56c6b37651bfa4ba107708615882593f990edf03d439db793f859fa8a791fd06c8fd80e09469ab
6
+ metadata.gz: 45f6ab87c51f79049a231139610e53ce47a7b09638a8e2f514c3476b6d3c2dda09ef10b089d0b566b6a737af07706372d779ca340bf75fafbfd1502e9d059e4e
7
+ data.tar.gz: 706542524a790db5c9c5a7acd729f885a5513ef04b29b6361b2c5a424a5dbc49fa76753891b73bcb34d435db3ea0736ef63e1c95d3efeb8df879675b3c52fc8b
data/CHANGES CHANGED
@@ -22,4 +22,8 @@
22
22
 
23
23
  == Version 0.9.5
24
24
 
25
- * Bug fix.
25
+ * Bug fix.
26
+
27
+ == Version 0.9.6
28
+
29
+ * Expose script methods as thor tasks.
@@ -10,7 +10,7 @@ class GenericProvision
10
10
 
11
11
  attr_reader :interpolator, :env, :script_list, :server_info
12
12
 
13
- def initialize config_file_name, scripts_file_names
13
+ def initialize parent_class, config_file_name, scripts_file_names
14
14
  @interpolator = TextInterpolator.new
15
15
 
16
16
  @env = read_config(config_file_name)
@@ -23,9 +23,13 @@ class GenericProvision
23
23
 
24
24
  create_script_methods
25
25
 
26
+ create_thor_methods(parent_class) if parent_class.ancestors.include?(Thor)
27
+
26
28
  @server_info = env[:node] ? env[:node] : {}
27
29
  end
28
30
 
31
+ protected
32
+
29
33
  def create_script_methods
30
34
  script_list.keys.each do |name|
31
35
  singleton_class.send(:define_method, name.to_sym) do
@@ -34,7 +38,21 @@ class GenericProvision
34
38
  end
35
39
  end
36
40
 
37
- protected
41
+ def create_thor_methods parent_class
42
+ provision = self
43
+
44
+ provision.script_list.each do |name, value|
45
+ title = provision.script_title(value)
46
+
47
+ title = title.nil? ? name : title
48
+
49
+ parent_class.send(:desc, name, title) if parent_class.respond_to?(:desc)
50
+
51
+ parent_class.send(:define_method, name.to_sym) do
52
+ provision.send "#{name}".to_sym
53
+ end
54
+ end
55
+ end
38
56
 
39
57
  def read_config config_file_name
40
58
  hash = JSON.parse(File.read(config_file_name), :symbolize_names => true)
@@ -3,7 +3,7 @@ require 'osx_provision/generic_provision'
3
3
  class OsxProvision < GenericProvision
4
4
  USER_LOCAL_BIN = "/usr/local/bin"
5
5
 
6
- def initialize config_file_name=".osx_provision.json", scripts_file_names=[]
6
+ def initialize parent_class, config_file_name=".osx_provision.json", scripts_file_names=[]
7
7
  scripts_file_names.unshift(File.expand_path("osx_provision_scripts.sh", File.dirname(__FILE__))) # make it first
8
8
 
9
9
  super
@@ -1,3 +1,3 @@
1
1
  class OsxProvision
2
- VERSION = "0.9.5"
2
+ VERSION = "0.9.6"
3
3
  end
@@ -3,25 +3,12 @@ $: << File.expand_path(File.dirname(__FILE__) + '/../lib')
3
3
  require 'osx_provision/osx_provision'
4
4
 
5
5
  class OsxInstall < Thor
6
- def self.installer
7
- @@installer ||= OsxProvision.new ".osx_provision.json", [File.expand_path("project_scripts.sh", File.dirname(__FILE__))]
8
- end
9
-
10
- def self.create_thor_script_methods parent_class
11
- installer.script_list.each do |name, value|
12
- title = installer.script_title(value)
6
+ @installer = OsxProvision.new self, ".osx_provision.json", [File.expand_path("project_scripts.sh", File.dirname(__FILE__))]
13
7
 
14
- title = title.nil? ? name : title
15
-
16
- parent_class.send :desc, name, title
17
- parent_class.send(:define_method, name.to_sym) do
18
- self.class.installer.send "#{name}".to_sym
19
- end
20
- end
8
+ class << self
9
+ attr_reader :installer
21
10
  end
22
11
 
23
- create_thor_script_methods self
24
-
25
12
  desc "all", "Installs all required packages"
26
13
  def all
27
14
  invoke :brew
@@ -52,22 +39,22 @@ class OsxInstall < Thor
52
39
 
53
40
  desc "postgres_create_schemas", "Initializes postgres schemas"
54
41
  def postgres_create_schemas
55
- self.class.installer.postgres_create_schemas
42
+ OsxInstall.installer.postgres_create_schemas
56
43
  end
57
44
 
58
45
  desc "postgres_drop_schemas", "Drops postgres schemas"
59
46
  def postgres_drop_schemas
60
- self.class.installer.postgres_drop_schemas
47
+ OsxInstall.installer.postgres_drop_schemas
61
48
  end
62
49
 
63
50
  desc "mysql_create_schemas", "Initializes mysql schemas"
64
51
  def mysql_create_schemas
65
- self.class.installer.mysql_create_schemas
52
+ OsxInstall.installer.mysql_create_schemas
66
53
  end
67
54
 
68
55
  desc "mysql_drop_schemas", "Drops mysql schemas"
69
56
  def mysql_drop_schemas
70
- self.class.installer.mysql_drop_schemas
57
+ OsxInstall.mysql_drop_schemas
71
58
  end
72
59
 
73
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osx_provision
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Shvets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-24 00:00:00.000000000 Z
11
+ date: 2014-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: text-interpolator