chef-zero 14.0.13 → 14.0.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -6
  3. data/Rakefile +9 -1
  4. data/chef-zero.gemspec +1 -4
  5. data/lib/chef_zero.rb +1 -1
  6. data/lib/chef_zero/chef_data/cookbook_data.rb +1 -1
  7. data/lib/chef_zero/chef_data/data_normalizer.rb +9 -7
  8. data/lib/chef_zero/chef_data/default_creator.rb +8 -5
  9. data/lib/chef_zero/data_store/data_already_exists_error.rb +1 -1
  10. data/lib/chef_zero/data_store/data_error.rb +1 -1
  11. data/lib/chef_zero/data_store/data_not_found_error.rb +1 -1
  12. data/lib/chef_zero/data_store/default_facade.rb +4 -4
  13. data/lib/chef_zero/data_store/interface_v2.rb +1 -1
  14. data/lib/chef_zero/data_store/memory_store.rb +3 -3
  15. data/lib/chef_zero/data_store/memory_store_v2.rb +22 -14
  16. data/lib/chef_zero/data_store/raw_file_store.rb +6 -4
  17. data/lib/chef_zero/data_store/v1_to_v2_adapter.rb +11 -1
  18. data/lib/chef_zero/data_store/v2_to_v1_adapter.rb +1 -1
  19. data/lib/chef_zero/endpoints/acl_endpoint.rb +3 -2
  20. data/lib/chef_zero/endpoints/acls_endpoint.rb +5 -4
  21. data/lib/chef_zero/endpoints/actor_default_key_endpoint.rb +2 -1
  22. data/lib/chef_zero/endpoints/actor_endpoint.rb +3 -3
  23. data/lib/chef_zero/endpoints/actor_key_endpoint.rb +1 -1
  24. data/lib/chef_zero/endpoints/actor_keys_endpoint.rb +3 -2
  25. data/lib/chef_zero/endpoints/actors_endpoint.rb +1 -1
  26. data/lib/chef_zero/endpoints/authenticate_user_endpoint.rb +2 -1
  27. data/lib/chef_zero/endpoints/container_endpoint.rb +2 -2
  28. data/lib/chef_zero/endpoints/containers_endpoint.rb +2 -2
  29. data/lib/chef_zero/endpoints/controls_endpoint.rb +1 -1
  30. data/lib/chef_zero/endpoints/cookbook_artifact_endpoint.rb +1 -1
  31. data/lib/chef_zero/endpoints/cookbook_artifact_identifier_endpoint.rb +3 -3
  32. data/lib/chef_zero/endpoints/cookbook_artifacts_endpoint.rb +1 -1
  33. data/lib/chef_zero/endpoints/cookbook_endpoint.rb +1 -1
  34. data/lib/chef_zero/endpoints/cookbook_version_endpoint.rb +7 -5
  35. data/lib/chef_zero/endpoints/cookbooks_base.rb +4 -2
  36. data/lib/chef_zero/endpoints/cookbooks_endpoint.rb +1 -1
  37. data/lib/chef_zero/endpoints/data_bag_endpoint.rb +3 -3
  38. data/lib/chef_zero/endpoints/data_bag_item_endpoint.rb +3 -3
  39. data/lib/chef_zero/endpoints/data_bags_endpoint.rb +2 -2
  40. data/lib/chef_zero/endpoints/environment_cookbook_endpoint.rb +1 -1
  41. data/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb +13 -10
  42. data/lib/chef_zero/endpoints/environment_cookbooks_endpoint.rb +1 -1
  43. data/lib/chef_zero/endpoints/environment_endpoint.rb +2 -2
  44. data/lib/chef_zero/endpoints/environment_nodes_endpoint.rb +1 -1
  45. data/lib/chef_zero/endpoints/environment_recipes_endpoint.rb +1 -1
  46. data/lib/chef_zero/endpoints/environment_role_endpoint.rb +1 -1
  47. data/lib/chef_zero/endpoints/file_store_file_endpoint.rb +1 -1
  48. data/lib/chef_zero/endpoints/group_endpoint.rb +2 -2
  49. data/lib/chef_zero/endpoints/groups_endpoint.rb +1 -1
  50. data/lib/chef_zero/endpoints/license_endpoint.rb +1 -1
  51. data/lib/chef_zero/endpoints/node_endpoint.rb +2 -2
  52. data/lib/chef_zero/endpoints/node_identifiers_endpoint.rb +1 -1
  53. data/lib/chef_zero/endpoints/nodes_endpoint.rb +2 -2
  54. data/lib/chef_zero/endpoints/not_found_endpoint.rb +1 -1
  55. data/lib/chef_zero/endpoints/organization_association_request_endpoint.rb +2 -1
  56. data/lib/chef_zero/endpoints/organization_association_requests_endpoint.rb +1 -1
  57. data/lib/chef_zero/endpoints/organization_authenticate_user_endpoint.rb +1 -1
  58. data/lib/chef_zero/endpoints/organization_endpoint.rb +3 -2
  59. data/lib/chef_zero/endpoints/organization_user_base.rb +1 -1
  60. data/lib/chef_zero/endpoints/organization_user_default_key_endpoint.rb +1 -1
  61. data/lib/chef_zero/endpoints/organization_user_endpoint.rb +1 -1
  62. data/lib/chef_zero/endpoints/organization_user_key_endpoint.rb +2 -2
  63. data/lib/chef_zero/endpoints/organization_user_keys_endpoint.rb +1 -1
  64. data/lib/chef_zero/endpoints/organization_users_endpoint.rb +2 -2
  65. data/lib/chef_zero/endpoints/organization_validator_key_endpoint.rb +1 -1
  66. data/lib/chef_zero/endpoints/organizations_endpoint.rb +1 -1
  67. data/lib/chef_zero/endpoints/policies_endpoint.rb +1 -1
  68. data/lib/chef_zero/endpoints/policy_endpoint.rb +1 -1
  69. data/lib/chef_zero/endpoints/policy_group_endpoint.rb +2 -2
  70. data/lib/chef_zero/endpoints/policy_group_policy_endpoint.rb +3 -3
  71. data/lib/chef_zero/endpoints/policy_groups_endpoint.rb +2 -2
  72. data/lib/chef_zero/endpoints/policy_revision_endpoint.rb +1 -1
  73. data/lib/chef_zero/endpoints/policy_revisions_endpoint.rb +1 -1
  74. data/lib/chef_zero/endpoints/principal_endpoint.rb +2 -2
  75. data/lib/chef_zero/endpoints/rest_list_endpoint.rb +2 -2
  76. data/lib/chef_zero/endpoints/rest_object_endpoint.rb +3 -2
  77. data/lib/chef_zero/endpoints/role_endpoint.rb +2 -2
  78. data/lib/chef_zero/endpoints/role_environments_endpoint.rb +1 -1
  79. data/lib/chef_zero/endpoints/sandbox_endpoint.rb +3 -3
  80. data/lib/chef_zero/endpoints/sandboxes_endpoint.rb +1 -1
  81. data/lib/chef_zero/endpoints/search_endpoint.rb +8 -8
  82. data/lib/chef_zero/endpoints/searches_endpoint.rb +1 -1
  83. data/lib/chef_zero/endpoints/server_api_version_endpoint.rb +1 -1
  84. data/lib/chef_zero/endpoints/system_recovery_endpoint.rb +3 -3
  85. data/lib/chef_zero/endpoints/universe_endpoint.rb +2 -2
  86. data/lib/chef_zero/endpoints/user_association_request_endpoint.rb +2 -1
  87. data/lib/chef_zero/endpoints/user_association_requests_count_endpoint.rb +1 -1
  88. data/lib/chef_zero/endpoints/user_association_requests_endpoint.rb +1 -1
  89. data/lib/chef_zero/endpoints/user_organizations_endpoint.rb +1 -1
  90. data/lib/chef_zero/endpoints/version_endpoint.rb +2 -2
  91. data/lib/chef_zero/rest_base.rb +15 -15
  92. data/lib/chef_zero/rest_request.rb +4 -4
  93. data/lib/chef_zero/rest_router.rb +2 -2
  94. data/lib/chef_zero/rspec.rb +3 -2
  95. data/lib/chef_zero/server.rb +87 -83
  96. data/lib/chef_zero/socketless_server_map.rb +2 -1
  97. data/lib/chef_zero/solr/query/phrase.rb +2 -2
  98. data/lib/chef_zero/solr/query/range_query.rb +3 -3
  99. data/lib/chef_zero/solr/query/term.rb +1 -1
  100. data/lib/chef_zero/solr/solr_parser.rb +12 -10
  101. data/lib/chef_zero/version.rb +1 -1
  102. data/spec/run_oc_pedant.rb +5 -3
  103. data/spec/search_spec.rb +2 -2
  104. data/spec/socketless_server_map_spec.rb +1 -1
  105. data/spec/support/oc_pedant.rb +1 -1
  106. metadata +3 -31
@@ -1,7 +1,7 @@
1
- require "chef_zero/rest_request"
2
- require "chef_zero/rest_error_response"
3
- require "chef_zero/data_store/data_not_found_error"
4
- require "chef_zero/chef_data/acl_path"
1
+ require_relative "rest_request"
2
+ require_relative "rest_error_response"
3
+ require_relative "data_store/data_not_found_error"
4
+ require_relative "chef_data/acl_path"
5
5
 
6
6
  module ChefZero
7
7
  class RestBase
@@ -30,15 +30,13 @@ module ChefZero
30
30
  }
31
31
 
32
32
  return json_response(406,
33
- response,
34
- request_version: version, response_version: -1
35
- )
33
+ response,
34
+ request_version: version, response_version: -1)
36
35
  end
37
36
  rescue ArgumentError
38
37
  json_response(406,
39
- { "username" => request.requestor },
40
- request_version: -1, response_version: -1
41
- )
38
+ { "username" => request.requestor },
39
+ request_version: -1, response_version: -1)
42
40
  end
43
41
 
44
42
  def call(request)
@@ -46,14 +44,15 @@ module ChefZero
46
44
  return response unless response.nil?
47
45
 
48
46
  method = request.method.downcase.to_sym
49
- if !respond_to?(method)
50
- accept_methods = [:get, :put, :post, :delete].select { |m| respond_to?(m) }
47
+ unless respond_to?(method)
48
+ accept_methods = %i{get put post delete}.select { |m| respond_to?(m) }
51
49
  accept_methods_str = accept_methods.map { |m| m.to_s.upcase }.join(", ")
52
- return [405, { "Content-Type" => "text/plain", "Allow" => accept_methods_str }, "Bad request method for '#{request.env['REQUEST_PATH']}': #{request.env['REQUEST_METHOD']}"]
50
+ return [405, { "Content-Type" => "text/plain", "Allow" => accept_methods_str }, "Bad request method for '#{request.env["REQUEST_PATH"]}': #{request.env["REQUEST_METHOD"]}"]
53
51
  end
54
52
  if json_only && !accepts?(request, "application", "json")
55
53
  return [406, { "Content-Type" => "text/plain" }, "Must accept application/json"]
56
54
  end
55
+
57
56
  # Dispatch to get()/post()/put()/delete()
58
57
  begin
59
58
  send(method, request)
@@ -70,7 +69,8 @@ module ChefZero
70
69
  def accepts?(request, category, type)
71
70
  # If HTTP_ACCEPT is not sent at all, assume it accepts anything
72
71
  # This parses as per http://tools.ietf.org/html/rfc7231#section-5.3
73
- return true if !request.env["HTTP_ACCEPT"]
72
+ return true unless request.env["HTTP_ACCEPT"]
73
+
74
74
  accepts = request.env["HTTP_ACCEPT"].split(/,\s*/).map { |x| x.split(";", 2)[0].strip }
75
75
  accepts.include?("#{category}/#{type}") || accepts.include?("#{category}/*") || accepts.include?("*/*")
76
76
  end
@@ -284,7 +284,7 @@ module ChefZero
284
284
  end
285
285
 
286
286
  def self.build_uri(base_uri, rest_path)
287
- "#{base_uri}/#{rest_path.map { |v| URI.escape(v) }.join('/')}"
287
+ "#{base_uri}/#{rest_path.map { |v| URI.escape(v) }.join("/")}"
288
288
  end
289
289
 
290
290
  def populate_defaults(request, response)
@@ -18,7 +18,7 @@ module ChefZero
18
18
  else
19
19
  scheme = env["rack.url_scheme"]
20
20
  end
21
- @base_uri ||= "#{scheme}://#{env['HTTP_HOST']}#{env['SCRIPT_NAME']}"
21
+ @base_uri ||= "#{scheme}://#{env["HTTP_HOST"]}#{env["SCRIPT_NAME"]}"
22
22
  end
23
23
 
24
24
  def base_uri=(value)
@@ -68,14 +68,14 @@ module ChefZero
68
68
  end
69
69
 
70
70
  def to_s
71
- result = "#{method} #{rest_path.join('/')}"
71
+ result = "#{method} #{rest_path.join("/")}"
72
72
  if query_params.size > 0
73
- result << "?#{query_params.map { |k, v| "#{k}=#{v}" }.join('&')}"
73
+ result << "?#{query_params.map { |k, v| "#{k}=#{v}" }.join("&")}"
74
74
  end
75
75
  if body.chomp != ""
76
76
  result << "\n--- #{method} BODY ---\n"
77
77
  result << body
78
- result << "\n" if !body.end_with?("\n")
78
+ result << "\n" unless body.end_with?("\n")
79
79
  result << "--- END #{method} BODY ---"
80
80
  end
81
81
  result
@@ -5,9 +5,9 @@ module ChefZero
5
5
  def initialize(routes)
6
6
  @routes = routes.map do |route, endpoint|
7
7
  if route =~ /\*\*$/
8
- pattern = Regexp.new("^#{route[0..-3].gsub('*', '[^/]*')}")
8
+ pattern = Regexp.new("^#{route[0..-3].gsub("*", "[^/]*")}")
9
9
  else
10
- pattern = Regexp.new("^#{route.gsub('*', '[^/]*')}$")
10
+ pattern = Regexp.new("^#{route.gsub("*", "[^/]*")}$")
11
11
  end
12
12
  [ pattern, endpoint ]
13
13
  end
@@ -1,6 +1,6 @@
1
1
  require "tempfile"
2
- require "chef_zero/server"
3
- require "chef_zero/rest_request"
2
+ require_relative "server"
3
+ require_relative "rest_request"
4
4
 
5
5
  module ChefZero
6
6
  module RSpec
@@ -69,6 +69,7 @@ module ChefZero
69
69
  if chef_server_options[:server_scope] != self.class.chef_server_options[:server_scope]
70
70
  raise "server_scope: #{chef_server_options[:server_scope]} will not be honored: it can only be set on when_the_chef_server!"
71
71
  end
72
+
72
73
  Log.info("Starting #{ChefZero::Dist::PRODUCT} server with options #{chef_server_options}")
73
74
 
74
75
  ChefZero::RSpec.set_server_options(chef_server_options)
@@ -26,87 +26,87 @@ require "rack"
26
26
  require "webrick"
27
27
  require "webrick/https"
28
28
 
29
- require "chef_zero"
30
- require "chef_zero/socketless_server_map"
31
- require "chef_zero/chef_data/cookbook_data"
32
- require "chef_zero/chef_data/acl_path"
33
- require "chef_zero/rest_router"
34
- require "chef_zero/data_store/memory_store_v2"
35
- require "chef_zero/data_store/v1_to_v2_adapter"
36
- require "chef_zero/data_store/default_facade"
37
- require "chef_zero/version"
29
+ require_relative "../chef_zero"
30
+ require_relative "socketless_server_map"
31
+ require_relative "chef_data/cookbook_data"
32
+ require_relative "chef_data/acl_path"
33
+ require_relative "rest_router"
34
+ require_relative "data_store/memory_store_v2"
35
+ require_relative "data_store/v1_to_v2_adapter"
36
+ require_relative "data_store/default_facade"
37
+ require_relative "version"
38
38
  require "chef_zero/dist.rb"
39
39
 
40
- require "chef_zero/endpoints/rest_list_endpoint"
41
- require "chef_zero/endpoints/authenticate_user_endpoint"
42
- require "chef_zero/endpoints/acls_endpoint"
43
- require "chef_zero/endpoints/acl_endpoint"
44
- require "chef_zero/endpoints/actor_endpoint"
45
- require "chef_zero/endpoints/actors_endpoint"
46
- require "chef_zero/endpoints/actor_key_endpoint"
47
- require "chef_zero/endpoints/organization_user_key_endpoint"
48
- require "chef_zero/endpoints/organization_user_default_key_endpoint"
49
- require "chef_zero/endpoints/organization_user_keys_endpoint"
50
- require "chef_zero/endpoints/actor_default_key_endpoint"
51
- require "chef_zero/endpoints/actor_keys_endpoint"
52
- require "chef_zero/endpoints/cookbooks_endpoint"
53
- require "chef_zero/endpoints/cookbook_endpoint"
54
- require "chef_zero/endpoints/cookbook_version_endpoint"
55
- require "chef_zero/endpoints/cookbook_artifacts_endpoint"
56
- require "chef_zero/endpoints/cookbook_artifact_endpoint"
57
- require "chef_zero/endpoints/cookbook_artifact_identifier_endpoint"
58
- require "chef_zero/endpoints/containers_endpoint"
59
- require "chef_zero/endpoints/container_endpoint"
60
- require "chef_zero/endpoints/controls_endpoint"
61
- require "chef_zero/endpoints/dummy_endpoint"
62
- require "chef_zero/endpoints/data_bags_endpoint"
63
- require "chef_zero/endpoints/data_bag_endpoint"
64
- require "chef_zero/endpoints/data_bag_item_endpoint"
65
- require "chef_zero/endpoints/groups_endpoint"
66
- require "chef_zero/endpoints/group_endpoint"
67
- require "chef_zero/endpoints/environment_endpoint"
68
- require "chef_zero/endpoints/environment_cookbooks_endpoint"
69
- require "chef_zero/endpoints/environment_cookbook_endpoint"
70
- require "chef_zero/endpoints/environment_cookbook_versions_endpoint"
71
- require "chef_zero/endpoints/environment_nodes_endpoint"
72
- require "chef_zero/endpoints/environment_recipes_endpoint"
73
- require "chef_zero/endpoints/environment_role_endpoint"
74
- require "chef_zero/endpoints/license_endpoint"
75
- require "chef_zero/endpoints/node_endpoint"
76
- require "chef_zero/endpoints/nodes_endpoint"
77
- require "chef_zero/endpoints/node_identifiers_endpoint"
78
- require "chef_zero/endpoints/organizations_endpoint"
79
- require "chef_zero/endpoints/organization_endpoint"
80
- require "chef_zero/endpoints/organization_association_requests_endpoint"
81
- require "chef_zero/endpoints/organization_association_request_endpoint"
82
- require "chef_zero/endpoints/organization_authenticate_user_endpoint"
83
- require "chef_zero/endpoints/organization_users_endpoint"
84
- require "chef_zero/endpoints/organization_user_endpoint"
85
- require "chef_zero/endpoints/organization_validator_key_endpoint"
86
- require "chef_zero/endpoints/policies_endpoint"
87
- require "chef_zero/endpoints/policy_endpoint"
88
- require "chef_zero/endpoints/policy_revisions_endpoint"
89
- require "chef_zero/endpoints/policy_revision_endpoint"
90
- require "chef_zero/endpoints/policy_groups_endpoint"
91
- require "chef_zero/endpoints/policy_group_endpoint"
92
- require "chef_zero/endpoints/policy_group_policy_endpoint"
93
- require "chef_zero/endpoints/principal_endpoint"
94
- require "chef_zero/endpoints/role_endpoint"
95
- require "chef_zero/endpoints/role_environments_endpoint"
96
- require "chef_zero/endpoints/sandboxes_endpoint"
97
- require "chef_zero/endpoints/sandbox_endpoint"
98
- require "chef_zero/endpoints/searches_endpoint"
99
- require "chef_zero/endpoints/search_endpoint"
100
- require "chef_zero/endpoints/system_recovery_endpoint"
101
- require "chef_zero/endpoints/user_association_requests_endpoint"
102
- require "chef_zero/endpoints/user_association_requests_count_endpoint"
103
- require "chef_zero/endpoints/user_association_request_endpoint"
104
- require "chef_zero/endpoints/user_organizations_endpoint"
105
- require "chef_zero/endpoints/file_store_file_endpoint"
106
- require "chef_zero/endpoints/not_found_endpoint"
107
- require "chef_zero/endpoints/version_endpoint"
108
- require "chef_zero/endpoints/server_api_version_endpoint"
109
- require "chef_zero/endpoints/universe_endpoint"
40
+ require_relative "endpoints/rest_list_endpoint"
41
+ require_relative "endpoints/authenticate_user_endpoint"
42
+ require_relative "endpoints/acls_endpoint"
43
+ require_relative "endpoints/acl_endpoint"
44
+ require_relative "endpoints/actor_endpoint"
45
+ require_relative "endpoints/actors_endpoint"
46
+ require_relative "endpoints/actor_key_endpoint"
47
+ require_relative "endpoints/organization_user_key_endpoint"
48
+ require_relative "endpoints/organization_user_default_key_endpoint"
49
+ require_relative "endpoints/organization_user_keys_endpoint"
50
+ require_relative "endpoints/actor_default_key_endpoint"
51
+ require_relative "endpoints/actor_keys_endpoint"
52
+ require_relative "endpoints/cookbooks_endpoint"
53
+ require_relative "endpoints/cookbook_endpoint"
54
+ require_relative "endpoints/cookbook_version_endpoint"
55
+ require_relative "endpoints/cookbook_artifacts_endpoint"
56
+ require_relative "endpoints/cookbook_artifact_endpoint"
57
+ require_relative "endpoints/cookbook_artifact_identifier_endpoint"
58
+ require_relative "endpoints/containers_endpoint"
59
+ require_relative "endpoints/container_endpoint"
60
+ require_relative "endpoints/controls_endpoint"
61
+ require_relative "endpoints/dummy_endpoint"
62
+ require_relative "endpoints/data_bags_endpoint"
63
+ require_relative "endpoints/data_bag_endpoint"
64
+ require_relative "endpoints/data_bag_item_endpoint"
65
+ require_relative "endpoints/groups_endpoint"
66
+ require_relative "endpoints/group_endpoint"
67
+ require_relative "endpoints/environment_endpoint"
68
+ require_relative "endpoints/environment_cookbooks_endpoint"
69
+ require_relative "endpoints/environment_cookbook_endpoint"
70
+ require_relative "endpoints/environment_cookbook_versions_endpoint"
71
+ require_relative "endpoints/environment_nodes_endpoint"
72
+ require_relative "endpoints/environment_recipes_endpoint"
73
+ require_relative "endpoints/environment_role_endpoint"
74
+ require_relative "endpoints/license_endpoint"
75
+ require_relative "endpoints/node_endpoint"
76
+ require_relative "endpoints/nodes_endpoint"
77
+ require_relative "endpoints/node_identifiers_endpoint"
78
+ require_relative "endpoints/organizations_endpoint"
79
+ require_relative "endpoints/organization_endpoint"
80
+ require_relative "endpoints/organization_association_requests_endpoint"
81
+ require_relative "endpoints/organization_association_request_endpoint"
82
+ require_relative "endpoints/organization_authenticate_user_endpoint"
83
+ require_relative "endpoints/organization_users_endpoint"
84
+ require_relative "endpoints/organization_user_endpoint"
85
+ require_relative "endpoints/organization_validator_key_endpoint"
86
+ require_relative "endpoints/policies_endpoint"
87
+ require_relative "endpoints/policy_endpoint"
88
+ require_relative "endpoints/policy_revisions_endpoint"
89
+ require_relative "endpoints/policy_revision_endpoint"
90
+ require_relative "endpoints/policy_groups_endpoint"
91
+ require_relative "endpoints/policy_group_endpoint"
92
+ require_relative "endpoints/policy_group_policy_endpoint"
93
+ require_relative "endpoints/principal_endpoint"
94
+ require_relative "endpoints/role_endpoint"
95
+ require_relative "endpoints/role_environments_endpoint"
96
+ require_relative "endpoints/sandboxes_endpoint"
97
+ require_relative "endpoints/sandbox_endpoint"
98
+ require_relative "endpoints/searches_endpoint"
99
+ require_relative "endpoints/search_endpoint"
100
+ require_relative "endpoints/system_recovery_endpoint"
101
+ require_relative "endpoints/user_association_requests_endpoint"
102
+ require_relative "endpoints/user_association_requests_count_endpoint"
103
+ require_relative "endpoints/user_association_request_endpoint"
104
+ require_relative "endpoints/user_organizations_endpoint"
105
+ require_relative "endpoints/file_store_file_endpoint"
106
+ require_relative "endpoints/not_found_endpoint"
107
+ require_relative "endpoints/version_endpoint"
108
+ require_relative "endpoints/server_api_version_endpoint"
109
+ require_relative "endpoints/universe_endpoint"
110
110
 
111
111
  module ChefZero
112
112
 
@@ -176,7 +176,8 @@ module ChefZero
176
176
  end
177
177
 
178
178
  def local_mode_url
179
- raise "Port not yet set, cannot generate URL" unless port.kind_of?(Integer)
179
+ raise "Port not yet set, cannot generate URL" unless port.is_a?(Integer)
180
+
180
181
  "chefzero://localhost:#{port}"
181
182
  end
182
183
 
@@ -275,7 +276,7 @@ module ChefZero
275
276
  true
276
277
  rescue Errno::EADDRINUSE
277
278
  ChefZero::Log.warn("Port #{port} not available")
278
- @server.listeners.each { |l| l.close }
279
+ @server.listeners.each(&:close)
279
280
  @server.listeners.clear
280
281
  false
281
282
  end
@@ -305,7 +306,7 @@ module ChefZero
305
306
  break
306
307
  end
307
308
  end
308
- if !@port
309
+ unless @port
309
310
  raise Errno::EADDRINUSE,
310
311
  "No port in :port range #{options[:port]} is available"
311
312
  end
@@ -501,11 +502,13 @@ module ChefZero
501
502
  else
502
503
  cookbook_data = ChefData::CookbookData.to_hash(cookbook, name_version)
503
504
  end
504
- raise "No version specified" if !cookbook_data[:version]
505
+ raise "No version specified" unless cookbook_data[:version]
506
+
505
507
  data_store.create_dir(["organizations", org_name, cookbook_type], cookbook_data[:cookbook_name], :recursive)
506
508
  data_store.set(["organizations", org_name, cookbook_type, cookbook_data[:cookbook_name], cookbook_data[:version]], FFI_Yajl::Encoder.encode(cookbook_data, pretty: true), :create)
507
509
  cookbook_data.values.each do |files|
508
510
  next unless files.is_a? Array
511
+
509
512
  files.each do |file|
510
513
  data_store.set(["organizations", org_name, "file_store", "checksums", file[:checksum]], get_file(cookbook, file[:path]), :create)
511
514
  end
@@ -642,6 +645,7 @@ module ChefZero
642
645
 
643
646
  def app
644
647
  return @app if @app
648
+
645
649
  router = RestRouter.new(endpoints)
646
650
  router.not_found = NotFoundEndpoint.new
647
651
 
@@ -18,7 +18,7 @@
18
18
 
19
19
  require "thread"
20
20
  require "singleton"
21
- require "chef_zero/dist"
21
+ require_relative "dist"
22
22
 
23
23
  module ChefZero
24
24
 
@@ -85,6 +85,7 @@ module ChefZero
85
85
  def request(port, request_env)
86
86
  server = @servers_by_port[port]
87
87
  raise ServerNotFound, "No socketless #{ChefZero::Dist::PRODUCT} server on given port #{port.inspect}" unless server
88
+
88
89
  server.handle_socketless_request(request_env)
89
90
  end
90
91
 
@@ -1,4 +1,4 @@
1
- require "chef_zero/solr/query/regexpable_query"
1
+ require_relative "regexpable_query"
2
2
 
3
3
  module ChefZero
4
4
  module Solr
@@ -11,7 +11,7 @@ module ChefZero
11
11
  else
12
12
  literal_string = nil
13
13
  end
14
- super(terms.map { |term| term.regexp_string }.join("#{NON_WORD_CHARACTER}+"), literal_string)
14
+ super(terms.map(&:regexp_string).join("#{NON_WORD_CHARACTER}+"), literal_string)
15
15
  end
16
16
 
17
17
  def to_s
@@ -10,7 +10,7 @@ module ChefZero
10
10
  end
11
11
 
12
12
  def to_s
13
- "#{@from_inclusive ? '[' : '{'}#{@from} TO #{@to}#{@to_inclusive ? ']' : '}'}"
13
+ "#{@from_inclusive ? "[" : "{"}#{@from} TO #{@to}#{@to_inclusive ? "]" : "}"}"
14
14
  end
15
15
 
16
16
  def matches_values?(values)
@@ -20,7 +20,7 @@ module ChefZero
20
20
  when -1
21
21
  return false
22
22
  when 0
23
- return false if !@from_inclusive
23
+ return false unless @from_inclusive
24
24
  end
25
25
  end
26
26
  unless @to == "*"
@@ -28,7 +28,7 @@ module ChefZero
28
28
  when 1
29
29
  return false
30
30
  when 0
31
- return false if !@to_inclusive
31
+ return false unless @to_inclusive
32
32
  end
33
33
  end
34
34
  return true
@@ -1,4 +1,4 @@
1
- require "chef_zero/solr/query/regexpable_query"
1
+ require_relative "regexpable_query"
2
2
 
3
3
  module ChefZero
4
4
  module Solr
@@ -1,9 +1,9 @@
1
- require "chef_zero/solr/query/binary_operator"
2
- require "chef_zero/solr/query/unary_operator"
3
- require "chef_zero/solr/query/term"
4
- require "chef_zero/solr/query/phrase"
5
- require "chef_zero/solr/query/range_query"
6
- require "chef_zero/solr/query/subquery"
1
+ require_relative "query/binary_operator"
2
+ require_relative "query/unary_operator"
3
+ require_relative "query/term"
4
+ require_relative "query/phrase"
5
+ require_relative "query/range_query"
6
+ require_relative "query/subquery"
7
7
 
8
8
  module ChefZero
9
9
  module Solr
@@ -50,7 +50,7 @@ module ChefZero
50
50
  if @query_string[@index] == '\\'
51
51
  @index += 1
52
52
  end
53
- @index += 1 if !eof?
53
+ @index += 1 unless eof?
54
54
  break if eof? || !peek_term_token
55
55
  end
56
56
  @query_string[start_index..@index - 1]
@@ -66,6 +66,7 @@ module ChefZero
66
66
 
67
67
  def peek_term_token
68
68
  return nil if @query_string[@index] =~ /\s/
69
+
69
70
  op = peek_operator_token
70
71
  !op || op == "-"
71
72
  end
@@ -79,6 +80,7 @@ module ChefZero
79
80
  return result
80
81
  end
81
82
  end
83
+
82
84
  nil
83
85
  end
84
86
 
@@ -145,13 +147,13 @@ module ChefZero
145
147
  # If it's the start of a range query, build that
146
148
  elsif token == "{" || token == "["
147
149
  left = next_token
148
- parse_error(left, "Expected left term in range query") if !left
150
+ parse_error(left, "Expected left term in range query") unless left
149
151
  to = next_token
150
152
  parse_error(left, "Expected TO in range query") if to != "TO"
151
153
  right = next_token
152
- parse_error(right, "Expected left term in range query") if !right
154
+ parse_error(right, "Expected left term in range query") unless right
153
155
  end_range = next_token
154
- parse_error(right, "Expected end range '#{end_range}") if !["}", "]"].include?(end_range)
156
+ parse_error(right, "Expected end range '#{end_range}") unless ["}", "]"].include?(end_range)
155
157
  Query::RangeQuery.new(left, right, token == "[", end_range == "]")
156
158
 
157
159
  elsif token == "("