community-zero 2.0.1 → 2.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: 226abd2ceb30453c56003b2de236ec47e8af77cf
4
- data.tar.gz: a409e38004737aeefe6ac90a62b49ac791873244
3
+ metadata.gz: 261644b167527ab9276b97f3a237633de68b7816
4
+ data.tar.gz: f600d118f314c8d6eeb35b1be7d18379f9e988bd
5
5
  SHA512:
6
- metadata.gz: 262caaa1ddf67dddec56af33b02814933a6ae76ba2cf94b3b178f0018b4b4c13f6c276a2967a145dab616cdec3219f5d04c627fc2792709ab82d690ab9669da7
7
- data.tar.gz: 4bf09520b70db219d1181719ea16fb714c92874db45889482453b5012aa3704557d8f50e6a4c48698928744029927224c1ab69c575ca9156b9441d7c3d09659b
6
+ metadata.gz: b8bb6605790682958e1b824b5e9672b459bc0981d62387a5511f91243b8daa07cf40fe20cf76cb79900f83c72ceacf646904922b29fb4d8429174204447d26f2
7
+ data.tar.gz: 16f5b7bc429553f540c48ab9268d666402a7d5bfd2894b4676c00c41a5291dace4495355ac432e18507ec947005b22fd1ed3ba194e614eb112d7972bf7c8380b
@@ -15,17 +15,36 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
+ require 'json'
19
+
18
20
  module CommunityZero
19
21
  # A quick, short metadata parser.
20
22
  #
21
23
  # @author Seth Vargo <sethvargo@gmail.com>
22
24
  class Metadata
23
- # Create a new metadata class.
25
+ # Create a new metadata class from the JSON.
24
26
  #
25
27
  # @param [String] content
26
- # the contents of the file to convert to a metadata entry.
27
- def initialize(content)
28
- instance_eval(content)
28
+ # the raw JSON content to parse into metadata
29
+ #
30
+ def self.from_json(content)
31
+ json = JSON.parse(content)
32
+
33
+ new.tap do |instance|
34
+ json.each do |k,v|
35
+ instance.send(k, v)
36
+ end
37
+ end
38
+ end
39
+
40
+ # Create a new metadata class from the raw Ruby.
41
+ #
42
+ # @param [String] content
43
+ # the contents of the file to convert to a metadata entry
44
+ def self.from_ruby(content)
45
+ new.tap do |instance|
46
+ instance.instance_eval(content)
47
+ end
29
48
  end
30
49
 
31
50
  def method_missing(m, *args, &block)
@@ -49,7 +49,7 @@ module CommunityZero
49
49
  cookbook = JSON.parse(params['cookbook'], symbolize_names: true)
50
50
  tarball = params['tarball']
51
51
 
52
- metadata = Metadata.new(read_tarball(tarball))
52
+ metadata = find_metadata(tarball)
53
53
 
54
54
  if store.find(metadata.name, metadata.version)
55
55
  respond(401,
@@ -86,20 +86,21 @@ module CommunityZero
86
86
  #
87
87
  # @param [Tempfile] tarball
88
88
  # the temporarily uploaded file
89
- def read_tarball(tarball)
89
+ #
90
+ # @return [Metadata]
91
+ def find_metadata(tarball)
90
92
  gzip = Zlib::GzipReader.new(tarball[:tempfile])
91
93
  tar = Gem::Package::TarReader.new(gzip)
92
- metadata = nil
93
94
 
94
95
  tar.each do |entry|
95
- if entry.full_name =~ /metadata\.rb$/
96
- metadata = entry.read
97
- break
96
+ if entry.full_name =~ /metadata\.json$/
97
+ return Metadata.from_json(entry.read)
98
+ elsif entry.full_name =~ /metadata\.rb$/
99
+ return Metadata.from_ruby(entry.read)
98
100
  end
99
101
  end
102
+ ensure
100
103
  tar.close
101
-
102
- return metadata
103
104
  end
104
105
 
105
106
  end
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module CommunityZero
19
- VERSION = '2.0.1'
19
+ VERSION = '2.0.2'
20
20
  end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: community-zero
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Vargo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-28 00:00:00.000000000 Z
11
+ date: 2014-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: cucumber
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json_spec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: Self-contained, easy-setup, fast-start in-memory Chef Community Site
@@ -120,17 +120,17 @@ require_paths:
120
120
  - lib
121
121
  required_ruby_version: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - '>='
123
+ - - ">="
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  requirements:
128
- - - '>='
128
+ - - ">="
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
131
  requirements: []
132
132
  rubyforge_project:
133
- rubygems_version: 2.2.0
133
+ rubygems_version: 2.3.0
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: Self-contained, easy-setup, fast-start in-memory Chef Community Site for