tinypacker 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
  SHA256:
3
- metadata.gz: 2aa21621f6b5dc2c5a2825bf8f326ae9cc8285c6a05798b5295ddcd9dcf888dd
4
- data.tar.gz: 91fb379bafe29dedb5d532fc489e5f4d61e13aead22a36f17f99bb6838baf0c0
3
+ metadata.gz: 06acf7757df545c98d3a0b8dd2456df838ad5703796a69910a0c8fb33dbbb1e9
4
+ data.tar.gz: 8e506319646a4e60dbbfd392a353db0e026591063b75d0f070da73fea08b76c4
5
5
  SHA512:
6
- metadata.gz: b3642f682bb1fb81b1c4de898fcd73ab0c37e4d70666b19c8f04771a539f5722d7753f31e1f65a48b8535de5e3d5540849dd2d48181247f4d8f5daa0a8c92087
7
- data.tar.gz: 597f80979de7e0ff202c6fda106e368f5d209866a513d3d8a5088de6801b9a6285f253e61476601c161b66d00bc77dfb7e9b8ed61bf78b1fc0bbb3dbbe0a03c5
6
+ metadata.gz: 60ef145be61223969d2e0a3d1de33bca57f2395e91d5a5f5d704c36a4908dfe4fc3a3c8593d8d58ce85c0b3bc2d0d63211ac92e1f1b142a5144d68c48aad3224
7
+ data.tar.gz: 4fc4ff31dfda69e22d5dffeb2ced10085c6e92723bc826939bbb34e245ca9a59ede36092a40b898d7ac60b19cd8b4a9e70283ef60ddc3cde8bc05e3ecf020d74
data/README.md CHANGED
@@ -18,9 +18,27 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install tinypacker
20
20
 
21
+ Finally, run the following to install
22
+
23
+ $ bundle exec rails tinypacker:install
24
+
21
25
  ## Usage
22
26
 
23
- TODO: Write usage instructions here
27
+ As with Webpacker, an asset manifest file is required to use Tinypacker. You need to specify the path of the asset manifest file in `manifest_path` of `tinypacker.yml`.
28
+
29
+ The format of the asset manifest file is as follows:
30
+
31
+ ```json
32
+ {
33
+ "application.js": "/packs/js/application-12345.js",
34
+ }
35
+ ```
36
+
37
+ And on the view file, you can use `javascript_pack_tag`.
38
+
39
+ ```
40
+ <%= javascript_pack_tag 'application.js' %>
41
+ ```
24
42
 
25
43
  ## Development
26
44
 
@@ -30,7 +48,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
30
48
 
31
49
  ## Contributing
32
50
 
33
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tinypacker. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/tinypacker/blob/master/CODE_OF_CONDUCT.md).
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/taogawa/tinypacker. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/taogawa/tinypacker/blob/main/CODE_OF_CONDUCT.md).
34
52
 
35
53
  ## License
36
54
 
@@ -38,4 +56,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
38
56
 
39
57
  ## Code of Conduct
40
58
 
41
- Everyone interacting in the Tinypacker project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/tinypacker/blob/master/CODE_OF_CONDUCT.md).
59
+ Everyone interacting in the Tinypacker project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/taogawa/tinypacker/blob/main/CODE_OF_CONDUCT.md).
@@ -0,0 +1,14 @@
1
+ default: &default
2
+ manifest_path: public/packs/manifest.json
3
+
4
+ development:
5
+ <<: *default
6
+ cache_manifest: false
7
+
8
+ test:
9
+ <<: *default
10
+ cache_manifest: false
11
+
12
+ production:
13
+ <<: *default
14
+ cache_manifest: true
@@ -0,0 +1,10 @@
1
+ # Install Tinypacker
2
+ copy_file "#{__dir__}/config/tinypacker.yml", "config/tinypacker.yml"
3
+
4
+ if File.exists?(".gitignore")
5
+ append_to_file ".gitignore" do
6
+ "\n/public/packs\n"
7
+ end
8
+ end
9
+
10
+ say "Tinypacker successfully installed", :green
@@ -0,0 +1,9 @@
1
+ install_template_path = File.expand_path("../install/template.rb", __dir__).freeze
2
+ bin_path = ENV["BUNDLE_BIN"] || "./bin"
3
+
4
+ namespace :tinypacker do
5
+ desc "Install Tinypacker in this application"
6
+ task :install do
7
+ exec "#{RbConfig.ruby} #{bin_path}/rails app:template LOCATION=#{install_template_path}"
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tinypacker
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/tinypacker.rb CHANGED
@@ -9,9 +9,9 @@ module Tinypacker
9
9
  @instance ||= Tinypacker::Instance.new
10
10
  end
11
11
 
12
- class Error < StandardError; end
13
-
14
12
  class Manifest
13
+ class FileNotFoundError < ::StandardError; end
14
+
15
15
  def initialize(configuration)
16
16
  @configuration = configuration
17
17
  end
@@ -25,7 +25,7 @@ module Tinypacker
25
25
  def load
26
26
  JSON.parse(File.read(@configuration.manifest_path))
27
27
  rescue Errno::ENOENT => e
28
- raise Tinypacker::Error, "manifest file not found #{@configuration.manifest_path}. Error: #{e.message}"
28
+ raise Tinypacker::Manifest::FileNotFoundError, "manifest file not found #{@configuration.manifest_path}. Error: #{e.message}"
29
29
  end
30
30
 
31
31
  def data
@@ -49,6 +49,9 @@ module Tinypacker
49
49
  end
50
50
 
51
51
  class Configuration
52
+ class FileNotFoundError < ::StandardError; end
53
+ class SyntaxError < ::StandardError; end
54
+
52
55
  attr_reader :root_path, :config_path
53
56
 
54
57
  def initialize(root_path:, env: Rails.env)
@@ -76,9 +79,9 @@ module Tinypacker
76
79
  end
77
80
  config[@env].deep_symbolize_keys
78
81
  rescue Errno::ENOENT => e
79
- raise Tinypacker::Error, "Tinypacker configuration file not found #{config_path}. Error: #{e.message}"
82
+ raise Tinypacker::Configuration::FileNotFoundError, "Tinypacker configuration file not found #{config_path}. Error: #{e.message}"
80
83
  rescue Psych::SyntaxError => e
81
- raise Tinypacker::Error, "YAML syntax error occurred while parsing #{config_path}. Error: #{e.message}"
84
+ raise Tinypacker::Configuration::SyntaxError, "YAML syntax error occurred while parsing #{config_path}. Error: #{e.message}"
82
85
  end
83
86
  end
84
87
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tinypacker
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
  - taogawa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-28 00:00:00.000000000 Z
11
+ date: 2022-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -95,6 +95,9 @@ files:
95
95
  - Rakefile
96
96
  - bin/console
97
97
  - bin/setup
98
+ - lib/install/config/tinypacker.yml
99
+ - lib/install/template.rb
100
+ - lib/tasks/install.rake
98
101
  - lib/tinypacker.rb
99
102
  - lib/tinypacker/version.rb
100
103
  - sig/tinypacker.rbs