rhinestone 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +7 -0
- data/README.md +43 -7
- data/lib/rhinestone.rb +6 -1
- data/lib/rhinestone/config.rb +29 -0
- data/lib/rhinestone/injector.rb +5 -1
- data/lib/rhinestone/version.rb +1 -1
- data/spec/rhinestone/config_spec.rb +31 -0
- metadata +26 -23
data/MIT-LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (C) 2012 Adam Pohorecki
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -6,23 +6,36 @@ It has bothered me, so I wrote Rhinestone: a simple proxy caches both the gems a
|
|
6
6
|
It updates the cache *after* returning the response, so you get data that might be a little stale, but you get it very quickly.
|
7
7
|
You should deploy it somewhere in your local network (so that more people use the same cache).
|
8
8
|
|
9
|
-
|
9
|
+
## Installation
|
10
10
|
|
11
11
|
Just install it from RubyGems:
|
12
12
|
|
13
13
|
gem install rhinestone
|
14
14
|
|
15
|
-
|
15
|
+
Below is the upstart script I used to make it run on Ubuntu:
|
16
16
|
|
17
|
-
|
17
|
+
```
|
18
|
+
# File: /etc/init/rhinestone.conf
|
18
19
|
|
19
|
-
|
20
|
+
# Rhinestone - a RubyGems.org proxy
|
21
|
+
|
22
|
+
description "rhinestone proxy server"
|
23
|
+
|
24
|
+
start on runlevel [23]
|
25
|
+
stop on shutdown
|
26
|
+
|
27
|
+
exec sudo rhinestone -p 80 -e prod -l /var/log/rhinestone.log -P /var/run/rhinestone.pid -C /var/rhinestone/cache
|
20
28
|
|
21
|
-
|
29
|
+
respawn
|
30
|
+
```
|
22
31
|
|
23
|
-
|
32
|
+
## Running
|
24
33
|
|
25
|
-
|
34
|
+
It's as simple as running:
|
35
|
+
|
36
|
+
rhinestone
|
37
|
+
|
38
|
+
Rhinestone uses Goliath underneath, so there are some switches you can use:
|
26
39
|
|
27
40
|
Server options:
|
28
41
|
-e, --environment NAME Set the execution environment (prod, dev or test) (default: development)
|
@@ -47,3 +60,26 @@ Rhinestone uses Goliath underneath, so there are more switches you can use:
|
|
47
60
|
Common options:
|
48
61
|
-v, --verbose Enable verbose logging (default: false)
|
49
62
|
-h, --help Display help message
|
63
|
+
|
64
|
+
Rhinestone-specific options:
|
65
|
+
-C, --cache-path DIRECTORY The directory where cache files will be stored
|
66
|
+
|
67
|
+
|
68
|
+
## Usage
|
69
|
+
|
70
|
+
Assuming you have Rhinestone running somewhere in your local network, add this to your Gemfile:
|
71
|
+
|
72
|
+
source :rubygems
|
73
|
+
source "http://rhinestone.local" # the address of rhinestone
|
74
|
+
|
75
|
+
This will speed up `bundle install` about 5-6x times, and even more if you remove the rubygems part completely (but I don't recommend that).
|
76
|
+
Note that the Rhinestone line is beneath rubygems one.
|
77
|
+
Otherwise bundler would download most of the gems directly from Rubygems and not from the proxy.
|
78
|
+
|
79
|
+
## Author
|
80
|
+
|
81
|
+
Adam Pohorecki
|
82
|
+
|
83
|
+
## License
|
84
|
+
|
85
|
+
MIT, see the MIT-LICENSE file.
|
data/lib/rhinestone.rb
CHANGED
@@ -7,6 +7,7 @@ require 'yaml'
|
|
7
7
|
module Rhinestone
|
8
8
|
autoload :App, 'rhinestone/app'
|
9
9
|
autoload :Cache, 'rhinestone/cache'
|
10
|
+
autoload :Config, 'rhinestone/config'
|
10
11
|
autoload :FilesystemCacheBackend, 'rhinestone/filesystem_cache_backend'
|
11
12
|
autoload :HeaderFilter, 'rhinestone/header_filter'
|
12
13
|
autoload :Injector, 'rhinestone/injector'
|
@@ -18,7 +19,11 @@ module Rhinestone
|
|
18
19
|
autoload :VERSION, 'rhinestone/version'
|
19
20
|
|
20
21
|
def self.server
|
21
|
-
Injector.new.server
|
22
|
+
Injector.new(config).server
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.config
|
26
|
+
Rhinestone::Config.new(ARGV).to_h
|
22
27
|
end
|
23
28
|
|
24
29
|
def self.run!
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Rhinestone
|
4
|
+
class Config
|
5
|
+
|
6
|
+
def initialize(argv)
|
7
|
+
@options = extract_options(argv)
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_h
|
11
|
+
@options
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def extract_options(argv)
|
17
|
+
options = {}
|
18
|
+
|
19
|
+
cache_path_idx = argv.index('--cache-path') || argv.index('-C')
|
20
|
+
|
21
|
+
if cache_path_idx
|
22
|
+
options[:cache_path] = argv[cache_path_idx + 1]
|
23
|
+
argv.slice!(cache_path_idx, 2)
|
24
|
+
end
|
25
|
+
|
26
|
+
return options
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/rhinestone/injector.rb
CHANGED
@@ -3,8 +3,12 @@ module Rhinestone
|
|
3
3
|
include Dependor::AutoInject
|
4
4
|
look_in_modules Rhinestone
|
5
5
|
|
6
|
+
def initialize(opts = {})
|
7
|
+
@cache_path = opts.fetch(:cache_path, '/tmp/rhinestone/cache')
|
8
|
+
end
|
9
|
+
|
6
10
|
def cache_backend
|
7
|
-
@cache_backend ||= FilesystemCacheBackend.new(
|
11
|
+
@cache_backend ||= FilesystemCacheBackend.new(@cache_path)
|
8
12
|
end
|
9
13
|
|
10
14
|
def hostname
|
data/lib/rhinestone/version.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe Rhinestone::Config do
|
4
|
+
it "parses out cache_path from arguments in long version" do
|
5
|
+
config('-d --environment prod --cache-path /some/path -p 80').should == {
|
6
|
+
:cache_path => '/some/path'
|
7
|
+
}
|
8
|
+
end
|
9
|
+
|
10
|
+
it "parses out cache_path from arguments in short version" do
|
11
|
+
config('-d --environment prod -C /some/path -p 80').should == {
|
12
|
+
:cache_path => '/some/path'
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'removes the option from argv' do
|
17
|
+
args = argv('-p --cache-path /foo -D')
|
18
|
+
|
19
|
+
Rhinestone::Config.new(args).to_h
|
20
|
+
|
21
|
+
args.should == ['-p', '-D']
|
22
|
+
end
|
23
|
+
|
24
|
+
def config(command_line)
|
25
|
+
Rhinestone::Config.new(argv(command_line)).to_h
|
26
|
+
end
|
27
|
+
|
28
|
+
def argv(command_line)
|
29
|
+
command_line.split(' ')
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhinestone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-03-21 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dependor
|
16
|
-
requirement: &
|
16
|
+
requirement: &74832880 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *74832880
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: goliath
|
27
|
-
requirement: &
|
27
|
+
requirement: &74832670 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *74832670
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: em-http-request
|
38
|
-
requirement: &
|
38
|
+
requirement: &74832460 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *74832460
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &74832250 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *74832250
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &74832040 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *74832040
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: vcr
|
71
|
-
requirement: &
|
71
|
+
requirement: &74831830 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *74831830
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: webmock
|
82
|
-
requirement: &
|
82
|
+
requirement: &74831620 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *74831620
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: guard
|
93
|
-
requirement: &
|
93
|
+
requirement: &74831410 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *74831410
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: guard-rspec
|
104
|
-
requirement: &
|
104
|
+
requirement: &74831200 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *74831200
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: libnotify
|
115
|
-
requirement: &
|
115
|
+
requirement: &74830990 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,7 +120,7 @@ dependencies:
|
|
120
120
|
version: '0'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *74830990
|
124
124
|
description: Proxy to rubygems that returns the latest cached version of the requested
|
125
125
|
url and updates the cache in the background
|
126
126
|
email:
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- .rvmrc
|
136
136
|
- Gemfile
|
137
137
|
- Guardfile
|
138
|
+
- MIT-LICENSE
|
138
139
|
- README.md
|
139
140
|
- Rakefile
|
140
141
|
- benchmark/Gemfile
|
@@ -145,6 +146,7 @@ files:
|
|
145
146
|
- lib/rhinestone.rb
|
146
147
|
- lib/rhinestone/app.rb
|
147
148
|
- lib/rhinestone/cache.rb
|
149
|
+
- lib/rhinestone/config.rb
|
148
150
|
- lib/rhinestone/filesystem_cache_backend.rb
|
149
151
|
- lib/rhinestone/header_filter.rb
|
150
152
|
- lib/rhinestone/http_client.rb
|
@@ -159,6 +161,7 @@ files:
|
|
159
161
|
- spec/cassettes/Rhinestone_integration/caches_the_requests.yml
|
160
162
|
- spec/cassettes/Rhinestone_integration/proxies_requests_to_rubygems_org.yml
|
161
163
|
- spec/rhinestone/cache_spec.rb
|
164
|
+
- spec/rhinestone/config_spec.rb
|
162
165
|
- spec/rhinestone/filesystem_cache_backend_spec.rb
|
163
166
|
- spec/rhinestone/header_filter_spec.rb
|
164
167
|
- spec/rhinestone/http_client_spec.rb
|
@@ -180,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
180
183
|
version: '0'
|
181
184
|
segments:
|
182
185
|
- 0
|
183
|
-
hash:
|
186
|
+
hash: 343967393
|
184
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
188
|
none: false
|
186
189
|
requirements:
|
@@ -189,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
192
|
version: '0'
|
190
193
|
segments:
|
191
194
|
- 0
|
192
|
-
hash:
|
195
|
+
hash: 343967393
|
193
196
|
requirements: []
|
194
197
|
rubyforge_project: rhinestone
|
195
198
|
rubygems_version: 1.8.10
|