epuber 0.5.0.beta.5 → 0.5.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
  SHA256:
3
- metadata.gz: 37778a7f4faaa148518e3e6c27ef3040ebebb9e45633bca1862a87e7d5e2239b
4
- data.tar.gz: 219e403caf0fcc9a3fa954d6d51c88dc47c730245d423107b34a34c67d8b676d
3
+ metadata.gz: 5bcf06496b9fa4f3dc3e979ff764a8ef40dcd2c925a8f6100d96b07d785d86b2
4
+ data.tar.gz: 7b92cc896492d689f5b69095ab608098e91dd9595e7ae1993327907a4bd925d5
5
5
  SHA512:
6
- metadata.gz: df92556bba4458006e9e7717ea60570ddf789c20a42901425c978fbac4cc55821dc65d8f9ddc8b8837cbe1cc02966cd1859e493aebfb70e5e064259240b3a7e4
7
- data.tar.gz: d842afcef1235ffc591aece3e74f8144ea7f645b1cd203f59649990a76744f1fc30022ccd4f041a37c6650a71ca977b15284683cd985a251e28f096fdc5b49a8
6
+ metadata.gz: b805dabd18ad6c8bf2f2f3a44b391726bf3a9766abb7668dd8fd7fb83b0173b076a04f765b041e8d405cf13ffba8e88a043c8ef39ee30e2b65197d8671f7eba2
7
+ data.tar.gz: 14cd6edfca175231d53f3883bd5dc18e178e02a1703907897492c9918b305e7826cb7a8b35fabb4d3b05aa943ab44b1370dfa837d97ee171c261bc23f2751d29
data/epuber.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.summary = 'Epuber is simple tool to compile and pack source files into EPUB format.'
15
15
  spec.homepage = Epuber::HOME_URL
16
16
  spec.license = 'MIT'
17
- spec.required_ruby_version = '>= 2.2'
17
+ spec.required_ruby_version = '>= 2.3'
18
18
 
19
19
  spec.files = Dir['bin/**/*'] + Dir['lib/**/*'] + %w(epuber.gemspec Gemfile LICENSE.txt README.md)
20
20
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -44,7 +44,7 @@ Gem::Specification.new do |spec|
44
44
 
45
45
  spec.add_development_dependency 'bundler', '~> 1.15'
46
46
  spec.add_development_dependency 'rspec', '~> 3.2'
47
- spec.add_development_dependency 'rubocop', '~> 0.29'
47
+ spec.add_development_dependency 'rubocop', '~> 0.49'
48
48
  spec.add_development_dependency 'rake', '~> 12.2'
49
49
  spec.add_development_dependency 'fakefs', '~> 0.6'
50
50
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'fileutils'
4
4
 
5
+ require_relative '../templates'
5
6
  require_relative '../command'
6
7
  require_relative '../vendor/ruby_templater'
7
8
 
@@ -62,8 +63,7 @@ END
62
63
  # @return [void]
63
64
  #
64
65
  def write_bookspec(book_id)
65
- template_path = File.expand_path(File.join('..', 'templates', 'template.bookspec'), File.dirname(__FILE__))
66
- rendered = Epuber::RubyTemplater.from_file(template_path)
66
+ rendered = Epuber::RubyTemplater.from_file(Templates::TEMPLATE_BOOKSPEC)
67
67
  .with_locals(book_id: book_id)
68
68
  .render
69
69
 
@@ -96,23 +96,22 @@ END
96
96
  # @return [void]
97
97
  #
98
98
  def write_gitignore
99
- write('.gitignore', <<-END
100
- # This is generated with `epuber init`
101
- *.epub
102
- *.mobi
103
- !.epuber/
104
- .epuber/build/
105
- .epuber/release_build/
106
- .epuber/build_cache/
107
- .epuber/metadata/
108
-
99
+ append_new_lines('.gitignore', <<~END
100
+ # This is generated with `epuber init`
101
+ *.epub
102
+ *.mobi
103
+ !.epuber/
104
+ .epuber/build/
105
+ .epuber/release_build/
106
+ .epuber/build_cache/
107
+ .epuber/metadata/
109
108
  END
110
109
  )
111
110
  end
112
111
 
113
112
  def write_default_style(book_id)
114
- write("styles/#{book_id}.styl", <<-END
115
- // This is generated with `epuber init` script.
113
+ write("styles/#{book_id}.styl", <<~END
114
+ // This is generated with `epuber init` script.
116
115
  END
117
116
  )
118
117
  end
@@ -127,6 +126,30 @@ END
127
126
  puts " #{'create'.ansi.green} #{file_path}"
128
127
  end
129
128
 
129
+ # @param string [String] text to file
130
+ # @param file_path [String] path to file
131
+ #
132
+ # @return [void]
133
+ #
134
+ def append_new_lines(file_path, string)
135
+ unless File.exist?(file_path)
136
+ write(file_path, string)
137
+ return
138
+ end
139
+
140
+ existing_content = File.read(file_path)
141
+ string.split("\n").each do |line|
142
+ next if existing_content.include?(line)
143
+
144
+ existing_content << "\n#{line}"
145
+ end
146
+
147
+ existing_content << "\n"
148
+
149
+ File.write(file_path, existing_content)
150
+ puts " #{'update'.ansi.green} #{file_path}"
151
+ end
152
+
130
153
  # @param [String] dir_path path to dir
131
154
  #
132
155
  # @return [nil]
@@ -30,7 +30,7 @@ module Epuber
30
30
  __const: Hash.new { |_hash, key| UI.warning("Undefined constant with key `#{key}`", location: caller_locations[0]) }.merge!(target.constants),
31
31
  }
32
32
 
33
- should_load_from_precompiled = up_to_date && precompiled_exists && compilation_context.incremental_build?
33
+ should_load_from_precompiled = up_to_date && precompiled_exists && compilation_context.incremental_build? && (!compilation_context.should_write)
34
34
 
35
35
  precompiled = if should_load_from_precompiled
36
36
  begin
@@ -164,7 +164,7 @@ module Epuber
164
164
  #
165
165
  def validate_type(value)
166
166
  return if value.nil?
167
- return if supported_types.any? { |klass| value.class == klass }
167
+ return if supported_types.any? { |klass| value.class <= klass }
168
168
 
169
169
  raise StandardError, "Non acceptable type `#{value.class}` for #{self}. Allowed types: `#{types.inspect}`"
170
170
  end
@@ -223,7 +223,7 @@ module Epuber
223
223
 
224
224
  if dest_class.nil?
225
225
  array_keys = @auto_convert.select { |k, _v| k.is_a?(Array) }
226
- array_keys_with_type = array_keys.select { |k, _v| k.include?(value.class) }
226
+ array_keys_with_type = array_keys.select { |k, _v| k.any? { |klass| value.class <= klass } }
227
227
 
228
228
  if array_keys_with_type.count > 0
229
229
  dest_class = array_keys_with_type.values.first
@@ -0,0 +1,8 @@
1
+
2
+ module Epuber
3
+ module Templates
4
+ DIR = File.join(File.dirname(__FILE__), 'templates')
5
+
6
+ TEMPLATE_BOOKSPEC = File.join(DIR, "template.bookspec")
7
+ end
8
+ end
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Epuber
3
- VERSION = '0.5.0.beta.5'
3
+ VERSION = '0.5.0'
4
4
 
5
5
  HOME_URL = 'https://github.com/epuber-io/epuber'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epuber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0.beta.5
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Kříž
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-08 00:00:00.000000000 Z
11
+ date: 2018-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -268,14 +268,14 @@ dependencies:
268
268
  requirements:
269
269
  - - "~>"
270
270
  - !ruby/object:Gem::Version
271
- version: '0.29'
271
+ version: '0.49'
272
272
  type: :development
273
273
  prerelease: false
274
274
  version_requirements: !ruby/object:Gem::Requirement
275
275
  requirements:
276
276
  - - "~>"
277
277
  - !ruby/object:Gem::Version
278
- version: '0.29'
278
+ version: '0.49'
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: rake
281
281
  requirement: !ruby/object:Gem::Requirement
@@ -389,6 +389,7 @@ files:
389
389
  - lib/epuber/server/pages/files.bade
390
390
  - lib/epuber/server/pages/toc.bade
391
391
  - lib/epuber/server/support.coffee
392
+ - lib/epuber/templates.rb
392
393
  - lib/epuber/templates/template.bookspec
393
394
  - lib/epuber/third_party/bower.rb
394
395
  - lib/epuber/third_party/bower/bower.json
@@ -533,12 +534,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
533
534
  requirements:
534
535
  - - ">="
535
536
  - !ruby/object:Gem::Version
536
- version: '2.2'
537
+ version: '2.3'
537
538
  required_rubygems_version: !ruby/object:Gem::Requirement
538
539
  requirements:
539
- - - ">"
540
+ - - ">="
540
541
  - !ruby/object:Gem::Version
541
- version: 1.3.1
542
+ version: '0'
542
543
  requirements: []
543
544
  rubyforge_project:
544
545
  rubygems_version: 2.7.7