puman 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/puman +5 -0
- data/lib/puman.rb +2 -0
- data/lib/puman/cli.rb +86 -0
- data/lib/puman/version.rb +3 -0
- data/puman.gemspec +28 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 372d5d603fe45e6cacc8de0b833e488d3e390c55
|
4
|
+
data.tar.gz: 4997b7fab1986fa223e8cf9d433e1ffbfac34799
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b461545bcb64f83571964527bce78e0c6c67659ec1be5138ee4f330d0456961ecbd1ccb6944613558c0e4d594c251d4a51bf98913f57e6144e8383d37490361d
|
7
|
+
data.tar.gz: 9b18c34c21095ec575a9e29efa86377289f93cf4b74e8efdc59ff7ac85e964ca64513ac6ff613200e7ad85ea3720c70788d59a5d65942e052e34fceaac481dd4
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 pi-chan
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Puman
|
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/puman`. 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 'puman'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install puman
|
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/[USERNAME]/puman.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "puman"
|
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
|
data/bin/setup
ADDED
data/exe/puman
ADDED
data/lib/puman.rb
ADDED
data/lib/puman/cli.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module Puman
|
4
|
+
App = Struct.new(:name, :host_port)
|
5
|
+
|
6
|
+
class CLI < Thor
|
7
|
+
default_command :server
|
8
|
+
|
9
|
+
def initialize(args, opts, config)
|
10
|
+
super
|
11
|
+
correct_apps
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "list", "list all apps linked with puma-dev"
|
15
|
+
def list
|
16
|
+
puts "-- symlink apps --"
|
17
|
+
@symlink_apps.sort_by(&:name).each do |app|
|
18
|
+
puts app.name
|
19
|
+
end
|
20
|
+
|
21
|
+
puts
|
22
|
+
puts "-- proxy apps --"
|
23
|
+
@proxy_apps.sort_by(&:host_port).each do |app|
|
24
|
+
puts "#{app.host_port.strip.rjust(@proxy_max_length)} => #{app.name}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "server", "run rails server"
|
29
|
+
def server
|
30
|
+
name = File.basename(git_dir_or_current_dir)
|
31
|
+
apps = @proxy_apps.select{|app| app.name == name}
|
32
|
+
if apps.size != 1
|
33
|
+
puts 'no or multiple apps are defind.'
|
34
|
+
else
|
35
|
+
app = apps.first
|
36
|
+
exec "bundle exec rails server -p #{app.host_port}" if app.host_port.match /^\d+$/
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
desc 'version', 'version'
|
41
|
+
def version
|
42
|
+
puts Puman::VERSION
|
43
|
+
end
|
44
|
+
|
45
|
+
# TODO
|
46
|
+
# desc "proxify", "make a text file with new host and port"
|
47
|
+
# def proxify
|
48
|
+
# puts 'hello'
|
49
|
+
# end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def correct_apps
|
54
|
+
return if !@proxy_apps.nil? && !@symlink_apps.nil?
|
55
|
+
@proxy_apps = []
|
56
|
+
@symlink_apps = []
|
57
|
+
Dir.chdir File.join(Dir.home, '.puma-dev') do
|
58
|
+
Dir.glob('*').each do |file|
|
59
|
+
if File.symlink?(file)
|
60
|
+
@symlink_apps.push App.new(file, nil)
|
61
|
+
else
|
62
|
+
host_port = File.read(file)
|
63
|
+
@proxy_apps.push App.new(file, host_port)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
@proxy_max_length = @proxy_apps.map {|app| app.host_port.strip.size}.max
|
68
|
+
end
|
69
|
+
|
70
|
+
def root_directory?(path)
|
71
|
+
File.directory?(path) && File.expand_path(path) == File.expand_path(File.join(path, '..'))
|
72
|
+
end
|
73
|
+
|
74
|
+
def git_dir_or_current_dir
|
75
|
+
current_path = Dir.pwd
|
76
|
+
until root_directory?(current_path)
|
77
|
+
if File.exist?(File.join(current_path, '.git'))
|
78
|
+
return current_path
|
79
|
+
else
|
80
|
+
current_path = File.dirname(current_path)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
Dir.pwd
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/puman.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 'puman/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "puman"
|
8
|
+
spec.version = Puman::VERSION
|
9
|
+
spec.authors = ["pi-chan"]
|
10
|
+
spec.email = ["xoyip@piyox.info"]
|
11
|
+
|
12
|
+
spec.summary = "CLI utility for puma-dev."
|
13
|
+
spec.homepage = "https://github.com/pi-chan/puman"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
spec.add_development_dependency "pry-byebug"
|
27
|
+
spec.add_dependency "thor"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: puman
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- pi-chan
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: thor
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- xoyip@piyox.info
|
86
|
+
executables:
|
87
|
+
- puman
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".travis.yml"
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/console
|
99
|
+
- bin/setup
|
100
|
+
- exe/puman
|
101
|
+
- lib/puman.rb
|
102
|
+
- lib/puman/cli.rb
|
103
|
+
- lib/puman/version.rb
|
104
|
+
- puman.gemspec
|
105
|
+
homepage: https://github.com/pi-chan/puman
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.5.2
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: CLI utility for puma-dev.
|
129
|
+
test_files: []
|