fog-artifactory 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fefced9410731434feab9ba2f07d5accf136d8fc
4
+ data.tar.gz: db5eda5f8773c96f9e16e2bca555a6949468c7c5
5
+ SHA512:
6
+ metadata.gz: 6328ac7261c84ee53bc7aa69238c923dec0f8b5b6539d55c058c587d2fe7cde6ee940bdd24051eb064b1114efc2df17f7087df28fe97638a53e87ca7dc95bebd
7
+ data.tar.gz: 205676729e870f226e01f352d0e0bc95b5804ec5f39ce448c112d66eb175c9577f633c72da81fddeb5cf517b3ecec8baecb0ebff7ff3ef50bd4255e199480c3b
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ tests/.fog
16
+ gemfiles/Gemfile-edge.lock
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
File without changes
File without changes
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.13.6
@@ -0,0 +1 @@
1
+ # Change Log
@@ -0,0 +1,18 @@
1
+ ## Getting Involved
2
+
3
+ New contributors are always welcome, when it doubt please ask questions. We strive to be an open and welcoming community. Please be nice to one another.
4
+
5
+ ### Coding
6
+
7
+ * Pick a task:
8
+ * Offer feedback on open [pull requests](https://github.com/fog/fog/pulls).
9
+ * Review open [issues](https://github.com/fog/fog/issues) for things to help on.
10
+ * [Create an issue](https://github.com/fog/fog/issues/new) to start a discussion on additions or features.
11
+ * Fork the project, add your changes and tests to cover them in a topic branch.
12
+ * Commit your changes and rebase against `fog/fog` to ensure everything is up to date.
13
+ * [Submit a pull request](https://github.com/fog/fog/compare/).
14
+
15
+ ### Non-Coding
16
+
17
+ * Offer feedback on open [issues](https://github.com/fog/fog/issues).
18
+ * Organize or volunteer at events.
@@ -0,0 +1 @@
1
+ * Dmitry Zuev <mail@dzuev.ru>
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fog-artifactory.gemspec
4
+ gemspec
5
+
6
+ group :test, :default do
7
+ gem 'pry-nav'
8
+ gem 'pry-byebug'
9
+ end
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2015 [CONTRIBUTORS.md](https://github.com/dmitryzuev/fog-artifactory/blob/master/CONTRIBUTORS.md)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,36 @@
1
+ # Fog::Artifactory
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/fog/artifactory`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'fog-artifactory'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install fog-artifactory
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fog-artifactory. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "fog/artifactory"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fog/artifactory/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'fog-artifactory'
8
+ spec.version = Fog::Artifactory::VERSION
9
+ spec.authors = ['Dmitry Zuev']
10
+ spec.email = ['d.zuev@rambler-co.ru']
11
+
12
+ spec.summary = "Module for the 'fog' gem to support JFrog Artifactory."
13
+ spec.description = "This library can be used as a module for `fog` or as standalone provider
14
+ to use the JFrog Artifactory in applications."
15
+ spec.homepage = 'https://github.com/dmitryzuev/fog-artifactory'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.bindir = 'bin'
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.13'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.0'
27
+
28
+ spec.add_dependency 'fog-core', '~> 1.43'
29
+ spec.add_dependency 'fog-json', '~> 1.0'
30
+ spec.add_dependency 'artifactory', '~> 2.8'
31
+ end
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'fog-core', github: 'fog/fog-core'
4
+ gem 'fog-json', github: 'fog/fog-json'
5
+
6
+ gemspec path: '../'
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '../'
@@ -0,0 +1,16 @@
1
+ require 'fog/core'
2
+ require 'fog/json'
3
+ require 'fog/artifactory/version'
4
+ require 'artifactory'
5
+
6
+ module Fog
7
+ module Storage
8
+ autoload :Artifactory, File.expand_path('../artifactory/storage', __FILE__)
9
+ end
10
+
11
+ module Artifactory
12
+ extend Fog::Provider
13
+
14
+ service(:storage, 'Storage')
15
+ end
16
+ end
@@ -0,0 +1,24 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/artifactory/models/storage/directory'
3
+
4
+ module Fog
5
+ module Storage
6
+ class Artifactory
7
+ class Directories < Fog::Collection
8
+ model Fog::Storage::Artifactory::Directory
9
+
10
+ def all
11
+ data = service.client.get('/api/repositories')
12
+ load(data)
13
+ end
14
+
15
+ def get(key, _options = {})
16
+ data = service.client.get("/api/repositories/#{key}")
17
+ new(key: data['key'])
18
+ rescue Artifactory::Error::HTTPError => _e
19
+ nil
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,28 @@
1
+ require 'fog/core/model'
2
+ require 'fog/artifactory/models/storage/files'
3
+
4
+ module Fog
5
+ module Storage
6
+ class Artifactory
7
+ class Directory < Fog::Model
8
+ identity :key
9
+
10
+ attribute :description
11
+ attribute :url
12
+
13
+ def destroy
14
+ false
15
+ end
16
+
17
+ def files
18
+ requires :key
19
+ @files ||= Fog::Storage::Artifactory::Files.new(directory: self, service: service)
20
+ end
21
+
22
+ def save
23
+ true
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,64 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Storage
5
+ class Artifactory
6
+ class File < Fog::Model
7
+ identity :key, aliases: 'path'
8
+
9
+ attribute :checksums
10
+ attribute :original_checksums, aliases: 'originalChecksums'
11
+ attribute :created, type: :time
12
+ attribute :created_by, aliases: 'createdBy'
13
+ attribute :download_uri, aliases: 'downloadUri'
14
+ attribute :last_modified, aliases: 'lastModified', type: :time
15
+ attribute :last_updated, aliases: 'lastUpdated', type: :time
16
+ attribute :content_type, aliases: %w(mimeType mime_type)
17
+ attribute :modified_by, aliases: 'modifiedBy'
18
+ attribute :repo
19
+ attribute :content_length, aliases: 'size', type: :integer
20
+ attribute :uri
21
+
22
+ def body
23
+ return attributes[:body] if attributes[:body]
24
+ return '' unless last_modified
25
+ attributes[:body] = service.client.get(download_uri)
26
+ end
27
+
28
+ def body=(new_body)
29
+ attributes[:body] = new_body
30
+ end
31
+
32
+ def directory
33
+ @directory
34
+ end
35
+
36
+ def destroy
37
+ requires :directory, :key
38
+ service.client.delete(attributes[:download_uri])
39
+ true
40
+ rescue Error::HTTPError
41
+ false
42
+ end
43
+
44
+ def save(_options = {})
45
+ requires :body, :directory, :key
46
+ endpoint = ::File.join(attributes[:repo], attributes[:key])
47
+
48
+ service.client.put(endpoint, attributes[:body])
49
+ true
50
+ end
51
+
52
+ def public_url
53
+ requires :directory, :key
54
+ self.download_uri
55
+ end
56
+ alias_method :url, :public_url
57
+
58
+ # def url
59
+ # # TODO: implement
60
+ # end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,40 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/artifactory/models/storage/file'
3
+
4
+ module Fog
5
+ module Storage
6
+ class Artifactory
7
+ class Files < Fog::Collection
8
+ model Fog::Storage::Artifactory::File
9
+
10
+ attribute :directory
11
+
12
+ def all(options = {})
13
+ requires :directory
14
+ options = options.reject { |_key, value| value.nil? || value.to_s.empty? }
15
+ merge_attributes(options)
16
+ load(service.client.get('/api/search/artifact', name: '.*', repos: directory.key)['results'].map do |artifact|
17
+ path = URI.parse(artifact['uri']).path
18
+ endpoint_path = URI.parse(service.client.endpoint).path
19
+ path.slice!(endpoint_path)
20
+ service.client.get(path)
21
+ end)
22
+ end
23
+
24
+ def get(key, _options = {}, &_block)
25
+ requires :directory
26
+ new(service.client.get("/api/storage/#{directory.key}#{key}"))
27
+ end
28
+
29
+ def head(key, options = {})
30
+ # TODO: implement
31
+ end
32
+
33
+ def new(attributes = {})
34
+ requires :directory
35
+ super({ directory: directory }.merge(attributes))
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,37 @@
1
+ module Fog
2
+ module Storage
3
+ class Artifactory < Fog::Service
4
+ autoload :Directories, ::File.expand_path('../models/storage/directories', __FILE__)
5
+ autoload :Directory, ::File.expand_path('../models/storage/directory', __FILE__)
6
+ autoload :File, ::File.expand_path('../models/storage/file', __FILE__)
7
+ autoload :Files, ::File.expand_path('../models/storage/files', __FILE__)
8
+
9
+ requires :endpoint
10
+ recognizes :username, :password, :api_key, :ssl_perm_file, :ssl_verify,
11
+ :proxy_username, :proxy_password, :proxy_address, :proxy_port,
12
+ :host, :port, :scheme, :persistent, :path_style
13
+ secrets :password, :api_key
14
+
15
+ model_path 'fog/artifactory/models/storage'
16
+ collection :directories
17
+ model :directory
18
+ model :file
19
+ collection :files
20
+
21
+ class Mock
22
+ def initialize(options = {})
23
+ end
24
+ end
25
+
26
+ class Real
27
+ def initialize(options = {})
28
+ @artifactory_client = ::Artifactory::Client.new(options)
29
+ end
30
+
31
+ def client
32
+ @artifactory_client
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ module Fog
2
+ module Artifactory
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ describe Fog::Artifactory do
4
+ it "has a version number" do
5
+ expect(Fog::Artifactory::VERSION).not_to be nil
6
+ end
7
+
8
+ it "does something useful" do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
2
+ require "fog/artifactory"
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fog-artifactory
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dmitry Zuev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: fog-core
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.43'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.43'
69
+ - !ruby/object:Gem::Dependency
70
+ name: fog-json
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: artifactory
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.8'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.8'
97
+ description: |-
98
+ This library can be used as a module for `fog` or as standalone provider
99
+ to use the JFrog Artifactory in applications.
100
+ email:
101
+ - d.zuev@rambler-co.ru
102
+ executables:
103
+ - console
104
+ - setup
105
+ extensions: []
106
+ extra_rdoc_files: []
107
+ files:
108
+ - ".gitignore"
109
+ - ".rspec"
110
+ - ".ruby-gemset"
111
+ - ".ruby-version"
112
+ - ".travis.yml"
113
+ - CHANGELOG.md
114
+ - CONTRIBUTING.md
115
+ - CONTRIBUTORS.md
116
+ - Gemfile
117
+ - LICENSE.md
118
+ - README.md
119
+ - Rakefile
120
+ - bin/console
121
+ - bin/setup
122
+ - fog-artifactory.gemspec
123
+ - gemfiles/Gemfile-edge
124
+ - gemfiles/Gemfile-ruby-2.0
125
+ - lib/fog/artifactory.rb
126
+ - lib/fog/artifactory/models/storage/directories.rb
127
+ - lib/fog/artifactory/models/storage/directory.rb
128
+ - lib/fog/artifactory/models/storage/file.rb
129
+ - lib/fog/artifactory/models/storage/files.rb
130
+ - lib/fog/artifactory/storage.rb
131
+ - lib/fog/artifactory/version.rb
132
+ - spec/fog/artifactory_spec.rb
133
+ - spec/spec_helper.rb
134
+ homepage: https://github.com/dmitryzuev/fog-artifactory
135
+ licenses:
136
+ - MIT
137
+ metadata: {}
138
+ post_install_message:
139
+ rdoc_options: []
140
+ require_paths:
141
+ - lib
142
+ required_ruby_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ requirements: []
153
+ rubyforge_project:
154
+ rubygems_version: 2.6.10
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: Module for the 'fog' gem to support JFrog Artifactory.
158
+ test_files:
159
+ - spec/fog/artifactory_spec.rb
160
+ - spec/spec_helper.rb