muxify 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0d599b510ae581c38e72a7f2da162ca6bcdbc8fb
4
+ data.tar.gz: c4a72a6befbf25cca43088f162d90108442b64a3
5
+ SHA512:
6
+ metadata.gz: 98f3cb24ba032e77b59e74cfa6902be4d26577d4dde99bb2ab483d72eefff00335932e47ef596121533f43839c2496891fd28254a72608f6974013542bbc844a
7
+ data.tar.gz: c544e2c7e79c666d01406eb6894f96a6d309fea0f42cbb0df1569e6318c5c3f59f264a4fc11a3a45c061440adfa8a17692c73706ddc4bb7610cd4dd719f444ce
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.15.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in muxify.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Muxify
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/muxify`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'muxify'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install muxify
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/zubin/muxify.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "muxify"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/muxify ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "muxify"
5
+
6
+ Muxify::CLI.start(ARGV)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,109 @@
1
+ require "yaml"
2
+
3
+ module Muxify
4
+ class Builder
5
+ def self.call(*args)
6
+ new(*args).to_yaml
7
+ end
8
+
9
+ def initialize(root:, name: nil)
10
+ @root = File.expand_path(root)
11
+ @name = name || File.basename(@root)
12
+ end
13
+
14
+ def to_yaml
15
+ config.to_yaml
16
+ end
17
+
18
+ private
19
+
20
+ attr_reader :root, :name
21
+
22
+ def config
23
+ {
24
+ 'name' => name,
25
+ 'root' => root,
26
+ 'windows' => windows,
27
+ }
28
+ end
29
+
30
+ def windows
31
+ Windows.new(root).all
32
+ end
33
+
34
+ class Windows
35
+ def initialize(root)
36
+ @root = root
37
+ end
38
+
39
+ def all
40
+ [
41
+ *shell,
42
+ *editor,
43
+ *logs,
44
+ *foreman,
45
+ *rails,
46
+ *django,
47
+ ]
48
+ end
49
+
50
+ private
51
+
52
+ attr_reader :root
53
+
54
+ def shell
55
+ [{shell: ('git fetch; git status' if git?)}]
56
+ end
57
+
58
+ def git?
59
+ File.exists?(File.join(root, '.git'))
60
+ end
61
+
62
+ def editor
63
+ [{editor: ENV.fetch('EDITOR', 'vim')}]
64
+ end
65
+
66
+ def logs
67
+ return [] if Dir["#{root}/log/*.log"].empty?
68
+ [{logs: 'tail -f log/*.log'}]
69
+ end
70
+
71
+ def foreman
72
+ return [] unless foreman?
73
+ [{foreman: <<-SH.strip}]
74
+ ps aux | grep 'unicorn_rails master' | awk '{print $2}' | xargs kill; foreman start
75
+ SH
76
+ end
77
+
78
+ def foreman?
79
+ # TODO?
80
+ end
81
+
82
+ def rails
83
+ return [] unless rails?
84
+ [
85
+ {db: 'rails db'},
86
+ {console: 'rails console'},
87
+ ]
88
+ end
89
+
90
+ def rails?
91
+ File.exists?(File.join(root, 'bin/rails'))
92
+ end
93
+
94
+ def django
95
+ return [] unless django?
96
+ [
97
+ {db: 'python manage.py dbshell'},
98
+ {console: 'python manage.py shell'},
99
+ {server: 'python manage.py runserver'},
100
+ ]
101
+ end
102
+
103
+ def django?
104
+ python_requirements = File.join(root, 'requirements.txt')
105
+ File.exists?(python_requirements) && File.read(python_requirements).include?('django')
106
+ end
107
+ end
108
+ end
109
+ end
data/lib/muxify/cli.rb ADDED
@@ -0,0 +1,17 @@
1
+ require "thor"
2
+ require "muxify/builder"
3
+ require "muxify/linker"
4
+
5
+ module Muxify
6
+ class CLI < Thor
7
+ desc "add", "Adds tmuxinator config for current path"
8
+ def add
9
+ Muxify::Linker.(root: Dir.pwd)
10
+ end
11
+
12
+ desc "debug", "Prints tmuxinator config of current path to stdout"
13
+ def debug
14
+ puts Muxify::Builder.(root: Dir.pwd)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,39 @@
1
+ require "fileutils"
2
+
3
+ module Muxify
4
+ class Linker
5
+ TMUXINATOR_CONFIG_PATH = File.expand_path(File.join(ENV.fetch('HOME'), '.tmuxinator')).freeze
6
+ private_constant :TMUXINATOR_CONFIG_PATH
7
+
8
+ def self.call(*args)
9
+ new(*args).call
10
+ end
11
+
12
+ def initialize(root:)
13
+ @root = File.expand_path(root)
14
+ end
15
+
16
+ def call
17
+ FileUtils.mkdir_p(TMUXINATOR_CONFIG_PATH)
18
+ File.open(config_path, 'w') { |f| f << contents }
19
+ end
20
+
21
+ private
22
+
23
+ attr_reader :root
24
+
25
+ def config_path
26
+ File.join(TMUXINATOR_CONFIG_PATH, "#{name}.yml")
27
+ end
28
+
29
+ def name
30
+ File.basename(root)
31
+ end
32
+
33
+ def contents
34
+ <<-ERB.strip
35
+ <% require 'muxify' %><%= Muxify::Builder.('#{root}') %>
36
+ ERB
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,3 @@
1
+ module Muxify
2
+ VERSION = "0.1.0"
3
+ end
data/lib/muxify.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "muxify/cli"
2
+ require "muxify/version"
data/muxify.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "muxify/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "muxify"
8
+ spec.version = Muxify::VERSION
9
+ spec.authors = ["Zubin Henner"]
10
+ spec.email = ["zubin@users.noreply.github.com"]
11
+
12
+ spec.summary = %q{Simple tmux project config}
13
+ spec.homepage = "https://github.com/zubin/muxify"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "thor"
23
+ spec.add_dependency "tmuxinator"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.15"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: muxify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Zubin Henner
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-06-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: tmuxinator
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.15'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.15'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description:
84
+ email:
85
+ - zubin@users.noreply.github.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - README.md
95
+ - Rakefile
96
+ - bin/console
97
+ - bin/muxify
98
+ - bin/setup
99
+ - lib/muxify.rb
100
+ - lib/muxify/builder.rb
101
+ - lib/muxify/cli.rb
102
+ - lib/muxify/linker.rb
103
+ - lib/muxify/version.rb
104
+ - muxify.gemspec
105
+ homepage: https://github.com/zubin/muxify
106
+ licenses: []
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.6.11
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Simple tmux project config
128
+ test_files: []