apptap 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ old/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+
20
+ .brew
21
+ config
22
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in apptap.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Jason Wadsworth
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ # AppTap
2
+
3
+ AppTap manages service dependencies for your applications. It uses an app-local installation of homebrew to install services, and foreman to manage service processes.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'apptap'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install apptap
18
+
19
+ ## Usage
20
+
21
+ $ apptap init
22
+ $ vi config/apptap.yml
23
+ $ apptap install
24
+ $ apptap foreman start
25
+
26
+ ## Brew Warning
27
+
28
+ You'll see a message like this when you install packages from homebrew:
29
+
30
+ Warning: /Users/jason/Code/subakva/apptap/tmp/example/.brew/bin is not in your PATH
31
+
32
+ Don't worry about it! AppTap takes care of using the correct path when it builds the Procfile.
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/apptap/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Jason Wadsworth"]
6
+ gem.email = ["jdwadsworth@gmail.com"]
7
+ gem.description = %q{AppTap makes it easy to manage service dependencies for your apps. It uses an app-local installation of homebrew to install services, and foreman to manage service processes.}
8
+ gem.summary = %q{Simplifies management of service dependencies for development. }
9
+ gem.homepage = "https://github.com/subakva/apptap"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "apptap"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = AppTap::VERSION
17
+
18
+ gem.add_dependency("thor")
19
+ gem.add_dependency("foreman")
20
+
21
+ # gem.add_development_dependency("rake", ['~> 0.9.2'])
22
+ # gem.add_development_dependency("rspec", ['~> 2.9.0'])
23
+ # gem.add_development_dependency("simplecov", ['~> 0.6.2'])
24
+ # gem.add_development_dependency("cane", ['~> 1.3.0'])
25
+ # gem.add_development_dependency("yard", ['~> 0.7.5'])
26
+ # gem.add_development_dependency("yard-tomdoc", ['~> 0.4.0'])
27
+ # gem.add_development_dependency("redcarpet", ['~> 2.1.1'])
28
+ # gem.add_development_dependency("ruby-debug19", ['~> 0.11.6'])
29
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ require "rubygems"
3
+ require "thor"
4
+
5
+ if File.exists?(File.join(File.expand_path('../..', __FILE__), '.git'))
6
+ apptap_path = File.expand_path('../../lib', __FILE__)
7
+ $:.unshift(apptap_path)
8
+ end
9
+
10
+ require "apptap"
11
+ AppTap::CLI::Root.start
@@ -0,0 +1,20 @@
1
+ require "apptap/version"
2
+ require 'thor'
3
+ require 'thor/group'
4
+
5
+ require 'apptap/cli/helpers'
6
+ require 'apptap/cli/init'
7
+ require 'apptap/cli/install'
8
+ require 'apptap/cli/foreman'
9
+
10
+ module AppTap
11
+ module CLI
12
+ class Root < Thor
13
+ include Thor::Actions
14
+
15
+ register AppTap::CLI::Init, 'init', 'init', 'Creates a sample apptap configuration file.'
16
+ register AppTap::CLI::Install, 'install', 'install [SERVICE_NAME]', 'Installs SERVICE_NAME. If SERVICE_NAME is empty, installs all configured services.'
17
+ register AppTap::CLI::Foreman, 'foreman', 'foreman [COMMAND]', 'Executes a foreman command.'
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ module AppTap
2
+ module CLI
3
+ class Foreman < Thor
4
+ include Thor::Actions
5
+ include AppTap::CLI::Helpers
6
+
7
+ # argument :command,
8
+ # desc: 'The name of the foreman command to execute.',
9
+ # required: false,
10
+ # type: :string
11
+
12
+ desc 'start', 'Starts the foreman process'
13
+ def start
14
+ run "foreman start -f #{app_procfile_path}"
15
+ # Process.exec "foreman -f #{app_procfile_path}"
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,66 @@
1
+ require 'yaml'
2
+
3
+ module AppTap
4
+ module CLI
5
+ module Helpers
6
+ def brew_dir
7
+ '.brew'
8
+ end
9
+
10
+ def brew_repo_url
11
+ 'https://github.com/mxcl/homebrew.git'
12
+ end
13
+
14
+ def app_procfile_path
15
+ 'Procfile.dev'
16
+ end
17
+
18
+ def procfile_config_start_token
19
+ '## START: AppTap Processes'
20
+ end
21
+
22
+ def procfile_config_end_token
23
+ '## END: AppTap Processes'
24
+ end
25
+
26
+ def app_config_path
27
+ File.join('config', 'apptap.yml')
28
+ end
29
+
30
+ def brew_install_path
31
+ File.join(destination_root, brew_dir)
32
+ end
33
+
34
+ def brew_bin
35
+ File.join(brew_install_path, 'bin')
36
+ end
37
+
38
+ def brew_command
39
+ File.join(brew_bin, 'brew')
40
+ end
41
+
42
+ def load_config
43
+ YAML.load_file(File.join(destination_root, app_config_path))
44
+ end
45
+
46
+ def filter_config(service_name, config = nil, &block)
47
+ config ||= self.load_config
48
+ filtered_config = config
49
+ if service_name && service_name.length > 0
50
+ unless config.keys.include?(service_name)
51
+ say_status 'error', "Unable to find a service called '#{service_name}'!", :red
52
+ end
53
+ filtered_config = config.select { |config_name| config_name == service_name }
54
+ end
55
+
56
+ if block_given?
57
+ filtered_config.each do |name, service_config|
58
+ yield(name, service_config)
59
+ end
60
+ end
61
+
62
+ filtered_config
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,26 @@
1
+ module AppTap
2
+ module CLI
3
+ class Init < Thor::Group
4
+ include Thor::Actions
5
+ include AppTap::CLI::Helpers
6
+
7
+ def self.source_root
8
+ File.expand_path(File.join(File.dirname(__FILE__), '../../..'))
9
+ end
10
+
11
+ def create_sample_config
12
+ empty_directory(File.dirname(app_config_path))
13
+ template('templates/config/apptap.yml.erb', app_config_path)
14
+ template('templates/Procfile.dev.erb', app_procfile_path)
15
+ end
16
+
17
+ def install_homebrew
18
+ if File.exists?(brew_install_path)
19
+ say_status 'installed', 'Homebrew', :blue
20
+ else
21
+ run("git clone #{brew_repo_url} #{brew_install_path}")
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,50 @@
1
+ module AppTap
2
+ module CLI
3
+ class Install < Thor::Group
4
+ include Thor::Actions
5
+ include AppTap::CLI::Helpers
6
+
7
+ argument :service_name,
8
+ desc: 'The name of the service to install.',
9
+ required: false,
10
+ type: :string
11
+
12
+ def install_services
13
+ say "Installing services..."
14
+
15
+ filter_config(service_name) do |config_name, service_config|
16
+ say_status 'installing', config_name, :green
17
+ if service_config['formula']
18
+ run("#{brew_bin} install #{service_config['formula']}")
19
+ else
20
+ say_status 'error', "Missing 'formula' configuration for #{config_name}.", :red
21
+ end
22
+ end
23
+ end
24
+
25
+ def reset_procfile
26
+ say_status 'resetting', app_procfile_path, :green
27
+
28
+ apptap_section_regexp = Regexp.new("#{procfile_config_start_token}(.*)#{procfile_config_end_token}", Regexp::MULTILINE)
29
+ gsub_file app_procfile_path, apptap_section_regexp do |match|
30
+ "#{procfile_config_start_token}\n#{procfile_config_end_token}"
31
+ end
32
+ end
33
+
34
+ def generate_procfile
35
+ say_status 'updating', app_procfile_path, :green
36
+
37
+ filter_config(service_name) do |config_name, service_config|
38
+ say_status 'adding', config_name, :green
39
+
40
+ insert_into_file(app_procfile_path, after: "#{procfile_config_start_token}\n") do
41
+ command = service_config['command']
42
+ process_name = config_name
43
+
44
+ "#{process_name}: #{File.join(brew_bin, command)}\n"
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,3 @@
1
+ module AppTap
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,2 @@
1
+ <%= procfile_config_start_token %>
2
+ <%= procfile_config_end_token %>
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: apptap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jason Wadsworth
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: foreman
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: AppTap makes it easy to manage service dependencies for your apps. It
47
+ uses an app-local installation of homebrew to install services, and foreman to manage
48
+ service processes.
49
+ email:
50
+ - jdwadsworth@gmail.com
51
+ executables:
52
+ - apptap
53
+ extensions: []
54
+ extra_rdoc_files: []
55
+ files:
56
+ - .gitignore
57
+ - Gemfile
58
+ - LICENSE
59
+ - README.md
60
+ - Rakefile
61
+ - apptap.gemspec
62
+ - bin/apptap
63
+ - lib/apptap.rb
64
+ - lib/apptap/cli/foreman.rb
65
+ - lib/apptap/cli/helpers.rb
66
+ - lib/apptap/cli/init.rb
67
+ - lib/apptap/cli/install.rb
68
+ - lib/apptap/version.rb
69
+ - templates/Procfile.dev.erb
70
+ - templates/config/apptap.yml.erb
71
+ homepage: https://github.com/subakva/apptap
72
+ licenses: []
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 1.8.23
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: Simplifies management of service dependencies for development.
95
+ test_files: []
96
+ has_rdoc: