nexus_cli 1.0.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/.gitignore +4 -1
  2. data/.travis.yml +5 -0
  3. data/Gemfile +40 -0
  4. data/Guardfile +27 -0
  5. data/README.md +20 -23
  6. data/Thorfile +66 -0
  7. data/VERSION +1 -1
  8. data/{pro → features/pro}/nexus_custom_metadata.feature +0 -0
  9. data/{pro → features/pro}/nexus_pro.feature +0 -0
  10. data/features/support/env.rb +41 -32
  11. data/lib/nexus_cli.rb +26 -10
  12. data/lib/nexus_cli/base_remote.rb +32 -0
  13. data/lib/nexus_cli/configuration.rb +24 -5
  14. data/lib/nexus_cli/connection.rb +81 -0
  15. data/lib/nexus_cli/mixins/artifact_actions.rb +186 -0
  16. data/lib/nexus_cli/mixins/global_settings_actions.rb +64 -0
  17. data/lib/nexus_cli/mixins/logging_actions.rb +45 -0
  18. data/lib/nexus_cli/{nexus_pro_remote.rb → mixins/pro/custom_metadata_actions.rb} +5 -199
  19. data/lib/nexus_cli/mixins/pro/smart_proxy_actions.rb +214 -0
  20. data/lib/nexus_cli/mixins/repository_actions.rb +245 -0
  21. data/lib/nexus_cli/mixins/user_actions.rb +125 -0
  22. data/lib/nexus_cli/remote/oss_remote.rb +11 -0
  23. data/lib/nexus_cli/remote/pro_remote.rb +59 -0
  24. data/lib/nexus_cli/remote_factory.rb +24 -0
  25. data/lib/nexus_cli/tasks.rb +3 -3
  26. data/spec/fixtures/nexus.config +4 -0
  27. data/spec/spec_helper.rb +14 -2
  28. data/spec/{configuration_spec.rb → unit/nexus_cli/configuration_spec.rb} +0 -0
  29. data/spec/{oss_remote_spec.rb → unit/nexus_cli/oss_remote_spec.rb} +15 -5
  30. data/spec/{pro_remote_spec.rb → unit/nexus_cli/pro_remote_spec.rb} +6 -1
  31. metadata +32 -17
  32. data/Gemfile.lock +0 -65
  33. data/lib/nexus_cli/kernel.rb +0 -33
  34. data/lib/nexus_cli/nexus_oss_remote.rb +0 -636
  35. data/lib/nexus_cli/nexus_remote_factory.rb +0 -65
@@ -1,65 +0,0 @@
1
- require 'httpclient'
2
- require 'nokogiri'
3
- require 'yaml'
4
-
5
- module NexusCli
6
- class Factory
7
- class << self
8
- def create(overrides, ssl_verify=true)
9
- @configuration = Configuration::parse(overrides)
10
- @ssl_verify = ssl_verify
11
- running_nexus_pro? ? ProRemote.new(overrides, ssl_verify) : OSSRemote.new(overrides, ssl_verify)
12
- end
13
-
14
- def configuration
15
- return @configuration if @configuration
16
- end
17
-
18
- def nexus
19
- client = HTTPClient.new
20
- # https://github.com/nahi/httpclient/issues/63
21
- client.set_auth(nil, configuration['username'], configuration['password'])
22
- client.www_auth.basic_auth.challenge(configuration['url'])
23
- client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @ssl_verify
24
- return client
25
- end
26
-
27
- def nexus_url(url)
28
- File.join(configuration['url'], url)
29
- end
30
-
31
- def status
32
- begin
33
- response = nexus.get(nexus_url("service/local/status"))
34
- rescue OpenSSL::SSL::SSLError => e
35
- raise SSLException
36
- end
37
-
38
- case response.status
39
- when 200
40
- doc = Nokogiri::XML(response.content).xpath("/status/data")
41
- data = Hash.new
42
- data['app_name'] = doc.xpath("appName")[0].text
43
- data['version'] = doc.xpath("version")[0].text
44
- data['edition_long'] = doc.xpath("editionLong")[0].text
45
- data['state'] = doc.xpath("state")[0].text
46
- data['started_at'] = doc.xpath("startedAt")[0].text
47
- data['base_url'] = doc.xpath("baseUrl")[0].text
48
- return data
49
- when 401
50
- raise PermissionsException
51
- when 503
52
- raise CouldNotConnectToNexusException
53
- else
54
- raise UnexpectedStatusCodeException.new(response.status)
55
- end
56
- end
57
-
58
- private
59
-
60
- def running_nexus_pro?
61
- return status['edition_long'] == "Professional" ? true : false
62
- end
63
- end
64
- end
65
- end