puman 0.1.1 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 971cb6d76dc593c0e5c2ee86670a340863c632b7
4
- data.tar.gz: cc9256b18f1dd845290b7d03564fa3b4fef2f6aa
2
+ SHA256:
3
+ metadata.gz: 5fb458fa1cb7c90b98c9edc679f13a9f3107562e9586056b868ad367ed46d1c4
4
+ data.tar.gz: adeed9435d312803c54b69d1f3f5d4d41f7389f4e4197cb77ae2c2f62bc1aa25
5
5
  SHA512:
6
- metadata.gz: 91a82d8ff43aad290b333a1bb420277618e852d146b09f495cbd5c1c83aa961e244536934876c4815b84d484e5bc386c0da0064f040cae4e7eab65cc5ee0503c
7
- data.tar.gz: 481011e38f64100d605b665edf34209b8fdb784f6a95e3f0f83472c18fc04caf450be0805af15336ac0cab42255e3027e9cde0dd291503839f82db1db762ca7f
6
+ metadata.gz: 54f564df2cdf84c78e271adcc309dc5a939801b0d6fa34ce547a51135f27e365c3985e4b691a41ccdd7799e26c8f04c7b75e150e3ca16e1741fa6b5aff2924e6
7
+ data.tar.gz: 5628e1e2c782d8d7d21425cf2f01018442cc36643aae384e32ec118ae0d8217dd8414d8337ddf8af8aaa8d0fc22302faa627e3d95dddb496c19144950e830de4
data/README.md CHANGED
@@ -1,41 +1,20 @@
1
1
  # Puman
2
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.
3
+ You can forget puma-dev proxy port numbers for your Rails apps!
4
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
5
+ `Puman` only supports macOS for now.
22
6
 
23
7
  ## Usage
24
8
 
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
-
9
+ ```
10
+ Commands:
11
+ puman help [COMMAND] # Describe available commands or one specific com...
12
+ puman list # list all apps linked with puma-dev
13
+ puman server # run rails server
14
+ puman symlink DIR # create symlink into puma-dev directory.
15
+ puman version # version
16
+ ```
37
17
 
38
18
  ## License
39
19
 
40
20
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
-
@@ -47,11 +47,17 @@ module Puman
47
47
  def server_command
48
48
  name = File.basename(git_dir_or_current_dir)
49
49
  apps = @proxy_apps.select{|app| app.name == name}
50
- if apps.size != 1
51
- puts 'no or multiple apps are defind.'
52
- else
53
- app = apps.first
54
- "bundle exec rails server -p #{app.host_port}" if app.host_port.match /^\d+$/
50
+ if apps.size == 1 && (app = apps.first).host_port.match(/^\d+$/)
51
+ "WEBPACKER_DEV_SERVER_PORT=#{devserver_port(app)} WEBPACKER_DEV_SERVER_PUBLIC=localhost:#{devserver_port(app)} bundle exec rails server -p #{app.host_port}"
52
+ end
53
+ end
54
+
55
+ def webpack_dev_server_command
56
+ name = File.basename(git_dir_or_current_dir)
57
+ apps = @proxy_apps.select{|app| app.name == name}
58
+ if apps.size == 1 && File.exists?(File.join(Dir.pwd, 'bin/webpack-dev-server'))
59
+ app = apps.first
60
+ "WEBPACKER_DEV_SERVER_PORT=#{devserver_port(app)} WEBPACKER_DEV_SERVER_PUBLIC=localhost:#{devserver_port(app)} ./bin/webpack-dev-server"
55
61
  end
56
62
  end
57
63
 
@@ -61,6 +67,10 @@ module Puman
61
67
 
62
68
  private
63
69
 
70
+ def devserver_port(app)
71
+ (app.host_port.to_i + 10000).to_s
72
+ end
73
+
64
74
  def root_directory?(path)
65
75
  File.directory?(path) && File.expand_path(path) == File.expand_path(File.join(path, '..'))
66
76
  end
@@ -23,21 +23,51 @@ module Puman
23
23
 
24
24
  desc "server", "run rails server"
25
25
  def server
26
- exec @app_list.server_command
26
+ server_command = @app_list.server_command
27
+ webpack_dev_server_command = @app_list.webpack_dev_server_command
28
+
29
+ if server_command.nil?
30
+ puts 'no or multiple apps are defind.'
31
+ exit 1
32
+ end
33
+
34
+ if webpack_dev_server_command
35
+ spawn webpack_dev_server_command
36
+ end
37
+ exec server_command
38
+ rescue
27
39
  end
28
40
 
29
- desc "symlink DIR_PATH", "create symlink into puma-dev directory."
41
+ desc "symlink DIR_PATH", "create symlink in puma-dev directory."
30
42
  def symlink(dir)
31
- file = File.expand_path(dir)
32
- return puts 'invalid argument.' unless File.exists?(file)
43
+ target_dir, basename = target_directory(dir)
44
+ if @app_list.include?(basename)
45
+ puts 'already exists.'
46
+ elnse
47
+ FileUtils::ln_s(target_dir, File.join(PUMA_DEV_DIR, basename))
48
+ puts 'symlink created.'
49
+ end
50
+ end
33
51
 
34
- link_name = File.basename(file)
35
- if @app_list.include?(link_name)
52
+ desc "proxy DIR_PATH", "create proxy file in puma-dev directory."
53
+ def proxy(dir)
54
+ target_dir = target_directory(dir)
55
+ if @app_list.include?(target_dir)
36
56
  puts 'already exists.'
37
57
  else
38
- FileUtils::ln_s(File.join(Dir.pwd, link_name), File.join(PUMA_DEV_DIR, link_name))
39
- puts 'symlink created.'
58
+ puts 'proxy option has not been implemented yet.'
59
+ end
60
+ end
61
+
62
+ private
63
+
64
+ def target_directory(arg_dir)
65
+ file = File.expand_path(arg_dir)
66
+ unless File.exists?(file)
67
+ puts 'invalid argument.'
68
+ exit 1
40
69
  end
70
+ [file, File.basename(file)]
41
71
  end
42
72
  end
43
73
  end
@@ -1,3 +1,3 @@
1
1
  module Puman
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.13"
23
+ spec.add_development_dependency "bundler", "~> 2.0.1"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  spec.add_development_dependency "rspec", "~> 3.0"
26
26
  spec.add_development_dependency "fakefs"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pi-chan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-10 00:00:00.000000000 Z
11
+ date: 2019-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.13'
19
+ version: 2.0.1
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.13'
26
+ version: 2.0.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  version: '0'
138
138
  requirements: []
139
139
  rubyforge_project:
140
- rubygems_version: 2.5.2
140
+ rubygems_version: 2.7.6.2
141
141
  signing_key:
142
142
  specification_version: 4
143
143
  summary: CLI utility for puma-dev.