publish2 1.0.0.alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YThlOTRlMGJmMjJiYWFlNTc0YjdmMjY5OWQ0NmI4MGVjMzhiNmUzZA==
5
+ data.tar.gz: !binary |-
6
+ N2E2YjEwZGE3MjhlMmY4NGUxMGVmYWU4MGY0NDQ3N2M3NTY2Y2FjMQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YzAyZTgwYWFkZmZiY2M4NzFlMDI2NmQ1ZTIyY2U0NjcwOGU2ZjIyZTUxMWY3
10
+ ZTZjZTc2OWJiY2U4ODg3ZTZmZGJhYThlYWQ5YjAwNzEwMDNiNTBiMmNhZDQ5
11
+ YzA4Mzc0ZTcyOThmZDhkNWJmZTM0ZTkzYjJjZTM3OTk3ZWRkMjQ=
12
+ data.tar.gz: !binary |-
13
+ NDQyNDIwZGQwZTg1MjRkY2I1YWNmMjcyNzZkMTFhYTg3YzkxYjM0NDg5ZjZl
14
+ MTRiODNkYWJlNjBlMDY0MDViMzZlNmQ4ZDczYTc5ZDE2NjJiMTA0NzI5OGU4
15
+ M2M3YzQ2NDcwYzQyMDI3OTliYmJhODhmNDE4MWFjZmY2MGM2MDA=
data/lib/publish2.rb ADDED
@@ -0,0 +1,4 @@
1
+
2
+ require 'publish2/namers'
3
+ require 'publish2/backends'
4
+ require 'publish2/publisher'
@@ -0,0 +1,3 @@
1
+
2
+ module Publish2
3
+ end
@@ -0,0 +1,2 @@
1
+
2
+ require_relative 'backends/folder'
@@ -0,0 +1,4 @@
1
+ require_relative '../__module__'
2
+
3
+ module Publish2::Backends
4
+ end
@@ -0,0 +1,17 @@
1
+ require_relative '__module__'
2
+
3
+ module Publish2::Backends
4
+
5
+ class Backend
6
+
7
+ def type
8
+ self.class.name
9
+ end
10
+
11
+ def publish(name, src_path)
12
+ raise NotImplementedError
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,33 @@
1
+ require_relative '__module__'
2
+
3
+ require_relative 'base'
4
+
5
+ require 'fileutils'
6
+
7
+ module Publish2::Backends
8
+
9
+ # Just stashes the data into a folder.
10
+ class Folder < Backend
11
+
12
+ attr_reader :root_path
13
+
14
+ def initialize(options = {})
15
+ unless options.is_a? Hash
16
+ options = {root_path: options}
17
+ end
18
+
19
+ @root_path = options.fetch(:root_path)
20
+ end
21
+
22
+
23
+ def publish(name, src_path)
24
+ FileUtils.mkdir_p root_path
25
+
26
+ dest_path = File.join(root_path, name)
27
+ FileUtils.cp src_path, dest_path
28
+ return dest_path
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,2 @@
1
+
2
+ require_relative 'namers/uuid'
@@ -0,0 +1,4 @@
1
+ require_relative '../__module__'
2
+
3
+ module Publish2::Namers
4
+ end
@@ -0,0 +1,15 @@
1
+ require_relative '__module__'
2
+
3
+ require 'securerandom'
4
+
5
+ module Publish2::Namers
6
+
7
+ module UUID
8
+
9
+ def self.name_for(path)
10
+ SecureRandom.uuid + File.extname(path)
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,28 @@
1
+ require_relative '__module__'
2
+
3
+ require_relative 'namers/uuid'
4
+
5
+ module Publish2
6
+
7
+ class Publisher
8
+
9
+ attr_reader :namer, :backend
10
+
11
+ def initialize(options = {})
12
+ @namer = options.fetch(:namer, ::Publish2::Namers::UUID)
13
+ @backend = options.fetch(:backend)
14
+ end
15
+
16
+ def publish(src_path)
17
+ name = namer.name_for(src_path)
18
+
19
+ return {
20
+ type: backend.type,
21
+ locator: backend.publish(name, src_path)
22
+ }
23
+
24
+ end
25
+
26
+ end
27
+
28
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: publish2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.alpha.1
5
+ platform: ruby
6
+ authors:
7
+ - Brian Lauber
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-20 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Generic API for storing data
14
+ email: constructible.truth@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/publish2.rb
20
+ - lib/publish2/__module__.rb
21
+ - lib/publish2/backends.rb
22
+ - lib/publish2/backends/__module__.rb
23
+ - lib/publish2/backends/base.rb
24
+ - lib/publish2/backends/folder.rb
25
+ - lib/publish2/namers.rb
26
+ - lib/publish2/namers/__module__.rb
27
+ - lib/publish2/namers/uuid.rb
28
+ - lib/publish2/publisher.rb
29
+ homepage: https://github.com/briandamaged/publish2
30
+ licenses:
31
+ - MIT
32
+ metadata: {}
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ! '>'
45
+ - !ruby/object:Gem::Version
46
+ version: 1.3.1
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 2.4.6
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: Generic API for storing data
53
+ test_files: []