assets_deployer 0.1.0 → 0.2.0

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: 3a2fbff0dd0f4fdce8796030dd461a21e2a1effa
4
- data.tar.gz: 9ee83f5080b956a53032e594486ab05a999b28b5
3
+ metadata.gz: ed1caa68bb86b53fcf9383ddf0a6590e279fdbb7
4
+ data.tar.gz: 8a1e18f651adec31f4b544d1df683269539c7cc4
5
5
  SHA512:
6
- metadata.gz: 002dd5e527556600c58275694d40914f52ff907502eb160041dbacf2c74ada3853713b9598b1f61e521c8805468b5c5861dec1f96ed3ba30b1c6c74c76ac7e1d
7
- data.tar.gz: 116a41aba91823a3b28b9819f16abebc223d9488e5a350d00cd9222d2be23853f271fefe4c0e7993656ec4f7582036f68bdcf2fa5be9c2a2b3e9c715ef19f1c4
6
+ metadata.gz: 5a07b9b9d0a04432e093aa7bc4cf43d7c9cee0ff7b17bb033d1e99530546c20c79d9ac106a61453c41e076c7d9dc05131ea4aabfde2cd58a30dea043b6387e19
7
+ data.tar.gz: 7f1a182179ba9b5c270fcd5f9604a0209bc1dee4a92ad14af1d4e237eafa06594a9dc9fd5f5e6f989f5ba334c5035f624f2ca81253c8438b31224adb8d258877
data/README.md CHANGED
@@ -1,8 +1,5 @@
1
1
  # AssetsDeployer
2
- Short description and motivation.
3
-
4
- ## Usage
5
- How to use my plugin.
2
+ Asset files deployer for rails application.
6
3
 
7
4
  ## Installation
8
5
  Add this line to your application's Gemfile:
@@ -21,8 +18,30 @@ Or install it yourself as:
21
18
  $ gem install assets_deployer
22
19
  ```
23
20
 
24
- ## Contributing
25
- Contribution directions go here.
21
+ ## Usage
22
+
23
+ ### Rails
24
+ Add initializer at `config/iniitializers/assets_deployer.rb`
25
+ ```rb
26
+ AssetsDeployer.configure do |config|
27
+ config.assets.root_path = Rails.root.join('public')
28
+ config.assets.prefix_paths = ['assets', 'packs']
29
+ config.assets.ignore_paths = ['packs/manifest.json']
30
+ # your storage service configurations
31
+ config.storage.name = 'S3'
32
+ config.storage.options[:bucket] = 'bucket_name'
33
+ config.storage.options[:prefix_key] = 'project_name'
34
+ # credentials
35
+ # Also, you can use environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) or instance profile credentials
36
+ config.storage.credentials[:access_key_id] = 'aws_access_key_id'
37
+ config.storage.credentials[:secret_access_key] = 'aws_secret_access_key'
38
+ end
39
+ ```
40
+
41
+ then you can use this rails command
42
+ ```console
43
+ $ bundle exec rails assets:precompile assets:deploy
44
+ ```
26
45
 
27
46
  ## License
28
47
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -4,7 +4,13 @@ require 'assets_deployer/storage_builder'
4
4
 
5
5
  module AssetsDeployer
6
6
  def self.run
7
- deployer = Deployer.new(storage: storage, root_path: config.assets_root_path, prefixes: config.assets_prefixes)
7
+ deployer = Deployer.new(
8
+ storage: storage,
9
+ root_path: config.assets.root_path,
10
+ prefix_paths: config.assets.prefix_paths,
11
+ ignore_paths: config.assets.ignore_paths
12
+ )
13
+
8
14
  deployer.run
9
15
  end
10
16
 
@@ -18,7 +24,6 @@ module AssetsDeployer
18
24
 
19
25
  def self.storage
20
26
  builder = StorageBuilder.new(
21
- platform: config.storage.platform,
22
27
  name: config.storage.name,
23
28
  credentials: config.storage.credentials,
24
29
  options: config.storage.options
@@ -1,16 +1,26 @@
1
1
  module AssetsDeployer
2
2
  class Configuration
3
- attr_accessor :storage,
4
- :assets_root_path,
5
- :assets_prefixes
3
+ attr_accessor :assets,
4
+ :storage
6
5
 
7
- class StorageConfiguration < Struct.new(:platform, :name, :credentials, :options)
6
+ class AssetsConfiguration < Struct.new(:root_path, :prefix_paths, :ignore_paths)
7
+ def initialize
8
+ self.prefix_paths = ['assets']
9
+ self.ignore_paths = []
10
+ end
11
+ end
12
+
13
+ class StorageConfiguration < Struct.new(:name, :credentials, :options)
8
14
  def initialize
9
15
  self.credentials = {}
10
16
  self.options = {}
11
17
  end
12
18
  end
13
19
 
20
+ def assets
21
+ @assets ||= AssetsConfiguration.new
22
+ end
23
+
14
24
  def storage
15
25
  @storage ||= StorageConfiguration.new
16
26
  end
@@ -2,10 +2,11 @@ require 'assets_deployer/asset_file'
2
2
 
3
3
  module AssetsDeployer
4
4
  class Deployer
5
- def initialize(storage:, root_path:, prefixes:)
5
+ def initialize(storage:, root_path:, prefix_paths:, ignore_paths:)
6
6
  @storage = storage
7
7
  @root_path = root_path
8
- @prefixes = prefixes
8
+ @prefix_paths = prefix_paths
9
+ @ignore_paths = ignore_paths.map { |path| File.join(root_path, path) }
9
10
  end
10
11
 
11
12
  def run
@@ -15,9 +16,9 @@ module AssetsDeployer
15
16
  private
16
17
 
17
18
  def files
18
- @files ||= @prefixes.flat_map do |prefix|
19
+ @files ||= @prefix_paths.flat_map do |prefix|
19
20
  Dir.glob(@root_path.join(prefix).join('**', '**')).map do |path|
20
- AssetFile.new(prefix, path) if Pathname.new(path).file?
21
+ AssetFile.new(prefix, path) if Pathname.new(path).file? && !@ignore_paths.include?(path)
21
22
  end
22
23
  end.compact
23
24
  end
@@ -6,16 +6,15 @@ module AssetsDeployer
6
6
  class InvalidStorageError < StandardError
7
7
  end
8
8
 
9
- def initialize(platform:, name:, credentials:, options:)
10
- @platform = platform
9
+ def initialize(name:, credentials:, options:)
11
10
  @name = name
12
11
  @credentials = credentials
13
12
  @options = options
14
13
  end
15
14
 
16
15
  def build
17
- case [@platform, @name]
18
- when ['AWS', 'S3']
16
+ case @name
17
+ when 'S3'
19
18
  Storage::AwsS3.new(
20
19
  credentials: @credentials,
21
20
  bucket: @options[:bucket],
@@ -1,3 +1,3 @@
1
1
  module AssetsDeployer
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assets_deployer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shota Iguchi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-28 00:00:00.000000000 Z
11
+ date: 2017-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails