scatter_deploy 0.1.1 → 0.1.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.
data/lib/scatter.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'scatter/cli'
2
2
 
3
3
  module Scatter
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
data/lib/scatter/cli.rb CHANGED
@@ -1,12 +1,16 @@
1
1
  require 'thor'
2
+ require 'scatter/config'
2
3
 
3
4
  module Scatter
4
5
  class CLI < Thor
5
6
 
7
+ desc "config SUBCOMMAND ...ARGS", "Set Scatter config."
8
+ subcommand 'config', Scatter::Config
9
+
6
10
  class_option :directory,
7
11
  :aliases => "-d",
8
12
  :type => :string,
9
- :default => "#{Dir.home}/.deploys",
13
+ :default => Config.new.read['directory'] || "#{Dir.home}/.deploys",
10
14
  :desc => "Specify a deploys directory."
11
15
 
12
16
  class_option :project,
@@ -41,6 +45,16 @@ module Scatter
41
45
  say Scatter::VERSION
42
46
  end
43
47
 
48
+ def method_missing(*args)
49
+ puts args
50
+ config = Config.new.read
51
+ alias_name = args.join ' '
52
+ super unless config['aliases'] and config['aliases'][alias_name]
53
+
54
+ # Execute the aliased command
55
+ system "scatter #{config['aliases'][alias_name]}"
56
+ end
57
+
44
58
  protected
45
59
  def git?
46
60
  `git rev-parse --is-inside-work-tree 2>/dev/null`.match "^true"
@@ -73,7 +87,7 @@ module Scatter
73
87
 
74
88
  def generate_command
75
89
  return "./#{options.shared} #{project_path}" if options.shared
76
- return "./deploy" if executable?
90
+ return "./deploy #{project_path}" if executable?
77
91
  return "cap deploy" if capfile?
78
92
  end
79
93
 
@@ -0,0 +1,53 @@
1
+ require 'thor'
2
+ require 'json'
3
+
4
+ module Scatter
5
+ class Config < Thor
6
+ CONFIG_FILE = "#{Dir.home}/.scatterconfig"
7
+
8
+ desc "alias FROM TO", "Alias a scatter command."
9
+ def alias(from, to)
10
+ say "Aliasing `scatter #{from}` to `scatter #{to}`"
11
+
12
+ settings = read
13
+ settings["aliases"] ||= {}
14
+ settings["aliases"][from] = to
15
+ save settings
16
+ end
17
+
18
+ desc "deploys PATH", "Set a default deploys directory."
19
+ def deploys(path)
20
+ path = File.expand_path path
21
+ say "Setting default deploys directory to #{path}"
22
+ settings = read
23
+ settings['directory'] = path
24
+ save settings
25
+ end
26
+
27
+ no_tasks do
28
+ def read
29
+ setup
30
+ return {} unless @settings.length > 0
31
+
32
+ begin
33
+ JSON.load @settings
34
+ rescue
35
+ {}
36
+ end
37
+ end
38
+ end
39
+
40
+ protected
41
+ def setup
42
+ File.open CONFIG_FILE, "w+" unless File.exists? CONFIG_FILE
43
+ @settings = IO.read CONFIG_FILE
44
+ end
45
+
46
+ def save(settings)
47
+ setup
48
+ File.open(CONFIG_FILE, "w+") do |f|
49
+ f.write JSON.pretty_generate(settings)
50
+ end
51
+ end
52
+ end
53
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scatter_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -55,6 +55,7 @@ files:
55
55
  - MIT-LICENSE
56
56
  - bin/scatter
57
57
  - lib/scatter/cli.rb
58
+ - lib/scatter/config.rb
58
59
  - lib/scatter.rb
59
60
  homepage: http://evansolomon.me/
60
61
  licenses:
@@ -69,6 +70,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
70
  - - ! '>='
70
71
  - !ruby/object:Gem::Version
71
72
  version: '0'
73
+ segments:
74
+ - 0
75
+ hash: 1442892228402604722
72
76
  required_rubygems_version: !ruby/object:Gem::Requirement
73
77
  none: false
74
78
  requirements: