gemirro 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of gemirro might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05740f277401bf065e00737b3e72426d3a6e5d0c
4
- data.tar.gz: 3d96044ff953bc7b4885ab660b95078d32bb150b
3
+ metadata.gz: 2d800c2fcc4025d9b6c61b262de67bd7fabaa16b
4
+ data.tar.gz: 83b03d07f993704b6a944435cc0736f15cb691d1
5
5
  SHA512:
6
- metadata.gz: a16eb40a5e9ff30b6d33ecbead16a648af41b6deeedb43e0ad2ba4ee8bfc23d196697c02140c8c444bbc9f6cbf6f79833db533b22dc233d0d11341aa8241279b
7
- data.tar.gz: 488decb43c8194a8becde330e5427a19313ad3a680c26f77a7db33b1423b2c4c2c12d6862d2d8755f44d459618b01c10a62d3eabbcd0e269a8a95b69a476ac6f
6
+ metadata.gz: cc903688bd26f284ecba57a374c2bbd21121fdb0c27b2a358780b5bb6126177428416277052049e7babb987bf2737e984a99d5ea91f1775da21346a3253c54b4
7
+ data.tar.gz: c4cfc5462bc6739b1857a5ff411dad6922fe69e8caeeff2605123bfea093377318d0afc6e0038ed93a52a4f6b271e5db8bcb55affbf6b8fdd054339e4b5ef534
data/README.md CHANGED
@@ -54,7 +54,44 @@ If you want to use a custom configuration file not located in the current direct
54
54
 
55
55
 
56
56
  ##Apache configuration
57
- TODO
57
+
58
+ You must active the apache `proxy` module.
59
+
60
+ ```bash
61
+ $ sudo a2enmod proxy
62
+ $ sudo a2enmod proxy_http
63
+ ```
64
+
65
+ Create your VirtualHost and replace following `http://localhost:2000` with your custom server configuration located in your `config.rb` file and restart Apache.
66
+
67
+ ```
68
+ <VirtualHost *:80>
69
+ ServerName mirror.gemirro
70
+ ProxyPreserveHost On
71
+ ProxyRequests off
72
+ ProxyPass / http://localhost:2000
73
+ ProxyPassReverse / http://localhost:2000
74
+ </VirtualHost>
75
+ ```
58
76
 
59
77
  ##Nginx configuration
60
- TODO
78
+
79
+ Replace `localhost:2000` with your custom server configuration located in your `config.rb` file and restart Nginx.
80
+
81
+ ```
82
+ upstream gemirro {
83
+ server localhost:2000;
84
+ }
85
+
86
+ server {
87
+ server_name rbgems;
88
+
89
+ location / {
90
+ proxy_pass http://gemirro;
91
+ proxy_set_header Host $host;
92
+ proxy_set_header X-Real-IP $remote_addr;
93
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
94
+ }
95
+ }
96
+ ```
97
+
data/bin/gemirro CHANGED
@@ -3,4 +3,5 @@
3
3
 
4
4
  require File.expand_path('../../lib/gemirro', __FILE__)
5
5
 
6
- Gemirro::CLI.options.parse
6
+ options = Gemirro::CLI.options
7
+ puts options if options.parse.empty?
@@ -39,10 +39,13 @@ module Gemirro
39
39
  #
40
40
  def run
41
41
  while (session = server.accept)
42
- request = session.gets
42
+ request = session.gets.chomp
43
43
  logger.info(request)
44
44
 
45
- trimmedrequest = request.gsub(/GET\ \//, '').gsub(/\ HTTP.*/, '').chomp
45
+ trimmedrequest = request
46
+ .gsub(/(HEAD|GET)\ \//, '')
47
+ .gsub(/\ HTTP.*/, '')
48
+ .chomp
46
49
  resource = "#{@destination}/#{trimmedrequest}"
47
50
 
48
51
  # Try to download gem if file doesn't exists
@@ -56,13 +59,17 @@ module Gemirro
56
59
  next
57
60
  end
58
61
 
59
- if File.directory?(resource)
60
- display_directory(session, resource)
61
- else
62
- mime_type = MIME::Types.type_for(resource)
63
- session.print "HTTP/1.1 200/OK\r\nContent-type:#{mime_type}\r\n\r\n"
64
- file = open(resource, 'rb')
65
- session.puts(file.read)
62
+ begin
63
+ if File.directory?(resource)
64
+ display_directory(session, resource)
65
+ else
66
+ mime_type = MIME::Types.type_for(resource)
67
+ session.print "HTTP/1.1 200/OK\r\nContent-type:#{mime_type}\r\n\r\n"
68
+ file = open(resource, 'rb')
69
+ session.puts(file.read)
70
+ end
71
+ rescue Errno::ECONNRESET, Errno::EPIPE => e
72
+ logger.info(e.message)
66
73
  end
67
74
 
68
75
  session.close
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Gemirro Version
3
3
  module Gemirro
4
- VERSION = '0.0.2'
4
+ VERSION = '0.1.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemirro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Rambaud