puppet-forge-server 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50dd26198a713585d3ff7bc041d02c6d51f3db2c
4
- data.tar.gz: 6d2c8cdda16ba2f5fcd003b93d455737b49d89c4
3
+ metadata.gz: 7534f17808255a66c9f45677758540784f88dd49
4
+ data.tar.gz: 45e2900ea2f35918116c89b813dfa7465a713f41
5
5
  SHA512:
6
- metadata.gz: 6f1231fe9ecb57b1f9a478a4d9b3ed951a6b8c6887728600278a338841ce56fca69dae6a1736251811c7fa5dc4dcc966ca5d45aeb956639c95a533817351140a
7
- data.tar.gz: 99947b8750cfc37c4e58da45fc68e51d44de742b67e36da7aa4e111d58984871fc7560092ad1822f7e0923eeda5074bcbaca154837b09bf33c180007b09a68c4
6
+ metadata.gz: 4edc8df5081d8244aac83af9a3064a8787ce1d57b023a8b5f90125e440407e3650f2010fa560caabcb46dacce974abb56dde156ae348b792d959cb1b6a7dce1e
7
+ data.tar.gz: 995943485154d7772395495fcb91b162629491e4ba0e7f98a429847f9fe2ae5eaeef8d68170e6318dc23074eaee805f0d1c94be6faca8457a4f5032671e49087
data/README.md CHANGED
@@ -15,7 +15,7 @@ Install the gem
15
15
  gem install puppet-forge-server
16
16
  puppet-forge-server --help
17
17
  ```
18
- or get the latest source
18
+ or get the latest source
19
19
  ```
20
20
  git clone https://github.com/unibet/puppet-forge-server
21
21
  cd puppet-forge-server
@@ -36,7 +36,9 @@ module PuppetForgeServer::App
36
36
  end.flatten.uniq
37
37
 
38
38
  halt 404, {'pagination' => {'next' => false}, 'results' => []}.to_json if metadata.empty?
39
- {'pagination' => {'next' => false}, 'results' => get_releases(metadata)}.to_json
39
+
40
+ releases = get_releases(metadata)
41
+ {'pagination' => {'next' => false, 'total' => releases.count}, 'results' => releases}.to_json
40
42
  end
41
43
 
42
44
  get '/v3/files/*' do
@@ -31,12 +31,20 @@ module PuppetForgeServer::Backends
31
31
  def get_metadata(author, name, options = {})
32
32
  options = ({:with_checksum => true}).merge(options)
33
33
  query ="#{author}/#{name}"
34
- get_module_metadata(JSON.parse(get("/modules.json?q=#{query}")).select { |e| e['full_name'].match("#{query}") }, options)
34
+ begin
35
+ get_module_metadata(JSON.parse(get("/modules.json?q=#{query}")).select { |e| e['full_name'].match("#{query}") }, options)
36
+ rescue OpenURI::HTTPError
37
+ #ignore
38
+ end
35
39
  end
36
40
 
37
41
  def query_metadata(query, options = {})
38
42
  options = ({:with_checksum => true}).merge(options)
39
- get_module_metadata(JSON.parse(get("/modules.json?q=#{query}")).select { |e| e['full_name'].match("*#{query}*") }, options)
43
+ begin
44
+ get_module_metadata(JSON.parse(get("/modules.json?q=#{query}")).select { |e| e['full_name'].match("*#{query}*") }, options)
45
+ rescue OpenURI::HTTPError
46
+ #ignore
47
+ end
40
48
  end
41
49
 
42
50
  private
@@ -29,13 +29,21 @@ module PuppetForgeServer::Backends
29
29
  def get_metadata(author, name, options = {})
30
30
  options = ({:with_checksum => true}).merge(options)
31
31
  query ="#{author}-#{name}"
32
- releases = options[:version] ? [JSON.parse(get("/v3/releases/#{query}-#{options[:version]}"))] : get_all_release_pages("/v3/releases?module=#{query}")
33
- get_release_metadata(releases)
32
+ begin
33
+ releases = options[:version] ? [JSON.parse(get("/v3/releases/#{query}-#{options[:version]}"))] : get_all_release_pages("/v3/releases?module=#{query}")
34
+ get_release_metadata(releases)
35
+ rescue OpenURI::HTTPError
36
+ #ignore
37
+ end
34
38
  end
35
39
 
36
40
  def query_metadata(query, options = {})
37
41
  author, name = query.split('-')
38
- get_metadata(author, name, options) if author && name
42
+ begin
43
+ get_metadata(author, name, options) if author && name
44
+ rescue OpenURI::HTTPError
45
+ #ignore
46
+ end
39
47
  end
40
48
 
41
49
  private
@@ -55,7 +63,7 @@ module PuppetForgeServer::Backends
55
63
  :metadata => PuppetForgeServer::Models::Metadata.new(element['metadata']),
56
64
  :checksum => element['file_md5'],
57
65
  :path => element['file_uri'],
58
- :tags => element['tags']
66
+ :tags => (element['tags'] + (element['metadata']['tags'] ? element['metadata']['tags'] : [])).flatten.uniq
59
67
  }
60
68
  end.compact
61
69
  end
@@ -23,7 +23,7 @@ module PuppetForgeServer::Models
23
23
  end
24
24
 
25
25
  def method_missing (method_name, *args, &block)
26
- STDERR.puts "Method #{method_name} with args #{args} not found in #{self.class.to_s}" unless method_name == :to_ary
26
+ STDERR.puts "ERROR: Method #{method_name} with args #{args} not found in #{self.class.to_s}" unless method_name == :to_ary
27
27
  end
28
28
 
29
29
  def to_hash
@@ -20,6 +20,7 @@ module PuppetForgeServer::Models
20
20
 
21
21
  attr_accessor :author, :name, :version, :dependencies, :summary, :description, :project_page, :types
22
22
  attr_accessor :checksums, :source, :license, :issues_url, :operatingsystem_support, :requirements
23
+ attr_accessor :puppet_version, :tags
23
24
 
24
25
  def initialize(attributes)
25
26
  super(attributes)
@@ -42,7 +42,7 @@ class Array
42
42
 
43
43
  def version_sort_by
44
44
  sort_by do |element|
45
- version = yield(element)
45
+ version = yield(element).gsub('-', '.pre.')
46
46
  Gem::Version.new(version)
47
47
  end
48
48
  end
@@ -33,15 +33,15 @@ module PuppetForgeServer::Utils
33
33
  opts.banner = "Usage: #{File.basename $0} [options]"
34
34
  opts.version = PuppetForgeServer::VERSION
35
35
 
36
- opts.on('-p', '--port PORT', 'Port to listen on (defaults to whatever Rack wants to use)') do |port|
36
+ opts.on('-p', "--port PORT', 'Port to listen on (default: #{@@DEFAULT_PORT})") do |port|
37
37
  options[:port] = port
38
38
  end
39
39
 
40
- opts.on('-b', '--bind-host HOSTNAME', 'Host name to bind to (defaults to whatever Rack wants to use)') do |hostname|
40
+ opts.on('-b', '--bind-host HOSTNAME', 'Host name to bind to (default: whatever Rack wants to use)') do |hostname|
41
41
  options[:hostname] = hostname
42
42
  end
43
43
 
44
- opts.on('--daemonize', 'Run the server in the background') do
44
+ opts.on('-D', '--daemonize', "Run the server in the background (default: #{@@DEFAULT_DAEMONIZE})") do
45
45
  options[:daemonize] = true
46
46
  options[:pidfile] = @@DEFAULT_PID_FILE unless options[:pidfile]
47
47
  end
@@ -57,11 +57,8 @@ module PuppetForgeServer::Utils
57
57
  opts.on('-x', '--proxy URL', 'Remote forge to proxy (can be specified multiple times)') do |url|
58
58
  options[:backend]['Proxy'] << normalize_url(url)
59
59
  end
60
- opts.on('--source-dir DIR', "Directory containing a module's source (can be specified multiple times)") do |module_dir|
61
- options[:backend]['Source'] << module_dir
62
- end
63
60
 
64
- opts.on('--cache-basedir DIR', "Cache all proxies' downloaded modules under this directory") do |cache_basedir|
61
+ opts.on('--cache-basedir DIR', "Cache all proxies' downloaded modules under this directory (default: #{@@DEFAULT_CACHE_DIR})") do |cache_basedir|
65
62
  options[:cache_basedir] = cache_basedir
66
63
  end
67
64
  end
@@ -15,5 +15,5 @@
15
15
  # limitations under the License.
16
16
 
17
17
  module PuppetForgeServer
18
- VERSION = '1.0.1'
18
+ VERSION = '1.0.2'
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-forge-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilja Bobkevic