<commit_before>rubygems-servlets
=================

[![Build Status](https://secure.travis-ci.org/torquebox/rubygems-servlets.png)](http://travis-ci.org/torquebox/rubygems-servlets)

webapp which hosts rubygems or a proxy to rubygems. delivers gem maven artifacts as well. the proxy can be configured to be caching proxy or non-caching proxy

build
--

the regular webapp with hosted and (caching-)proxy can be built with

     mvn package

or just run it in place with

     mvn jetty:run

where the hosted rubygems are located under <http://localhost:8989/hosted> and the proxy with <https://rubygems.org> as source is reachable under <http://localhost:8989/caching> or <http://localhost:8989/proxy>. and the  <http://localhost:8989/merge> will combine all three to on rubygems repository.

executable standalone
---

you also can start the war like this (using embedded jetty):

     mvn package -Pexecutable
     java -jar target/rubygems.war

and adjust the <rubygems.properties> to your liking.

usage
--

add them to your gem command

* ```gem sources add <http://localhost:8989/hosted>```
* ```gem sources add <http://localhost:8989/caching>```
* ```gem sources add <http://localhost:8989/proxy>```
* ```gem sources add <http://localhost:8989/merged>```

or use the (caching-)proxy with bundler (example only for https://rubygems.org)

* ```bundler config mirror.https://rubygems.org http://localhost:8989/proxy```
* ```bundler config mirror.https://rubygems.org http://localhost:8989/caching```
* ```bundler config mirror.https://rubygems.org http://localhost:8989/merged```

the Gem-Artifacts are accessible via

*  <http://localhost:8989/hosted/maven/releases>
*  <http://localhost:8989/hosted/maven/prereleases>
*  <http://localhost:8989/caching/maven/releases>
*  <http://localhost:8989/caching/maven/prereleases>
*  <http://localhost:8989/proxy/maven/releases>
*  <http://localhost:8989/proxy/maven/prereleases>
*  <http://localhost:8989/merged/maven/releases>
*  <http://localhost:8989/merged/maven/prereleases>

you need a mirror declaration <http://rubygems-proxy.torquebox.org/releases> and <http://rubygems-proxy.torquebox.org/prereleases> in your settings.xml

    <settings>
      <mirrors>
        <mirror>
          <id>gems</id>
          <name>Rubygems</name>
          <url>http://localhost:8989/caching/maven/releases</url>
          <mirrorOf>rubygems-releases</mirrorOf>
        </mirror>
        <mirror>
          <id>pregems</id>
          <name>Rubygems Prereleases</name>
          <url>http://localhost:8989/caching/maven/prereleases</url>
          <mirrorOf>rubygems-prereleases</mirrorOf>
        </mirror>

since some old gem-artifacts use the those repositories (old in sense they originally came from rubygems-proxy.torquebox.org)

for more details about Gem-Artifacts see <https://github.com/sonatype/nexus-ruby-support/wiki/Gem-Artifacts>. for a solution with access control, more advanced proxy features and merging (group) to repositories see <https://github.com/sonatype/nexus-ruby-support>.

non-caching proxy
---

this proxy configuration does not cache the gem-files itself but instead sends a redirect to <rubygems.org>. all other files are cached the same way as the caching proxy:

    mvn jetty:run -P proxy

with url <http://localhost:8989/proxy>

rubygems-proxy.torquebox.org (not yet installed)
--

the webapp for this rubygems-proxy is under the profile **legacy**

     mvn clean package -Plegacy

which is just a proxy (mvn jetty:run -Plegacy)

*  <http://localhost:8989/releases>
*  <http://localhost:8989/prereleases>


tests
====<commit_msg>added paragraph on how to upload gems - fixes #15<commit_after>rubygems-servlets
=================

[![Build Status](https://secure.travis-ci.org/torquebox/rubygems-servlets.png)](http://travis-ci.org/torquebox/rubygems-servlets)

webapp which hosts rubygems or a proxy to rubygems. delivers gem maven artifacts as well. the proxy can be configured to be caching proxy or non-caching proxy

build
--

the regular webapp with hosted and (caching-)proxy can be built with

     mvn package

or just run it in place with

     mvn jetty:run

where the hosted rubygems are located under <http://localhost:8989/hosted> and the proxy with <https://rubygems.org> as source is reachable under <http://localhost:8989/caching> or <http://localhost:8989/proxy>. and the  <http://localhost:8989/merge> will combine all three to on rubygems repository.

executable standalone
---

you also can start the war like this (using embedded jetty):

     mvn package -Pexecutable
     java -jar target/rubygems.war

and adjust the <rubygems.properties> to your liking.

usage
--

add them to your gem command

* ```gem sources add <http://localhost:8989/hosted>```
* ```gem sources add <http://localhost:8989/caching>```
* ```gem sources add <http://localhost:8989/proxy>```
* ```gem sources add <http://localhost:8989/merged>```

or use the (caching-)proxy with bundler (example only for https://rubygems.org)

* ```bundler config mirror.https://rubygems.org http://localhost:8989/proxy```
* ```bundler config mirror.https://rubygems.org http://localhost:8989/caching```
* ```bundler config mirror.https://rubygems.org http://localhost:8989/merged```

the Gem-Artifacts are accessible via

*  <http://localhost:8989/hosted/maven/releases>
*  <http://localhost:8989/hosted/maven/prereleases>
*  <http://localhost:8989/caching/maven/releases>
*  <http://localhost:8989/caching/maven/prereleases>
*  <http://localhost:8989/proxy/maven/releases>
*  <http://localhost:8989/proxy/maven/prereleases>
*  <http://localhost:8989/merged/maven/releases>
*  <http://localhost:8989/merged/maven/prereleases>

you need a mirror declaration <http://rubygems-proxy.torquebox.org/releases> and <http://rubygems-proxy.torquebox.org/prereleases> in your settings.xml

    <settings>
      <mirrors>
        <mirror>
          <id>gems</id>
          <name>Rubygems</name>
          <url>http://localhost:8989/caching/maven/releases</url>
          <mirrorOf>rubygems-releases</mirrorOf>
        </mirror>
        <mirror>
          <id>pregems</id>
          <name>Rubygems Prereleases</name>
          <url>http://localhost:8989/caching/maven/prereleases</url>
          <mirrorOf>rubygems-prereleases</mirrorOf>
        </mirror>

since some old gem-artifacts use the those repositories (old in sense they originally came from rubygems-proxy.torquebox.org)

for more details about Gem-Artifacts see <https://github.com/sonatype/nexus-ruby-support/wiki/Gem-Artifacts>. for a solution with access control, more advanced proxy features and merging (group) to repositories see <https://github.com/sonatype/nexus-ruby-support>.


hosted
---

the underlying library nexus-ruby-tools can handle `gem push my-1.0.0.gem` but somehow I have not deciphered how to use rubygems.org and a local repo without manually editing the config files.

the easiest way is to use the `nexus` gem which was tailor made for the nexus-ruby-tools.


```
gem install nexus
``

then you can upload your gem with

```
gem nexus my-1.0.0.gem
```

it will prompt for the url which is http://localhost:8989/hosted from above. empty username and password will finally push the gem. since the username and passoword was empty it will be prompted again.


non-caching proxy
---

this proxy configuration does not cache the gem-files itself but instead sends a redirect to <rubygems.org>. all other files are cached the same way as the caching proxy:

    mvn jetty:run -P proxy

with url <http://localhost:8989/proxy>

rubygems-proxy.torquebox.org (not yet installed)
--

the webapp for this rubygems-proxy is under the profile **legacy**

     mvn clean package -Plegacy

which is just a proxy (mvn jetty:run -Plegacy)

*  <http://localhost:8989/releases>
*  <http://localhost:8989/prereleases>


tests
====
{'fraction_non_alphanumeric': 0.12949732074508805, 'fraction_numerical': 0.026027047716254147, 'mean_word_length': 3.8780336029869322, 'pattern_counts': {'":': 0, '<': 99, '<?xml version=': 0, '>': 99, 'https://': 16, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7403176', 'n_tokens_mistral': 2710, 'n_tokens_neox': 2442, 'n_words': 701}