gakubuchi 0.0.1 → 0.0.2

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: c8eadc6c43abb24a24e5f9163cba95e7cc506e87
4
- data.tar.gz: 5ecca979cc2ce51e3f2cda97d694af588e5f5825
3
+ metadata.gz: 898ea44bc282dc24bfb9a7c3aaee3788acb1766c
4
+ data.tar.gz: 1723a43f1d413a703346063a197b04b9e0eb730a
5
5
  SHA512:
6
- metadata.gz: 677bd4ce6ecbf75293bd7a2f8c91a45b9d89b48f885e2d2e73a1aa0377ab55ca35e23963a35028a63ae5390e16df5b547ee03e19acf10fbedd1088b8d353b62c
7
- data.tar.gz: 5cee678c49dd28db358068f5d1014da31721f2c23b79c2955d0ae9cab7b87692c167dc460e92d64f50b82a522067815c71cf9ce5147233c17670ebee469a64ee
6
+ metadata.gz: a839d3064b2d6d4d80a7f06b2e32568e7296b2db5d360836e79fb125fb033058213e015e5014ca1dcbf4820a359c4b4a431dd7bb57a8532614fddcc9927a4e9c
7
+ data.tar.gz: 2e0d1e29093d1cab7e48d2337af926711cb9e2e00bb5bca04416b9021f57941a47666ca71580113e5abe100dfdde5a9450d5e23fa14d56a487686e4baf56f883
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
1
  # Gakubuchi
2
2
 
3
+ [![Build Status](https://travis-ci.org/yasaichi/gakubuchi.svg?branch=master)](https://travis-ci.org/yasaichi/gakubuchi)
4
+ [![Code Climate](https://codeclimate.com/github/yasaichi/gakubuchi/badges/gpa.svg)](https://codeclimate.com/github/yasaichi/gakubuchi)
5
+ [![Test Coverage](https://codeclimate.com/github/yasaichi/gakubuchi/badges/coverage.svg)](https://codeclimate.com/github/yasaichi/gakubuchi/coverage)
6
+
3
7
  This project rocks and uses MIT-LICENSE.
data/Rakefile CHANGED
@@ -17,10 +17,10 @@ end
17
17
  APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
18
  load 'rails/tasks/engine.rake'
19
19
 
20
-
21
20
  load 'rails/tasks/statistics.rake'
22
21
 
23
-
24
-
25
22
  Bundler::GemHelper.install_tasks
26
23
 
24
+ require 'rspec/core/rake_task'
25
+ RSpec::Core::RakeTask.new(:spec)
26
+ task default: :spec
@@ -3,8 +3,8 @@ module Gakubuchi
3
3
  include ActiveSupport::Configurable
4
4
  alias_method :to_h, :config
5
5
 
6
- config_accessor :template_path do
7
- 'templates'
6
+ config_accessor :template_root do
7
+ 'app/assets/templates'
8
8
  end
9
9
  end
10
10
  end
@@ -1,4 +1,9 @@
1
1
  module Gakubuchi
2
2
  class Engine < ::Rails::Engine
3
+ isolate_namespace Gakubuchi
4
+
5
+ config.generators do |g|
6
+ g.test_framework :rspec
7
+ end
3
8
  end
4
9
  end
@@ -0,0 +1,49 @@
1
+ require 'fileutils'
2
+
3
+ module Gakubuchi
4
+ class Task
5
+ attr_reader :templates
6
+
7
+ def initialize(templates)
8
+ @templates = Array(templates)
9
+ end
10
+
11
+ def remove_compiled_files?
12
+ !!Gakubuchi.configuration.remove_compiled_files
13
+ end
14
+
15
+ def execute!
16
+ templates.each do |template|
17
+ compiled_paths = Dir.glob(template.compiled_pathname)
18
+ src = compiled_paths
19
+ .select { |path| File.extname(path) == '.html' }
20
+ .sort_by { |path| File.mtime(path) }
21
+ .last
22
+
23
+ next if src.nil?
24
+ dest = template.destination_pathname
25
+
26
+ copy(src, dest)
27
+ remove(compiled_paths) if remove_compiled_files?
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def copy(src, dest)
34
+ FileUtils.mkdir_p(File.dirname(dest))
35
+ FileUtils.cp(src, dest)
36
+ log("Copied #{src} to #{dest}")
37
+ end
38
+
39
+ def log(message)
40
+ @logger ||= Logger.new(STDOUT)
41
+ @logger.info(message)
42
+ end
43
+
44
+ def remove(list)
45
+ FileUtils.rm(list)
46
+ log("Removed #{list.join(' ')}")
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,51 @@
1
+ module Gakubuchi
2
+ class Template
3
+ attr_reader :pathname
4
+
5
+ def self.all
6
+ Dir.glob(root.join('**/*.html*')).map { |path| new(path) }
7
+ end
8
+
9
+ def self.root
10
+ Rails.root.join(Gakubuchi::configuration.template_root)
11
+ end
12
+
13
+ def initialize(path)
14
+ @pathname = Pathname.new(path)
15
+ end
16
+
17
+ def basename
18
+ pathname.basename.to_s
19
+ end
20
+
21
+ def compiled_pathname
22
+ dirname = relative_pathname.dirname
23
+ pattern = "#{relative_pathname.basename(extname)}-*.{html,html.gz}"
24
+ Rails.public_path.join('assets', dirname, pattern)
25
+ end
26
+
27
+ def destination_pathname
28
+ dirname = relative_pathname.dirname
29
+ Rails.public_path.join(dirname, "#{relative_pathname.basename(extname)}.html")
30
+ end
31
+
32
+ def extname
33
+ extnames = []
34
+ basename_without_ext = pathname.basename
35
+
36
+ loop do
37
+ extname = basename_without_ext.extname
38
+ break if extname.empty?
39
+
40
+ extnames.unshift(extname)
41
+ basename_without_ext = basename_without_ext.basename(extname)
42
+ end
43
+
44
+ extnames.join
45
+ end
46
+
47
+ def relative_pathname
48
+ pathname.relative_path_from(self.class.root)
49
+ end
50
+ end
51
+ end
@@ -1,3 +1,3 @@
1
1
  module Gakubuchi
2
- VERSION = "0.0.1"
2
+ VERSION = '0.0.2'
3
3
  end
data/lib/gakubuchi.rb CHANGED
@@ -1,4 +1,20 @@
1
- require "gakubuchi/engine"
1
+ require 'rails'
2
+
3
+ require 'gakubuchi/configuration'
4
+ require 'gakubuchi/template'
5
+ require 'gakubuchi/version'
6
+ require 'gakubuchi/engine'
2
7
 
3
8
  module Gakubuchi
9
+ class << self
10
+ attr_writer :configuration
11
+
12
+ def configuration
13
+ @configuration ||= Configuration.new
14
+ end
15
+
16
+ def configure
17
+ yield(configuration) if block_given?
18
+ end
19
+ end
4
20
  end
@@ -0,0 +1,11 @@
1
+ module Gakubuchi
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../templates', __FILE__)
5
+
6
+ def copy_initializer_file
7
+ copy_file 'gakubuchi.rb', 'config/initializers/gakubuchi.rb'
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ Gakubuchi.configure do |config|
2
+ end
@@ -0,0 +1,4 @@
1
+ Rake::Task['assets:precompile'].enhance do
2
+ task = Gakubuchi::Task.new(Gakubuchi::Template.all)
3
+ task.execute!
4
+ 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.0.1
4
+ version: 0.0.2
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-13 00:00:00.000000000 Z
11
+ date: 2015-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.0.0
19
+ version: 4.0.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 4.0.0
26
+ version: 4.0.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 3.0.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: ammeter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 1.0.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: codeclimate-test-reporter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  description: Gakubuchi enables you to manage static pages with Asset Pipeline
56
84
  email:
57
85
  - yasaichi@users.noreply.github.com
@@ -66,7 +94,12 @@ files:
66
94
  - lib/gakubuchi.rb
67
95
  - lib/gakubuchi/configuration.rb
68
96
  - lib/gakubuchi/engine.rb
97
+ - lib/gakubuchi/task.rb
98
+ - lib/gakubuchi/template.rb
69
99
  - lib/gakubuchi/version.rb
100
+ - lib/generators/gakubuchi/install/install_generator.rb
101
+ - lib/generators/gakubuchi/install/templates/gakubuchi.rb
102
+ - lib/tasks/after_precompile.rake
70
103
  - lib/tasks/gakubuchi_tasks.rake
71
104
  homepage: https://github.com/yasaichi/gakubuchi
72
105
  licenses: