librarian-puppet-maestrodev 0.9.9.8 → 0.9.10.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -170,25 +170,6 @@ Please include:
170
170
  * Please run the `librarian-puppet` commands in verbose mode by using the
171
171
  `--verbose` flag, and include the verbose output in the bug report as well.
172
172
 
173
- ## Changelog
174
-
175
- ### 0.9.0
176
-
177
- * Initial release
178
-
179
- ### 0.9.1
180
-
181
- * Proper error message when a module that is sourced from the forge does not
182
- exist.
183
- * Added support for annotated tags as git references.
184
- * `librarian-puppet init` adds `.tmp/` to gitignore instead of `tmp/`.
185
- * Fixed syntax error in the template Puppetfile created by `librarian-puppet
186
- init`.
187
- * Checks for `lib/puppet` as well as `manifests/` when checking if the git
188
- repository is a valid module.
189
- * When a user specifies `<foo>/<bar>` as the name of a module sources from a
190
- git repository, assume the module name is actually `<bar>`.
191
- * Fixed gem description and summary in gemspec.
192
173
 
193
174
  ## License
194
175
  Please see the [LICENSE](https://github.com/rodjek/librarian-puppet/blob/master/LICENSE)
@@ -102,15 +102,118 @@ module Librarian
102
102
  end
103
103
  end
104
104
 
105
- class Resolver
106
- # ensure we don't return nil, if manifests is nil we return a resolution that is not valid
107
- def resolve(spec, partial_manifests = [])
108
- manifests = implementation(spec).resolve(partial_manifests)
109
- if manifests
110
- enforce_consistency!(spec.dependencies, manifests)
111
- manifests = sort(manifests)
112
- end
113
- Resolution.new(spec.dependencies, manifests)
105
+ class Manifest
106
+
107
+ class PreReleaseVersion
108
+
109
+ # Compares pre-release component ids using Semver 2.0.0 spec
110
+ def self.compare_components(this_id,other_id)
111
+ case # Strings have higher precedence than numbers
112
+ when (this_id.is_a?(Integer) and other_id.is_a?(String))
113
+ -1
114
+ when (this_id.is_a?(String) and other_id.is_a?(Integer))
115
+ 1
116
+ else
117
+ this_id <=> other_id
118
+ end
119
+ end
120
+
121
+ # Parses pre-release components `a.b.c` into an array ``[a,b,c]`
122
+ # Converts numeric components into +Integer+
123
+ def self.parse(prerelease)
124
+ if prerelease.nil?
125
+ []
126
+ else
127
+ prerelease.split('.').collect do |id|
128
+ id = Integer(id) if /^[0-9]+$/ =~ id
129
+ id
130
+ end
131
+ end
132
+ end
133
+
134
+ include Comparable
135
+
136
+ attr_reader :components
137
+
138
+ def initialize(prerelease)
139
+ @prerelease = prerelease
140
+ @components = PreReleaseVersion.parse(prerelease)
141
+ end
142
+
143
+ def to_s
144
+ @prerelease
145
+ end
146
+
147
+ def <=>(other)
148
+ # null-fill zip array to prevent loss of components
149
+ z = Array.new([components.length,other.components.length])
150
+
151
+ # Compare each component against the other
152
+ comp = z.zip(components,other.components).collect do |ids|
153
+ case # All components being equal, the version with more of them takes precedence
154
+ when ids[1].nil? # Self has less elements, other wins
155
+ -1
156
+ when ids[2].nil? # Other has less elements, self wins
157
+ 1
158
+ else
159
+ PreReleaseVersion.compare_components(ids[1],ids[2])
160
+ end
161
+ end
162
+ # Chose the first non-zero comparison or return 0
163
+ comp.delete_if {|c| c == 0}[0] || 0
164
+ end
165
+ end
166
+ class Version
167
+ @@SEMANTIC_VERSION_PATTERN = /^([0-9]+\.[0-9]+(?:\.[0-9]+)?)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/
168
+ def self.parse_semver(version_string)
169
+ parsed = @@SEMANTIC_VERSION_PATTERN.match(version_string.strip)
170
+ if parsed
171
+ {
172
+ :full_version => parsed[0],
173
+ :version => parsed[1],
174
+ :prerelease => (PreReleaseVersion.new(parsed[2]) if parsed[2]),
175
+ :build => parsed[3]
176
+ }
177
+ end
178
+ end
179
+
180
+ attr_reader :prerelease
181
+
182
+ def initialize(*args)
183
+ args = initialize_normalize_args(args)
184
+ semver = Version.parse_semver(*args)
185
+ if semver
186
+ self.backing = Gem::Version.new(semver[:version])
187
+ @prerelease = semver[:prerelease]
188
+ @full_version = semver[:full_version]
189
+ else
190
+ self.backing = Gem::Version.new(*args)
191
+ @full_version = to_gem_version.to_s
192
+ end
193
+ end
194
+
195
+ def <=>(other)
196
+ cmp = to_gem_version <=> other.to_gem_version
197
+
198
+ # Should compare pre-release versions?
199
+ if cmp == 0 and not (prerelease.nil? and other.prerelease.nil?)
200
+ case # Versions without prerelease take precedence
201
+ when (prerelease.nil? and not other.prerelease.nil?)
202
+ 1
203
+ when (not prerelease.nil? and other.prerelease.nil?)
204
+ -1
205
+ else
206
+ prerelease <=> other.prerelease
207
+ end
208
+ else
209
+ cmp
210
+ end
211
+ end
212
+
213
+ def to_s
214
+ @full_version
215
+ end
114
216
  end
115
217
  end
218
+
116
219
  end
@@ -152,8 +152,10 @@ module Librarian
152
152
  def api_call(module_name)
153
153
  debug { "Querying Forge API for module #{name}" }
154
154
  base_url = source.uri
155
+ path = "api/v1/releases.json?module=#{module_name}"
156
+
155
157
  begin
156
- data = open("#{base_url}/api/v1/releases.json?module=#{module_name}") {|f| f.read}
158
+ data = open("#{base_url}/#{path}") {|f| f.read}
157
159
  JSON.parse(data)
158
160
  rescue OpenURI::HTTPError => e
159
161
  case e.io.status[0].to_i
@@ -125,10 +125,20 @@ module Librarian
125
125
  "librarian-puppet v#{Librarian::Puppet::VERSION}"
126
126
 
127
127
  resp = http.request(request)
128
- if resp.code.to_i != 200
128
+ data = resp.body
129
+
130
+ if resp.code.to_i == 403
131
+ begin
132
+ message = JSON.parse(data)['message']
133
+ if message.include? 'API rate limit exceeded'
134
+ raise Error, message
135
+ end
136
+ rescue JSON::ParserError
137
+ # 403 response does not return json, skip.
138
+ end
139
+ elsif resp.code.to_i != 200
129
140
  nil
130
141
  else
131
- data = resp.body
132
142
  JSON.parse(data)
133
143
  end
134
144
  end
@@ -1,5 +1,5 @@
1
1
  module Librarian
2
2
  module Puppet
3
- VERSION = "0.9.9.8"
3
+ VERSION = "0.9.10.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librarian-puppet-maestrodev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.9.8
4
+ version: 0.9.10.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-25 00:00:00.000000000 Z
12
+ date: 2013-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: librarian
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.1.0
21
+ version: 0.1.1
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.1.0
29
+ version: 0.1.1
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: json
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -107,6 +107,22 @@ dependencies:
107
107
  - - ! '>='
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: puppet
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
110
126
  description: ! "Simplify deployment of your Puppet infrastructure by\n automatically
111
127
  pulling in modules from the forge and git repositories with\n a single command."
112
128
  email:
@@ -149,7 +165,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
165
  version: '0'
150
166
  segments:
151
167
  - 0
152
- hash: -1093121364581452316
168
+ hash: -2861496222512018377
153
169
  required_rubygems_version: !ruby/object:Gem::Requirement
154
170
  none: false
155
171
  requirements:
@@ -158,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
174
  version: '0'
159
175
  segments:
160
176
  - 0
161
- hash: -1093121364581452316
177
+ hash: -2861496222512018377
162
178
  requirements: []
163
179
  rubyforge_project:
164
180
  rubygems_version: 1.8.25