gem-mirror 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ doc/build/
2
+ !doc/build/.gitkeep
3
+
4
+ Gemfile.lock
5
+ pkg
@@ -0,0 +1,11 @@
1
+ ./lib/gem-mirror/**/*.rb ./lib/gem-mirror.rb
2
+ -m markdown
3
+ -M redcarpet
4
+ -o ./doc/build
5
+ -r ./README.md
6
+ --private
7
+ --protected
8
+ --asset ./doc/css/common.css:css/common.css
9
+ -
10
+ ./doc/*.md
11
+ LICENSE
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2013, Yorick Peterse
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,33 @@
1
+ .gitignore
2
+ .yardopts
3
+ Gemfile
4
+ LICENSE
5
+ MANIFEST
6
+ README.md
7
+ Rakefile
8
+ bin/gem-mirror
9
+ doc/.gitkeep
10
+ doc/Contributing.md
11
+ doc/DCO.md
12
+ doc/css/.gitkeep
13
+ doc/css/common.css
14
+ gem-mirror.gemspec
15
+ lib/gem-mirror.rb
16
+ lib/gem-mirror/cli.rb
17
+ lib/gem-mirror/cli/checksum.rb
18
+ lib/gem-mirror/cli/index.rb
19
+ lib/gem-mirror/cli/init.rb
20
+ lib/gem-mirror/cli/update.rb
21
+ lib/gem-mirror/configuration.rb
22
+ lib/gem-mirror/gem.rb
23
+ lib/gem-mirror/gems_fetcher.rb
24
+ lib/gem-mirror/mirror_directory.rb
25
+ lib/gem-mirror/mirror_file.rb
26
+ lib/gem-mirror/source.rb
27
+ lib/gem-mirror/version.rb
28
+ lib/gem-mirror/versions_fetcher.rb
29
+ lib/gem-mirror/versions_file.rb
30
+ task/manifest.rake
31
+ template/config.rb
32
+ template/public/checksums/.gitkeep
33
+ template/public/gems/.gitkeep
@@ -0,0 +1,80 @@
1
+ # Gem Mirror
2
+
3
+ Gem-mirror is a Ruby application that makes it easy to create your own RubyGems
4
+ mirror without having to stitch together ugly Bash scripts or deal with more
5
+ complex tools such as [Geminabox][geminabox]. Unlike tools such as Geminabox
6
+ and other gem-mirror does mirroring only, it has no authentication and you
7
+ can't upload Gems to it.
8
+
9
+ ## Differences with Geminabox
10
+
11
+ Geminabox is basically a tiny DIY RubyGems that focuses more on uploading your
12
+ own Gems (e.g. company specific ones) instead of mirroring an external source.
13
+ Gem-mirror however purely focuses on generating a mirror that can be used by
14
+ the RubyGems CLI utility.
15
+
16
+ ## Differences with gem-server
17
+
18
+ RubyGems comes with the command `gem-server` which can be used to serve the
19
+ Gems you have installed on that machine and user. Similar to Geminabox it does
20
+ not provide the means to actually mirror an external source. It's also Rack
21
+ based and uses WEBRick, which isn't exactly the best server around.
22
+
23
+ ## How do I use it?
24
+
25
+ The process of setting up a mirror is fairly easy and can be done in a matter
26
+ of minutes depending on the amount of Gems you're mirroring and your internet
27
+ speed.
28
+
29
+ The first step is to set up a new, empty mirror. This is done by running the
30
+ `gem-mirror init` command similar to how you initialize a new Git repository:
31
+
32
+ $ gem-mirror init /srv/http/mirror.com/
33
+
34
+ Once created you should edit the main configuration file called `config.rb`.
35
+ This configuration file specifies what sources to mirror (you can mirror
36
+ multiple ones!), which Gems, etc.
37
+
38
+ Once configured you can pull all the Gems by running the following command:
39
+
40
+ $ gem-mirror update
41
+
42
+ If your configuration file is not located in the current directory you can
43
+ specify the path to it using the `-c` or `--config` option. The process of
44
+ downloading all the Gems takes a while and can use quite a bit of memory so
45
+ make sure you have plenty of time and RAM available.
46
+
47
+ Once all the Gems have been downloaded you'll need to generate an index of all
48
+ the installed files. This can be done as following:
49
+
50
+ $ gem-mirror index
51
+
52
+ Last but not least you'll want to generate a list of SHA512 checksums. Although
53
+ RubyGems doesn't use these they might come in handy when verifying Gems (e.g.
54
+ when RubyGems gets hacked again). This can be done using the following command:
55
+
56
+ $ gem-mirror checksum
57
+
58
+ If you want to do all this automatically (which is recommended) you can use a
59
+ simple Cronjob like the following one:
60
+
61
+ @hourly cd /srv/http/mirror.com && gem-mirror update && gem-mirror index
62
+
63
+ ## Requirements
64
+
65
+ * Ruby 1.9.2 or newer
66
+ * Enough space to store Gems
67
+
68
+ ## Installation
69
+
70
+ Assuming RubyGems isn't down you can install the Gem as following:
71
+
72
+ $ gem install gem-mirror
73
+
74
+ ## License
75
+
76
+ All source code in this repository is licensed under the MIT license unless
77
+ specified otherwise. A copy of this license can be found in the file "LICENSE"
78
+ in the root directory of this repository.
79
+
80
+ [geminabox]: https://github.com/cwninja/geminabox
@@ -0,0 +1,12 @@
1
+ require 'rubygems/package_task'
2
+
3
+ GEMSPEC = Gem::Specification.load('gem-mirror.gemspec')
4
+
5
+ Dir['./task/*.rake'].each do |task|
6
+ import(task)
7
+ end
8
+
9
+ Gem::PackageTask.new(GEMSPEC) do |pkg|
10
+ pkg.need_tar = false
11
+ pkg.need_zip = false
12
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path('../../lib/gem-mirror', __FILE__)
4
+
5
+ GemMirror::CLI.options.parse
File without changes
@@ -0,0 +1,125 @@
1
+ # Contributing
2
+
3
+ For those wishing to contribute code to gem-mirror there are several
4
+ requirements that have to be met before their code is accepted into the
5
+ repository. These requirements and the corresponding steps involved are
6
+ described in this document.
7
+
8
+ ## Licenses
9
+
10
+ gem-mirror is licensed under the MIT license (see the file "LICENSE" for the
11
+ specific details of this license) and thus all contributed code must be
12
+ compliant with this license. To keep things simple I do not accept code that is
13
+ licensed under a different license, even if it is an open source license.
14
+
15
+ For example, if you were to contribute a patch but license it under a specific
16
+ license, such as the GPL, then I will not accept it. All code should and will
17
+ always be licensed under the MIT license.
18
+
19
+ ## Signing Off
20
+
21
+ Each commit, no matter how small, must be signed off using `git commit --sign`.
22
+ When signing off a commit you indicate that you have read and accepted both the
23
+ Developer's Certificate of Origin (found in the file DCO.md) as well as the
24
+ license (found in the file LICENSE). Commits that are not signed off, no matter
25
+ how useful, will **not** be accepted.
26
+
27
+ When signing your commits make sure your username and Email address are set
28
+ correctly, these can be set as following:
29
+
30
+ $ git config --global --add user.name "YOUR NAME"
31
+ $ git config --global --add user.email "YOUR EMAIL"
32
+
33
+ Once configured properly you can sign off commits using the following command:
34
+
35
+ $ git commit --sign -m "Commit message goes in here"
36
+
37
+ ## Commit Messages
38
+
39
+ Commit messages should follow the same standard as the Kernel/Git repository.
40
+ The first line of the commit acts as a short description of what the commit
41
+ does. Think of it as the subject of an Email: make it short and understandable.
42
+ The maximum amount of characters on this line is 50 characters.
43
+
44
+ Note that descriptions such as "Updated README.md" and "Changes" are not proper
45
+ descriptions and will result in me not accepting such commits.
46
+
47
+ The second line of the commit should be empty as it acts as a separator between
48
+ the subject and following lines. The following lines can be used to give a more
49
+ in-depth description of what the commit does. These lines must not be longer
50
+ than 79 characters per line.
51
+
52
+ An example of a good commit message is the following:
53
+
54
+ Started completely re-writing the AST.
55
+
56
+ The current AST that's being generated by RubyLint::Parser is overly complex
57
+ and confusing due to the large number of classes used for different node types.
58
+ After having a discussion about ASTs and the likes with @whitequark I decided
59
+ that the AST generated by the parser has to be re-written from scratch.
60
+
61
+ To make things easier I'm using "Furnace" which provides a simple, immutable
62
+ class that can be used for representing nodes in an AST. Along with changing
63
+ the AST will come various changes to the way the definitions list is built as
64
+ well as how callback classes work (due to different event names being used).
65
+ None of this will be backwards compatible with what I've currently pushed to
66
+ Rubygems but that's expected when something is still alpha quality software.
67
+
68
+ Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>
69
+
70
+ Example of a not so good commit message:
71
+
72
+ ensure a http 302 redirect
73
+
74
+ The latter is bad because although it does state what it does (up to a certain
75
+ point) there's no in depth explanation. This means that I have to start digging
76
+ through code in order to find out what's going on. While I will always check
77
+ every commit added by somebody else there are times when the code is not clear
78
+ enough and I have no interest in spending an entire evening trying to
79
+ understand what somebody was trying to do.
80
+
81
+ ## Coding Standards
82
+
83
+ * 2 spaces per indentation level for Ruby files, 4 spaces for the CSS files
84
+ used for the documentation (chances are most people won't have to bother with
85
+ these). Code that includes tabs for indentation will not be accepted.
86
+
87
+ * Code must be documented using YARD. At minimum you should document the
88
+ parameters and return values, preferably it should also contain a short
89
+ description and some examples when needed. The formatting of generic text
90
+ (e.g. method descriptions) must be done using Markdown.
91
+
92
+ * The amount of dependencies, both runtime and development dependencies, should
93
+ be kept to a minimum. This reduces the amount of potential risk factors both
94
+ in terms of bugs as well as potential security issues.
95
+
96
+ * Nested modules/classes go into their own definitions, code such as `module
97
+ Foo::Bar; ...; end` is a no-no.
98
+
99
+ * Use common sense, I'm not going to hold your hands while you're writing
100
+ patches.
101
+
102
+ * Do yourself a favour and open an issue *before* starting on big changes that
103
+ I might reject. It would be a waste if you were to spend a week working on
104
+ something only for me to reject it. You're also welcome to send me an Email
105
+ but I prefer to keep gem-mirror related discussions on the issue tracker so
106
+ other people can see it and potentially give their feedback.
107
+
108
+ * Do not touch the files LICENSE, version.rb, MANIFEST and DCO.md. The Gemspec
109
+ (gem-mirror.gemspec) may only be modified when adding dependencies that are
110
+ absolutely required and only after I have approved it. Last I want is for the
111
+ gem to be broken because somebody messed with one of these files without me
112
+ noticing.
113
+
114
+ ## Language Requirements
115
+
116
+ Besides the various coding standards and commit requirements I also require
117
+ both code and commits to be written in proper English. A typo or grammar error
118
+ happens and isn't the end of the world but please double check your spelling
119
+ before committing something. If you use Vim you can enable spell checking by
120
+ running the following:
121
+
122
+ set spell spelllang=en
123
+
124
+ The use of offensive or otherwise negative language aimed at other projects,
125
+ people, organizations and the likes is not allowed.
@@ -0,0 +1,25 @@
1
+ Developer's Certificate of Origin 1.0
2
+
3
+ By making a contribution to this project, I certify that:
4
+
5
+ 1. The contribution was created in whole or in part by me and I
6
+ have the right to submit it under the open source license
7
+ indicated in the file LICENSE; or
8
+
9
+ 2. The contribution is based upon previous work that, to the best
10
+ of my knowledge, is covered under an appropriate open source
11
+ license and I have the right under that license to submit that
12
+ work with modifications, whether created in whole or in part
13
+ by me, under the same open source license (unless I am
14
+ permitted to submit under a different license), as indicated
15
+ in the file LICENSE; or
16
+
17
+ 3. The contribution was provided directly to me by some other
18
+ person who certified (1), (2) or (3) and I have not modified
19
+ it.
20
+
21
+ 4. I understand and agree that this project and the contribution
22
+ are public and that a record of the contribution (including all
23
+ personal information I submit with it, including my sign-off) is
24
+ maintained indefinitely and may be redistributed consistent with
25
+ this project or the open source license(s) involved.
File without changes
@@ -0,0 +1,68 @@
1
+ body
2
+ {
3
+ font-size: 14px;
4
+ line-height: 1.6;
5
+ margin: 0 auto;
6
+ max-width: 960px;
7
+ }
8
+
9
+ p code
10
+ {
11
+ background: #f2f2f2;
12
+ padding-left: 3px;
13
+ padding-right: 3px;
14
+ }
15
+
16
+ pre.code
17
+ {
18
+ font-size: 13px;
19
+ line-height: 1.4;
20
+ }
21
+
22
+ /**
23
+ * YARD uses generic table styles, using a special class means those tables
24
+ * don't get messed up.
25
+ */
26
+ .table
27
+ {
28
+ border: 1px solid #ccc;
29
+ border-right: none;
30
+ border-collapse: separate;
31
+ border-spacing: 0;
32
+ text-align: left;
33
+ }
34
+
35
+ .table.full
36
+ {
37
+ width: 100%;
38
+ }
39
+
40
+ .table .field_name
41
+ {
42
+ min-width: 160px;
43
+ }
44
+
45
+ .table thead tr th.no_sort:first-child
46
+ {
47
+ width: 25px;
48
+ }
49
+
50
+ .table thead tr th, .table tbody tr td
51
+ {
52
+ border-bottom: 1px solid #ccc;
53
+ border-right: 1px solid #ccc;
54
+ min-width: 20px;
55
+ padding: 8px 5px;
56
+ text-align: left;
57
+ vertical-align: top;
58
+ }
59
+
60
+ .table tbody tr:last-child td
61
+ {
62
+ border-bottom: none;
63
+ }
64
+
65
+ .table tr:nth-child(odd) td
66
+ {
67
+ background: #f9f9f9;
68
+ }
@@ -0,0 +1,26 @@
1
+ require File.expand_path('../lib/gem-mirror/version', __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'gem-mirror'
5
+ s.version = GemMirror::VERSION
6
+ s.date = '2012-02-03'
7
+ s.authors = ['Yorick Peterse']
8
+ s.email = 'yorickpeterse@gmail.com'
9
+ s.summary = 'Gem for easily creating your own RubyGems mirror.'
10
+ s.homepage = 'https://github.com/yorickpeterse/gem-mirror'
11
+ s.description = s.summary
12
+ s.executables = ['gem-mirror']
13
+
14
+ s.files = File.read(File.expand_path('../MANIFEST', __FILE__)).split("\n")
15
+
16
+ s.has_rdoc = 'yard'
17
+ s.required_ruby_version = '>= 1.9.2'
18
+
19
+ s.add_dependency 'slop'
20
+ s.add_dependency 'httpclient'
21
+ s.add_dependency 'builder'
22
+
23
+ s.add_development_dependency 'yard'
24
+ s.add_development_dependency 'redcarpet'
25
+ s.add_development_dependency 'rake'
26
+ end
@@ -0,0 +1,31 @@
1
+ require 'rubygems'
2
+ require 'rubygems/user_interaction'
3
+ require 'rubygems/indexer'
4
+ require 'slop'
5
+ require 'fileutils'
6
+ require 'digest/sha2'
7
+ require 'confstruct'
8
+ require 'zlib'
9
+ require 'httpclient'
10
+ require 'logger'
11
+ require 'stringio'
12
+
13
+ unless $:.include?(File.expand_path('../', __FILE__))
14
+ $:.unshift(File.expand_path('../', __FILE__))
15
+ end
16
+
17
+ require 'gem-mirror/version'
18
+ require 'gem-mirror/configuration'
19
+ require 'gem-mirror/gem'
20
+ require 'gem-mirror/source'
21
+ require 'gem-mirror/mirror_directory'
22
+ require 'gem-mirror/mirror_file'
23
+ require 'gem-mirror/versions_file'
24
+ require 'gem-mirror/versions_fetcher'
25
+ require 'gem-mirror/gems_fetcher'
26
+
27
+ require 'gem-mirror/cli'
28
+ require 'gem-mirror/cli/init'
29
+ require 'gem-mirror/cli/update'
30
+ require 'gem-mirror/cli/index'
31
+ require 'gem-mirror/cli/checksum'