reachable-under 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 993bf509e3159d4a6b38b6fde42b44771a963316
4
+ data.tar.gz: 9b6054bc7f38e8c039a436078525dbbb09ec161f
5
+ SHA512:
6
+ metadata.gz: ef38217aafadcc32ae47063351765cfd5dfce111ba41ff1b8b8dc3f966ef9b6dd87facd77e8148bcb7cbaac8f170e28e57ba31dc161c8c2b4237804aff998d8a
7
+ data.tar.gz: 326dca8d2dfa3a1102794a5312816384967bf0ec02487fd409189f646dadf462412fdeb841ae0e7ff0126b8bd1f6dec3ab6f72a9ff6027b92043599bd913e5ee
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ reachable-under
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.2.2
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in reachable-under.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Reachable::Under
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/reachable/under`. 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 'reachable-under'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install reachable-under
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 `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` to 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
+ 1. Fork it ( https://github.com/[my-github-username]/reachable-under/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "reachable/under"
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ require "reachable/under/version"
2
+ require "reachable/under/helper"
3
+
4
+ module Reachable
5
+ module Under
6
+ extend Helper
7
+ end
8
+ end
@@ -0,0 +1,41 @@
1
+ require "socket"
2
+
3
+ module Reachable
4
+ module Under
5
+ module Helper
6
+ class << self
7
+ private
8
+ def method_missing method, *args, &block
9
+ if frontend = method.to_s.scan(/^via_(.*)\?$/).flatten.first
10
+ frontend_klass ||= frontend.classify.constantize rescue nil
11
+ frontend_klass ||= frontend.gsub(/_/,"/").classify.constantize rescue nil
12
+ return not(frontend_klass.nil?)
13
+ end
14
+ super
15
+ end
16
+ end
17
+ # Credits: https://coderrr.wordpress.com/2008/05/28/get-your-local-ip-address/#comment-523
18
+ def default_address
19
+ @default_address ||= UDPSocket.open {|s| s.connect("64.233.187.99", 1); s.addr.last }
20
+ end
21
+ def reachable_address
22
+ return unless block_given?
23
+ yield.sub(/0\.0\.0\.0/,default_address)
24
+ end
25
+ def address
26
+ reachable_address do
27
+ address ||= Rails::Server.new.options[:Host] if Helper.via_rails_server?
28
+ address ||= ReverseProxy.instance.binds.first.tcp.host rescue nil if Helper.via_reverse_proxy?
29
+ address ||= URI(Puma.cli_config.options[:binds].select{|l| l =~ /^tcp:/ }.first).host rescue nil if Helper.via_puma?
30
+ address ||= "127.0.0.1"
31
+ end
32
+ end
33
+ def port
34
+ port ||= Rails::Server.new.options[:Port] if Helper.via_rails_server?
35
+ port ||= ReverseProxy.instance.binds.first.tcp.port rescue nil if Helper.via_reverse_proxy?
36
+ port ||= URI(Puma.cli_config.options[:binds].select{|l| l =~ /^tcp:/ }.first).port rescue nil if Helper.via_puma?
37
+ port ||= 3000
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,5 @@
1
+ module Reachable
2
+ module Under
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'reachable/under/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "reachable-under"
8
+ spec.version = Reachable::Under::VERSION
9
+ spec.authors = ["Mathias Kaufmann"]
10
+ spec.email = ["me@stei.gr"]
11
+
12
+ spec.summary = %q{Get frontend address and port of your web application.}
13
+ spec.description = %q{Get frontend address and port of your web application.}
14
+ spec.homepage = "https://rails.stei.gr/reachable"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.9"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: reachable-under
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mathias Kaufmann
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-04-25 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.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
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
+ description: Get frontend address and port of your web application.
42
+ email:
43
+ - me@stei.gr
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".ruby-gemset"
50
+ - ".ruby-version"
51
+ - ".travis.yml"
52
+ - Gemfile
53
+ - README.md
54
+ - Rakefile
55
+ - bin/console
56
+ - bin/setup
57
+ - lib/reachable/under.rb
58
+ - lib/reachable/under/helper.rb
59
+ - lib/reachable/under/version.rb
60
+ - reachable-under.gemspec
61
+ homepage: https://rails.stei.gr/reachable
62
+ licenses: []
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.4.6
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Get frontend address and port of your web application.
84
+ test_files: []