stickler 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +15 -0
  2. data/CONTRIBUTING.md +5 -4
  3. data/HISTORY.md +16 -9
  4. data/LICENSE +1 -1
  5. data/Manifest.txt +34 -20
  6. data/README.md +128 -0
  7. data/Rakefile +10 -9
  8. data/bin/stickler +9 -6
  9. data/bin/stickler-passenger-config +8 -8
  10. data/bin/stickler-server +12 -12
  11. data/examples/as_middleware.ru +14 -0
  12. data/examples/auth_repo.ru +1 -1
  13. data/examples/gemcutter_repo.ru +1 -1
  14. data/examples/local_repo.ru +1 -1
  15. data/lib/stickler.rb +3 -1
  16. data/lib/stickler/client.rb +2 -1
  17. data/lib/stickler/client/delete.rb +1 -1
  18. data/lib/stickler/client/latest-version.rb +40 -0
  19. data/lib/stickler/client/mirror.rb +47 -15
  20. data/lib/stickler/client/push.rb +1 -1
  21. data/lib/stickler/client/unyank.rb +1 -1
  22. data/lib/stickler/client/yank.rb +1 -1
  23. data/lib/stickler/gem_container.rb +40 -0
  24. data/lib/stickler/gemfile_lock_parser.rb +47 -0
  25. data/lib/stickler/middleware.rb +1 -0
  26. data/lib/stickler/middleware/server.rb +37 -0
  27. data/lib/stickler/repository/api.rb +16 -0
  28. data/lib/stickler/repository/index.rb +0 -3
  29. data/lib/stickler/repository/local.rb +6 -8
  30. data/lib/stickler/repository/remote.rb +29 -7
  31. data/lib/stickler/server.rb +2 -6
  32. data/man/stickler-passenger-config.1 +2 -22
  33. data/man/stickler-server.1 +9 -99
  34. data/man/stickler.1 +15 -173
  35. data/man/stickler.1.ronn +6 -0
  36. data/tasks/default.rake +16 -18
  37. data/tasks/man.rake +7 -0
  38. data/tasks/this.rb +5 -5
  39. data/test/data/Gemfile.lock.example +56 -0
  40. data/{spec → test}/data/gemcutter/gems/foo-1.0.0.gem +0 -0
  41. data/{spec → test}/data/gems/bar-1.0.0.gem +0 -0
  42. data/{spec → test}/data/gems/baz-3.1.4-java.gem +0 -0
  43. data/{spec → test}/data/gems/baz-3.1.4.gem +0 -0
  44. data/{spec → test}/data/gems/foo-1.0.0.gem +0 -0
  45. data/{spec → test}/data/gems/foo-2.0.0a.gem +0 -0
  46. data/test/data/specifications/bar-1.0.0.gemspec +31 -0
  47. data/test/data/specifications/baz-3.1.4-java.gemspec +32 -0
  48. data/test/data/specifications/baz-3.1.4.gemspec +31 -0
  49. data/test/data/specifications/foo-1.0.0.gemspec +31 -0
  50. data/test/data/specifications/foo-2.0.0a.gemspec +32 -0
  51. data/test/index_test_helpers.rb +75 -0
  52. data/test/middleware/test_local.rb +75 -0
  53. data/test/middleware/test_not_found.rb +26 -0
  54. data/test/repository/test_api.rb +49 -0
  55. data/test/repository/test_api_behavior.rb +208 -0
  56. data/test/repository/test_index.rb +48 -0
  57. data/test/repository/test_local.rb +59 -0
  58. data/test/repository/test_null.rb +15 -0
  59. data/test/repository/test_remote.rb +26 -0
  60. data/test/repository/test_remote_authenticated.rb +39 -0
  61. data/test/stickler_test_server.rb +35 -0
  62. data/test/test_gemfile_lock_parser.rb +28 -0
  63. data/test/test_paths.rb +22 -0
  64. data/test/test_spec_lite.rb +90 -0
  65. data/test/test_stickler.rb +49 -0
  66. metadata +58 -85
  67. data/README.rdoc +0 -156
  68. data/spec/index_spec_helpers.rb +0 -73
  69. data/spec/middleware/local_spec.rb +0 -72
  70. data/spec/middleware/not_found_spec.rb +0 -25
  71. data/spec/paths_spec.rb +0 -11
  72. data/spec/repository/api_behavior.rb +0 -192
  73. data/spec/repository/api_spec.rb +0 -37
  74. data/spec/repository/index_spec.rb +0 -46
  75. data/spec/repository/local_spec.rb +0 -49
  76. data/spec/repository/null_spec.rb +0 -14
  77. data/spec/repository/remote_spec.rb +0 -86
  78. data/spec/spec.opts +0 -2
  79. data/spec/spec_helper.rb +0 -24
  80. data/spec/spec_lite_spec.rb +0 -96
@@ -48,6 +48,13 @@ module ::Stickler::Repository
48
48
  Marshal.load( download_specs_list )
49
49
  end
50
50
 
51
+ #
52
+ # The array of latests specs from usptream
53
+ #
54
+ def latest_specs_list
55
+ Marshal.load( download_latest_specs_list )
56
+ end
57
+
51
58
  #
52
59
  # See Api#search_for
53
60
  #
@@ -95,12 +102,15 @@ module ::Stickler::Repository
95
102
 
96
103
  #
97
104
  # See Api#unyank
98
- #
105
+ #
99
106
  def unyank( spec )
100
- return nil unless remote_gem_file_exist?( spec )
101
- query = { :spec_name => spec.name, :version => spec.version.to_s }
102
- resource_request( unyank_resource, :query => query )
103
- true
107
+ if remote_gem_file_exist?( spec ) && search_for( spec ).empty? then
108
+ query = { :spec_name => spec.name, :version => spec.version.to_s }
109
+ resource_request( unyank_resource, :query => query )
110
+ return true
111
+ else
112
+ return nil
113
+ end
104
114
  rescue Excon::Errors::Error => e
105
115
  raise Stickler::Repository::Error, "Failure unyanking: #{e.inspect}"
106
116
  end
@@ -173,6 +183,14 @@ module ::Stickler::Repository
173
183
  @specs_list_resource ||= Excon.new( specs_list_uri.to_s, :method => :get, :expects => [200] )
174
184
  end
175
185
 
186
+ def latest_specs_list_uri
187
+ Addressable::URI.join( uri, "latest_specs.#{Gem.marshal_version}.gz" )
188
+ end
189
+
190
+ def latest_specs_list_resource
191
+ @latest_specs_list_resource ||= Excon.new( latest_specs_list_uri.to_s, :method => :get, :expects => [200] )
192
+ end
193
+
176
194
  def push_uri
177
195
  Addressable::URI.join( uri, "api/v1/gems" )
178
196
  end
@@ -214,6 +232,10 @@ module ::Stickler::Repository
214
232
  Excon.new( full_uri_to_gem( spec ), :method => :get, :expects => [200] )
215
233
  end
216
234
 
235
+ def download_latest_specs_list
236
+ download_gzipped_resource( latest_specs_list_resource )
237
+ end
238
+
217
239
  def download_specs_list
218
240
  download_gzipped_resource( specs_list_resource )
219
241
  end
@@ -254,8 +276,8 @@ module ::Stickler::Repository
254
276
  end
255
277
 
256
278
  def specification_from_gem_file( path )
257
- format = Gem::Format.from_file_by_path( path )
258
- return format.spec
279
+ container = Stickler::GemContainer.new( path )
280
+ return container.spec
259
281
  end
260
282
 
261
283
  def speclite_from_specification( spec )
@@ -12,14 +12,10 @@ module Stickler
12
12
 
13
13
  def app
14
14
  root = self.stickler_root
15
- Rack::Builder.app do
15
+ Rack::Builder.app( Sinatra::Base.new ) do
16
16
  use Rack::CommonLogger
17
- use Stickler::Middleware::Compression
18
- use Stickler::Middleware::Gemcutter, :serve_indexes => false, :repo_root => File.join( root, "gemcutter" )
19
- use Stickler::Middleware::Mirror, :serve_indexes => false, :repo_root => File.join( root, "mirror" )
20
- use Stickler::Middleware::Index, :serve_indexes => true
17
+ use Stickler::Middleware::Server, :stickler_root => root
21
18
  use Stickler::Middleware::NotFound
22
- run Sinatra::Base
23
19
  end
24
20
  end
25
21
  end
@@ -19,30 +19,10 @@ stickler\-passenger\-config \- output a Phusion Passenger config for stickler
19
19
  \fInginx\fR: Output an Nginx config\.
20
20
  .
21
21
  .SH "OPTIONS"
22
- \fI\-h, \-\-help\fR:
23
- .
24
- .IP "" 4
25
- .
26
- .nf
27
-
28
- Show the help message
29
- .
30
- .fi
31
- .
32
- .IP "" 0
22
+ \fI\-h, \-\-help\fR: Show the help message
33
23
  .
34
24
  .P
35
- \fI\-v, \-\-version\fR:
36
- .
37
- .IP "" 4
38
- .
39
- .nf
40
-
41
- Output the version\.
42
- .
43
- .fi
44
- .
45
- .IP "" 0
25
+ \fI\-v, \-\-version\fR: Output the version\.
46
26
  .
47
27
  .SH "EXAMPLES"
48
28
  Output a passenger config for use with apache\.
@@ -13,121 +13,31 @@ stickler\-server \- start and stop the stickler server process
13
13
  stickler\-server is the daemon process that houses the repositories of proprietary gems and/or mirrors of third party gems\.
14
14
  .
15
15
  .SH "COMMANDS"
16
- \fIstart\fR:
17
- .
18
- .IP "" 4
19
- .
20
- .nf
21
-
22
- Start the stickler server process
23
- .
24
- .fi
25
- .
26
- .IP "" 0
16
+ \fIstart\fR: Start the stickler server process
27
17
  .
28
18
  .P
29
- \fIstop\fR:
30
- .
31
- .IP "" 4
32
- .
33
- .nf
34
-
35
- Stop the stickler server process
36
- .
37
- .fi
38
- .
39
- .IP "" 0
19
+ \fIstop\fR: Stop the stickler server process
40
20
  .
41
21
  .SH "OPTIONS"
42
- \fI\-d, \-\-daemonize\fR:
43
- .
44
- .IP "" 4
45
- .
46
- .nf
47
-
48
- Daemonize the server
49
- .
50
- .fi
51
- .
52
- .IP "" 0
22
+ \fI\-d, \-\-daemonize\fR: Daemonize the server
53
23
  .
54
24
  .P
55
- \fI\-\-help\fR:
56
- .
57
- .IP "" 4
58
- .
59
- .nf
60
-
61
- Show the help message
62
- .
63
- .fi
64
- .
65
- .IP "" 0
25
+ \fI\-\-help\fR: Show the help message
66
26
  .
67
27
  .P
68
- \fI\-h, \-\-host\fR=\'HOST\':
69
- .
70
- .IP "" 4
71
- .
72
- .nf
73
-
74
- The host address to bind to (default: 0\.0\.0\.0)
75
- .
76
- .fi
77
- .
78
- .IP "" 0
28
+ \fI\-h, \-\-host\fR=\'HOST\': The host address to bind to (default: 0\.0\.0\.0)
79
29
  .
80
30
  .P
81
- \fI\-o, \-\-port\fR=\'PORT\':
82
- .
83
- .IP "" 4
84
- .
85
- .nf
86
-
87
- The port to bind to (default: 6789)
88
- .
89
- .fi
90
- .
91
- .IP "" 0
31
+ \fI\-o, \-\-port\fR=\'PORT\': The port to bind to (default: 6789)
92
32
  .
93
33
  .P
94
- \fI\-p, \-\-pid\fR=\'PID_FILE\':
95
- .
96
- .IP "" 4
97
- .
98
- .nf
99
-
100
- Path to wriate a pid file to after daemonizing
101
- .
102
- .fi
103
- .
104
- .IP "" 0
34
+ \fI\-p, \-\-pid\fR=\'PID_FILE\': Path to wriate a pid file to after daemonizing
105
35
  .
106
36
  .P
107
- \fI\-s, \-\-server\fR=\'SERVER\':
108
- .
109
- .IP "" 4
110
- .
111
- .nf
112
-
113
- The rack handler to use: thin, mongrel, webrick, etc\.
114
- .
115
- .fi
116
- .
117
- .IP "" 0
37
+ \fI\-s, \-\-server\fR=\'SERVER\': The rack handler to use: thin, mongrel, webrick, etc\.
118
38
  .
119
39
  .P
120
- \fI\-v, \-\-version\fR:
121
- .
122
- .IP "" 4
123
- .
124
- .nf
125
-
126
- Output the version\.
127
- .
128
- .fi
129
- .
130
- .IP "" 0
40
+ \fI\-v, \-\-version\fR: Output the version\.
131
41
  .
132
42
  .SH "EXAMPLES"
133
43
  Start the server, daemonized, using /var/lib/stickler as the root directory of all the repositories\.
@@ -16,210 +16,52 @@ Stickler is a tool to organize and maintain an internal gem repository of propri
16
16
  The stickler(1) command interacts with an instance of stickler\-server(1) to control the publishing and mirroring of ruby gems\.
17
17
  .
18
18
  .SH "COMMANDS"
19
- \fIpush\fR:
20
- .
21
- .IP "" 4
22
- .
23
- .nf
24
-
25
- Push one or more gems to a gemserver\. This works the same as `gem push`
26
- although there is no authorization mechanism\.
27
- .
28
- .fi
29
- .
30
- .IP "" 0
19
+ \fIpush\fR: Push one or more gems to a gemserver\. This works the same as \fBgem push\fR although there is no authorization mechanism\.
31
20
  .
32
21
  .P
33
- \fIyank\fR:
34
- .
35
- .IP "" 4
36
- .
37
- .nf
38
-
39
- Remove a gem from the gemserver\'s index\. It will still be available from
40
- direct download\. This works the same as `gem yank`\.
41
- .
42
- .fi
43
- .
44
- .IP "" 0
22
+ \fIyank\fR: Remove a gem from the gemserver\'s index\. It will still be available from direct download\. This works the same as \fBgem yank\fR\.
45
23
  .
46
24
  .P
47
- \fImirror\fR:
48
- .
49
- .IP "" 4
50
- .
51
- .nf
52
-
53
- Pull a specific version of a gem from an upstream gem server and
54
- store it in a stickler\-server(1)\.
55
- .
56
- .fi
57
- .
58
- .IP "" 0
25
+ \fImirror\fR: Pull a specific version of a gem from an upstream gem server and store it in a stickler\-server(1)\.
59
26
  .
60
27
  .P
61
- \fIconfig\fR:
62
- .
63
- .IP "" 4
64
- .
65
- .nf
66
-
67
- Access or update the stickler client configuration\.
68
- .
69
- .fi
70
- .
71
- .IP "" 0
28
+ \fIconfig\fR: Access or update the stickler client configuration\.
72
29
  .
73
30
  .P
74
- \fIlist\fR:
75
- .
76
- .IP "" 4
77
- .
78
- .nf
79
-
80
- List all the gems in the remote repository\.
81
- .
82
- .fi
83
- .
84
- .IP "" 0
31
+ \fIlist\fR: List all the gems in the remote repository\.
85
32
  .
86
33
  .P
87
- \fIunyank\fR:
88
- .
89
- .IP "" 4
90
- .
91
- .nf
92
-
93
- Put a gem that was _yanked_ back into the gemserver index\. This reverses a
94
- `yank`\.
95
- .
96
- .fi
97
- .
98
- .IP "" 0
34
+ \fIunyank\fR: Put a gem that was \fIyanked\fR back into the gemserver index\. This reverses a \fByank\fR\.
99
35
  .
100
36
  .SH "OPTIONS"
101
37
  These are the options for all commands\. Not all options apply to all commands\.
102
38
  .
103
39
  .P
104
- \fI\-a, \-\-add\fR:
105
- .
106
- .IP "" 4
107
- .
108
- .nf
109
-
110
- Add the `\-\-server` or `\-\-upstream` items to the config file when using the
111
- `config` command\.
112
- .
113
- .fi
114
- .
115
- .IP "" 0
40
+ \fI\-a, \-\-add\fR: Add the \fB\-\-server\fR or \fB\-\-upstream\fR items to the config file when using the \fBconfig\fR command\.
116
41
  .
117
42
  .P
118
- \fI\-d, \-\-debug\fR:
119
- .
120
- .IP "" 4
121
- .
122
- .nf
123
-
124
- Output debug information
125
- .
126
- .fi
127
- .
128
- .IP "" 0
43
+ \fI\-d, \-\-debug\fR: Output debug information
129
44
  .
130
45
  .P
131
- \fI\-g, \-\-gem\-version\fR=\'VERSION\':
132
- .
133
- .IP "" 4
134
- .
135
- .nf
136
-
137
- The version of the gem to yank from `\-\-server` or to mirror from
138
- `\-\-upstream`\.
139
- .
140
- .fi
141
- .
142
- .IP "" 0
46
+ \fI\-g, \-\-gem\-version\fR=\'VERSION\': The version of the gem to yank from \fB\-\-server\fR or to mirror from \fB\-\-upstream\fR\.
143
47
  .
144
48
  .P
145
- \fI\-h, \-\-help\fR:
146
- .
147
- .IP "" 4
148
- .
149
- .nf
150
-
151
- Show the help message
152
- .
153
- .fi
154
- .
155
- .IP "" 0
49
+ \fI\-h, \-\-help\fR: Show the help message
156
50
  .
157
51
  .P
158
- \fI\-l, \-\-list\fR:
159
- .
160
- .IP "" 4
161
- .
162
- .nf
163
-
164
- Display the current configuration when using the `config` command\.
165
- .
166
- .fi
167
- .
168
- .IP "" 0
52
+ \fI\-l, \-\-list\fR: Display the current configuration when using the \fBconfig\fR command\.
169
53
  .
170
54
  .P
171
- \fI\-p, \-\-platform\fR=\'PLATFORM\':
172
- .
173
- .IP "" 4
174
- .
175
- .nf
176
-
177
- The platform of the gem to yank from `\-\-server` or to mirror from
178
- `\-\-upstream` (e\.g\. ruby, java, mswin32)
179
- .
180
- .fi
181
- .
182
- .IP "" 0
55
+ \fI\-p, \-\-platform\fR=\'PLATFORM\': The platform of the gem to yank from \fB\-\-server\fR or to mirror from \fB\-\-upstream\fR (e\.g\. ruby, java, mswin32)
183
56
  .
184
57
  .P
185
- \fI\-s, \-\-server\fR=\'SERVER\':
186
- .
187
- .IP "" 4
188
- .
189
- .nf
190
-
191
- The gem server or stickler\-server(1) URL\. This is used by all the commands\.
192
- .
193
- .fi
194
- .
195
- .IP "" 0
58
+ \fI\-s, \-\-server\fR=\'SERVER\': The gem server or stickler\-server(1) URL\. This is used by all the commands\.
196
59
  .
197
60
  .P
198
- \fI\-u, \-\-upstream\fR=\'SERVER\':
199
- .
200
- .IP "" 4
201
- .
202
- .nf
203
-
204
- The upstream server from which to mirror a gem when using the `mirror`
205
- command\.
206
- .
207
- .fi
208
- .
209
- .IP "" 0
61
+ \fI\-u, \-\-upstream\fR=\'SERVER\': The upstream server from which to mirror a gem when using the \fBmirror\fR command\.
210
62
  .
211
63
  .P
212
- \fI\-v, \-\-version\fR:
213
- .
214
- .IP "" 4
215
- .
216
- .nf
217
-
218
- Output the version\.
219
- .
220
- .fi
221
- .
222
- .IP "" 0
64
+ \fI\-v, \-\-version\fR: Output the version\.
223
65
  .
224
66
  .SH "CONFIGURATION"
225
67
  Stickler uses the \fB\.gem/stickler\fR file to hold its configuration\. It is a yaml file and Currently there are two options\. These are altered using the \fBstickler config\fR command\.