gakubuchi 0.1.1 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8f99f730ea4cf0f4c61bbffe8cc2250c8fd4cd4
4
- data.tar.gz: 2650b9127b36840d288dbed572750ffa409b07ba
3
+ metadata.gz: 581c86e67d3d350858d9929191d9382656959691
4
+ data.tar.gz: 5640d23696f5e820da2b4dcaaccf5ac3e942b062
5
5
  SHA512:
6
- metadata.gz: 63fbdc55bba9fc95c3d18c3f1a3ee98ee56a35e9c4e94edbf862e1316be59392063b7702220e845d143670882bde7985dae838ee28ed2b18cb902ee2ba04e818
7
- data.tar.gz: bdddf2049a9f888cb9e8648882cf1c513cf184ec6111927dc5c5834bbf13e854c1e618242b4412b984dd6beef55d6d4fa0ee0b361af2e197d1c45d86c985ac76
6
+ metadata.gz: b34bfcb48634bda49914a78e0d4613921294976977bc60b1186ee87b807b88bb1c177b0c08563b9f7470b49e1763b1ef94c535a756536b3bd357e7f9177684d9
7
+ data.tar.gz: e592fa46b572100f56648cda5313937010e466e7b2ef0ac876a99b3d2d0338a0b07b5861a5392c8921a76c739cac2468a2999750e5b5294948533eeecd360442
data/README.md CHANGED
@@ -19,20 +19,19 @@ Put this in your Gemfile:
19
19
  gem 'gakubuchi'
20
20
  ```
21
21
 
22
- In `app/assets/templates/static_page.html.erb`:
23
-
24
- ```erb
25
- <!DOCTYPE html>
26
- <html>
27
- <head>
28
- <title>Static Page</title>
29
- <%= stylesheet_link_tag 'application', media: 'all' %>
30
- <%= javascript_include_tag 'application' %>
31
- </head>
32
- <body>
33
- Welcome to Gakubuchi!
34
- </body>
35
- </html>
22
+ In `app/assets/templates/static_page.html.slim`:
23
+
24
+ ```slim
25
+ doctype html
26
+ html
27
+ head
28
+ title
29
+ | Sample Static Page
30
+ = stylesheet_link_tag 'application', media: 'all'
31
+ = javascript_include_tag 'application'
32
+ body
33
+ p
34
+ | Hello, Gakubuchi!
36
35
  ```
37
36
 
38
37
  Compile the templeate with:
@@ -46,14 +45,14 @@ Then, you can get `public/static_page.html` as follows.
46
45
  ```html
47
46
  <!DOCTYPE html>
48
47
  <html>
49
- <head>
50
- <title>Static Page</title>
51
- <link rel="stylesheet" media="all" href="/assets/application-e80e8f2318043e8af94dddc2adad5a4f09739a8ebb323b3ab31cd71d45fd9113.css" />
52
- <script src="/assets/application-8f06a73c35179188914ab50e057157639fce1401c1cdca640ac9cec33746fc5b.js"></script>
53
- </head>
54
- <body>
55
- Welcome to Gakubuchi!
56
- </body>
48
+ <head>
49
+ <title>Sample Static Page</title><link rel="stylesheet" media="all" href="/assets/application-e80e8f2318043e8af94dddc2adad5a4f09739a8ebb323b3ab31cd71d45fd9113.css" /><script src="/assets/application-8f06a73c35179188914ab50e057157639fce1401c1cdca640ac9cec33746fc5b.js"></script>
50
+ </head>
51
+ <body>
52
+ <p>
53
+ Hello, Gakubuchi!
54
+ </p>
55
+ </body>
57
56
  </html>
58
57
  ```
59
58
 
@@ -64,7 +63,8 @@ First, run the installation generator with:
64
63
  rails generate gakubuchi:install
65
64
  ```
66
65
 
67
- This will install the initializer into `config/initializers/gakubuchi.rb`.
66
+ This will install the initializer into `config/initializers/gakubuchi.rb`.
67
+
68
68
  In the file, you can configure the following values.
69
69
 
70
70
  ```
@@ -74,8 +74,8 @@ template_root # 'app/assets/templates' by default
74
74
 
75
75
  ## Supports
76
76
  * Ruby: `2.0.0` or later
77
- * Rails: `4.0.0` or later (supports `3.x` as possible)
78
- * Template engines: `ERB` (supports `Haml` and `Slim` soon)
77
+ * Rails: `4.0.0` or later (supports `3.x` as possible)
78
+ * Template engines: `ERB`, `Haml` and `Slim`
79
79
 
80
80
  ## Contributing
81
81
  You should follow the steps below.
@@ -3,6 +3,7 @@ require 'rails'
3
3
  require 'gakubuchi/configuration'
4
4
  require 'gakubuchi/task'
5
5
  require 'gakubuchi/template'
6
+ require 'gakubuchi/template_engine'
6
7
  require 'gakubuchi/version'
7
8
  require 'gakubuchi/engine'
8
9
 
@@ -5,5 +5,10 @@ module Gakubuchi
5
5
  config.generators do |g|
6
6
  g.test_framework :rspec
7
7
  end
8
+
9
+ initializer 'gakubuchi.assets.precompile' do |app|
10
+ TemplateEngine.new('Slim::Template').register!('.slim')
11
+ TemplateEngine.new('Tilt::HamlTemplate').register!('.haml')
12
+ end
8
13
  end
9
14
  end
@@ -20,8 +20,8 @@ module Gakubuchi
20
20
  next if src.nil?
21
21
  dest = template.destination_pathname
22
22
 
23
- Gakubuchi::FileUtils.copy_p(src, dest)
24
- Gakubuchi::FileUtils.remove(precompiled_pathnames) if remove_precompiled_templates?
23
+ FileUtils.copy_p(src, dest)
24
+ FileUtils.remove(precompiled_pathnames) if remove_precompiled_templates?
25
25
  end
26
26
  end
27
27
 
@@ -17,7 +17,7 @@ module Gakubuchi
17
17
  end
18
18
 
19
19
  def self.root
20
- Rails.root.join(Gakubuchi::configuration.template_root)
20
+ Rails.root.join(Gakubuchi.configuration.template_root)
21
21
  end
22
22
 
23
23
  def initialize(path)
@@ -0,0 +1,28 @@
1
+ module Gakubuchi
2
+ class TemplateEngine
3
+ extend ::Forwardable
4
+
5
+ attr_reader :klass
6
+ alias_method :engine, :klass
7
+
8
+ def_delegators 'Rails.application', :assets
9
+ def_delegators 'Sprockets::Utils', :normalize_extension
10
+ private :assets, :normalize_extension
11
+
12
+ def initialize(engine)
13
+ @klass = engine.to_s.constantize rescue nil
14
+ end
15
+
16
+ def register!(extname)
17
+ if engine.instance_of?(Class) && !registered?(extname)
18
+ !!assets.register_engine(extname, engine)
19
+ else
20
+ false
21
+ end
22
+ end
23
+
24
+ def registered?(extname)
25
+ assets.engines[normalize_extension(extname)] == engine
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module Gakubuchi
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gakubuchi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yasaichi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-29 00:00:00.000000000 Z
11
+ date: 2015-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -81,7 +81,21 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: pry-byebug
84
+ name: appraisal
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 2.0.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 2.0.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: haml-rails
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
@@ -95,19 +109,19 @@ dependencies:
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
- name: appraisal
112
+ name: slim-rails
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - ">="
102
116
  - !ruby/object:Gem::Version
103
- version: 2.0.0
117
+ version: '0'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - ">="
109
123
  - !ruby/object:Gem::Version
110
- version: 2.0.0
124
+ version: '0'
111
125
  description: Gakubuchi enables you to manage static pages with Asset Pipeline
112
126
  email:
113
127
  - yasaichi@users.noreply.github.com
@@ -125,6 +139,7 @@ files:
125
139
  - lib/gakubuchi/fileutils.rb
126
140
  - lib/gakubuchi/task.rb
127
141
  - lib/gakubuchi/template.rb
142
+ - lib/gakubuchi/template_engine.rb
128
143
  - lib/gakubuchi/version.rb
129
144
  - lib/generators/gakubuchi/install/install_generator.rb
130
145
  - lib/generators/gakubuchi/install/templates/gakubuchi.rb