sumodev 0.1.9 → 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6a2594f6056cd2a4982f612ba66b069b3219ebf2
4
+ data.tar.gz: 12fd73496885b8e92f763d78587f6ee988ad70b2
5
+ SHA512:
6
+ metadata.gz: ff23e9767c2e04db2583f5cca992b3255393931e63655a6acce209593ff4ea47bbf91ba8b7de6f4031e8bddc0bdae7df4721038dcf350851188e5b7cc3586ed6
7
+ data.tar.gz: 0fda1ac15fcf7a7280d98e4cd0cc2d9e324f8fdaac4b957ed23f259d3fe95aa7fccd17b9b5f700053b606ccbdf082cad4ac21f32ed40182a7f6339f8046f0abc
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
- source :rubygems
1
+ source 'http://rubygems.org'
2
2
 
3
3
  gem 'thor'
4
4
  gem 'activesupport'
5
+ gem 'net-ssh'
6
+ gem 'net-scp'
@@ -6,11 +6,16 @@ GEM
6
6
  multi_json (~> 1.0)
7
7
  i18n (0.6.0)
8
8
  multi_json (1.3.6)
9
- thor (0.15.4)
9
+ net-scp (1.1.2)
10
+ net-ssh (>= 2.6.5)
11
+ net-ssh (2.6.8)
12
+ thor (0.18.1)
10
13
 
11
14
  PLATFORMS
12
15
  ruby
13
16
 
14
17
  DEPENDENCIES
15
18
  activesupport
19
+ net-scp
20
+ net-ssh
16
21
  thor
@@ -8,6 +8,7 @@ class Sumodev < Thor
8
8
  autoload :Factr, 'sumodev/commands/factr'
9
9
  autoload :Push, 'sumodev/commands/push'
10
10
  autoload :Project, 'sumodev/commands/project'
11
+ autoload :Box, 'sumodev/commands/box'
11
12
  end
12
13
 
13
14
  register Commands::Fork, 'fork', 'fork <command>', 'All commands concerning Fork applications'
@@ -15,5 +16,6 @@ class Sumodev < Thor
15
16
  register Commands::Factr, 'factr', 'factr <command>', 'All commands concerning Factr'
16
17
  register Commands::Push, 'push', 'push <server>', 'Push the SSH keys to the server'
17
18
  register Commands::Project, 'project', 'project <command>', 'All commands concerning projects'
19
+ register Commands::Box, 'box', 'box <command>', 'All commands concerning our Vagrant install'
18
20
  end
19
21
 
@@ -0,0 +1,72 @@
1
+ require 'sumodev/command'
2
+ require 'sumodev/config'
3
+ require 'sumodev/sumofile'
4
+
5
+ class Sumodev::Commands::Box < Sumodev::Command
6
+ namespace :box
7
+
8
+ no_commands do
9
+ def box_path
10
+ possible_paths = [
11
+ Dir.pwd,
12
+ Sumodev::Config.get('SUMO_VAGRANT_PATH')
13
+ ]
14
+
15
+ vagrantfile = possible_paths.detect do |path|
16
+ File.file?(File.join(File.expand_path(path), "Vagrantfile"))
17
+ end || raise("No Vagrant file found in #{possible_paths.join(', ')}")
18
+
19
+ File.expand_path(vagrantfile)
20
+ end
21
+
22
+ def run_vagrant_command(command)
23
+ system "cd #{box_path}; vagrant #{command}"
24
+ end
25
+
26
+ def box_running?
27
+ output = `cd #{box_path}; vagrant status`
28
+ output =~ /The VM is running/
29
+ end
30
+
31
+ def configure_port_mapping
32
+ ipfw_lines = `sudo ipfw list`
33
+
34
+ {
35
+ 8080 => 80,
36
+ 8443 => 443
37
+ }.each do |src, dst|
38
+ if !ipfw_lines.include?("fwd 127.0.0.1,#{src} tcp from any to me dst-port #{dst}")
39
+ system "sudo ipfw add 80 fwd 127.0.0.1,#{src} tcp from any to me #{dst}"
40
+ end
41
+ end
42
+ end
43
+
44
+ def convert_sumofile_into_env_variables
45
+ sumofile_path = Dir.pwd + "/Sumofile"
46
+
47
+ file = Sumodev::Sumofile.from_file sumofile_path
48
+ file.convert_into_sourceable_file
49
+ file.convert_into_json_file
50
+ end
51
+ end
52
+
53
+ desc 'up', "Starts the Vagrant-box"
54
+ def up
55
+ say("There is already a box running, you should manually start the box. Or halt the running instance", :red) && exit(1) if box_running?
56
+
57
+ convert_sumofile_into_env_variables
58
+ configure_port_mapping
59
+ run_vagrant_command("up")
60
+ rescue Sumodev::Sumofile::NoSuchFileError
61
+ say("No Sumofile found! Please define one so the correct versions will be used!", :red) && exit(1)
62
+ end
63
+
64
+ desc 'your_command', "Runs your command on the correct box"
65
+ def your_command(*args)
66
+ say "Use sumo box <command> you bloody idiot, eg: sumo box ssh"
67
+ end
68
+
69
+ def method_missing(*args)
70
+ run_vagrant_command(args.join(" "))
71
+ end
72
+ end
@@ -5,15 +5,19 @@ class Sumodev::Config
5
5
 
6
6
  attr_accessor :variables
7
7
 
8
+ Defaults = {
9
+ 'SUMO_TEMP_PATH' => "/tmp/",
10
+ }
11
+
8
12
  def initialize
9
13
  sumofile_path = File.expand_path("~/.sumorc")
10
14
 
11
15
  if File.file?(sumofile_path)
12
- @variables = File.readlines(sumofile_path).inject({}) do |env,line|
13
- line = line.strip.gsub('export', '')
14
- name, value = line.split("=", 2)
15
- env.merge name.strip => value.strip.tr("'\"", '')
16
- end
16
+ @variables = File.readlines(sumofile_path).inject({}) do |env, line|
17
+ line = line.strip.gsub('export', '')
18
+ name, value = line.split("=", 2)
19
+ env.merge name.strip => value.strip.tr("'\"", '')
20
+ end
17
21
  else
18
22
  raise("No .sumorc-file found in ~/.sumorc")
19
23
  end
@@ -24,6 +28,6 @@ class Sumodev::Config
24
28
  end
25
29
 
26
30
  def get(name)
27
- @variables[name]
31
+ @variables[name] || Defaults[name] || raise("Can't find setting for #{name} in ~/.sumorc")
28
32
  end
29
33
  end
@@ -0,0 +1,68 @@
1
+ require 'multi_json'
2
+
3
+ class Sumodev::Sumofile
4
+ attr_accessor :variables
5
+
6
+ class << self
7
+ def from_file(path)
8
+ new do |sumofile|
9
+ File.readlines(path).each do |line|
10
+ _, name, value = line.match(/^(.+?)\s+['"]?(.+?)['"]?$/).to_a
11
+ sumofile[name] = value
12
+ end
13
+ end
14
+ rescue Errno::ENOENT
15
+ raise NoSuchFileError
16
+ end
17
+
18
+ def current_config
19
+ data = File.read("#{temp_path}/sumofile.json")
20
+ json = MultiJson.load data
21
+
22
+ new do |sumofile|
23
+ sumofile.variables = json['sumofile']
24
+ end
25
+ rescue Errno::ENOENT
26
+ raise NoSuchFileError
27
+ end
28
+
29
+ def temp_path
30
+ File.expand_path(Sumodev::Config.get('SUMO_TEMP_PATH'));
31
+ end
32
+ end
33
+
34
+ def initialize
35
+ @variables = {}
36
+
37
+ yield self if block_given?
38
+ end
39
+
40
+ def convert_into_sourceable_file
41
+ File.open("#{self.class.temp_path}/env_vars.tmp", "w") do |file|
42
+ @variables.each do |key, value|
43
+ file.write "export SUMOFILE_#{key.upcase}='#{value}'\n"
44
+ end
45
+ end
46
+ end
47
+
48
+ def convert_into_json_file
49
+ File.open("#{self.class.temp_path}/sumofile.json", "w") do |file|
50
+ file.write to_json
51
+ end
52
+ end
53
+
54
+ def get(name)
55
+ @variables[name]
56
+ end
57
+ alias :[] :get
58
+
59
+ def []=(name, value)
60
+ @variables[name] = value
61
+ end
62
+
63
+ def to_json
64
+ MultiJson.dump({'sumofile' => @variables})
65
+ end
66
+
67
+ class NoSuchFileError < StandardError; end
68
+ end
@@ -1,3 +1,3 @@
1
1
  module Sumodev
2
- VERSION = "0.1.9"
2
+ VERSION = "0.2"
3
3
  end
metadata CHANGED
@@ -1,78 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sumodev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
5
- prerelease:
4
+ version: '0.2'
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jan De Poorter
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-12-09 00:00:00.000000000 Z
11
+ date: 2013-12-31 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activesupport
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: thor
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: net-ssh
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: net-scp
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  description: A command line tool to access all things you want
@@ -85,6 +76,7 @@ files:
85
76
  - lib/sumodev/actions.rb
86
77
  - lib/sumodev/application.rb
87
78
  - lib/sumodev/command.rb
79
+ - lib/sumodev/commands/box.rb
88
80
  - lib/sumodev/commands/factr.rb
89
81
  - lib/sumodev/commands/fork.rb
90
82
  - lib/sumodev/commands/project.rb
@@ -95,6 +87,7 @@ files:
95
87
  - lib/sumodev/generators/fork/v3.rb
96
88
  - lib/sumodev/generators/general/capistrano.rb
97
89
  - lib/sumodev/generators/general/templates/Capfile
90
+ - lib/sumodev/sumofile.rb
98
91
  - lib/sumodev/version.rb
99
92
  - lib/sumodev.rb
100
93
  - bin/sumo
@@ -102,26 +95,25 @@ files:
102
95
  - Gemfile.lock
103
96
  homepage:
104
97
  licenses: []
98
+ metadata: {}
105
99
  post_install_message:
106
100
  rdoc_options: []
107
101
  require_paths:
108
102
  - lib
109
103
  required_ruby_version: !ruby/object:Gem::Requirement
110
- none: false
111
104
  requirements:
112
- - - ! '>='
105
+ - - '>='
113
106
  - !ruby/object:Gem::Version
114
107
  version: '0'
115
108
  required_rubygems_version: !ruby/object:Gem::Requirement
116
- none: false
117
109
  requirements:
118
- - - ! '>='
110
+ - - '>='
119
111
  - !ruby/object:Gem::Version
120
112
  version: '0'
121
113
  requirements: []
122
114
  rubyforge_project:
123
- rubygems_version: 1.8.23
115
+ rubygems_version: 2.0.14
124
116
  signing_key:
125
- specification_version: 3
117
+ specification_version: 4
126
118
  summary: SumoCoders Developers gem
127
119
  test_files: []