JotBook 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4308ce617d91663fe2e22e7f148af4b95b9a0a9aa19201c7f754dc2d0795fd54
4
+ data.tar.gz: 316689cdb6db73f5a268336bc28e25c7f3e8a50b0782b4c9695c370a51e0cb57
5
+ SHA512:
6
+ metadata.gz: ba374f5f7d1d720125be76139d39be008f330cb39e0a80341b7e5721968a1f08bb754d5cec60a6f753b2d6c3b095e4f20f7c0536e64eb2a245e8ee9435b462c3
7
+ data.tar.gz: e168e9c02c5a502364fdd956e059c119afc9477b0c1d095e9066c91ab2720b27e00681bb0d2ac023bec85e8fc512d8b68beb1fa61ee61f80688233257b295321
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-03-15
4
+
5
+ - Initial release
data/JotBook.gemspec ADDED
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/JotBook/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "JotBook"
7
+ spec.version = JotBook::VERSION
8
+ spec.authors = ["HamidrezaSafari"]
9
+ spec.email = ["HamidrezaSafari@hotmail.com"]
10
+
11
+ spec.summary = "Write a short summary, because RubyGems requires one."
12
+ spec.description = "Write a longer description or delete this line."
13
+ spec.homepage = "https://github.com/HamidrezaSafari/JotBook"
14
+ spec.required_ruby_version = ">= 3.0.0"
15
+
16
+ # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/HamidrezaSafari/JotBook"
20
+ spec.metadata["changelog_uri"] = "https://github.com/HamidrezaSafari/JotBook"
21
+ spec.license = "MIT"
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(__dir__) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ (File.expand_path(f) == __FILE__) ||
27
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile])
28
+ end
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
+ spec.default_executable = 'jotbook'
33
+ spec.require_paths = ["lib"]
34
+
35
+
36
+
37
+
38
+ # Uncomment to register a new dependency of your gem
39
+ # spec.add_dependency "example-gem", "~> 1.0"
40
+
41
+ # For more information and examples about making a new gem, check out our
42
+ # guide at: https://bundler.io/guides/creating_gem.html
43
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (C) 2012-present Dan Allen, Sarah White, Ryan Waldron, and the
4
+ individual contributors to Asciidoctor.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # JotBook
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/JotBook`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/JotBook. 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]/JotBook/blob/main/CODE_OF_CONDUCT.md).
32
+
33
+ ## Code of Conduct
34
+
35
+ Everyone interacting in the JotBook project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/JotBook/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,4 @@
1
+ module JotBook
2
+ class Generator < Plugin
3
+ end
4
+ end
@@ -0,0 +1,31 @@
1
+ require 'date'
2
+
3
+ module JotBook
4
+ class Jot
5
+ MATCHER = /^(\d+-\d+-\d+)-jot-(.*)\.([^.]+)$/
6
+
7
+ attr_accessor :date, :slug, :ext,:base,:name
8
+
9
+ def self.valid?(name)
10
+ name =~ MATCHER
11
+ end
12
+
13
+ def initialize(base, name)
14
+ @base = base
15
+ @name = name
16
+
17
+ self.process(name)
18
+ end
19
+
20
+ def url
21
+ self.date + self.slug
22
+ end
23
+
24
+ def process(name)
25
+ m, date, slug, ext = *name.match(MATCHER)
26
+ self.date = DateTime.parse(date).strftime("%Y-%m-%d")
27
+ self.slug = slug
28
+ self.ext = ext
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,41 @@
1
+ module JotBook
2
+ class Plugin
3
+ PRIORITIES = { :lowest => -100,
4
+ :low => -10,
5
+ :normal => 0,
6
+ :high => 10,
7
+ :highest => 100 }
8
+
9
+ def self.subclasses
10
+ @subclasses ||= []
11
+ end
12
+
13
+ def self.inherited(base)
14
+ subclasses << base
15
+ subclasses.sort!
16
+ end
17
+
18
+ def self.priority(priority = nil)
19
+ @priority ||= nil
20
+ if priority && PRIORITIES.has_key?(priority)
21
+ @priority = priority
22
+ end
23
+ @priority || :normal
24
+ end
25
+
26
+ def self.safe(safe = nil)
27
+ if safe
28
+ @safe = safe
29
+ end
30
+ @safe || false
31
+ end
32
+
33
+ def self.<=>(other)
34
+ PRIORITIES[other.priority] <=> PRIORITIES[self.priority]
35
+ end
36
+
37
+ def initialize(config = {})
38
+ # no-op for default
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,53 @@
1
+
2
+ module JotBook
3
+ class Site
4
+ attr_accessor :source, :dest
5
+ attr_accessor :layouts, :jotes
6
+ attr_accessor :config
7
+ attr_accessor :generators
8
+
9
+ def initialize(config)
10
+ self.config = config
11
+ @source = config[:source]
12
+ @dest = config[:destination]
13
+ @plugins = config[:plugins]
14
+ @layouts = config[:layouts]
15
+
16
+ self.jotes = []
17
+
18
+ process
19
+ end
20
+
21
+ def process
22
+ self.read_jotes
23
+ self.setup
24
+ self.generate
25
+ end
26
+
27
+ def setup
28
+ Dir[File.join(@plugins, "*.rb")].each do |plugin|
29
+ require plugin
30
+ end
31
+ @generators = Generator.subclasses.map do |c|
32
+ c.new(self.config,self.jotes)
33
+ end
34
+ end
35
+
36
+ def generate
37
+ @generators.each do |generator|
38
+ generator.generate
39
+ end
40
+ end
41
+
42
+ def read_jotes
43
+ base = File.join(@source)
44
+ entries = Dir.entries(base)
45
+ entries = entries.reject { |e| File.directory?(e)}
46
+ entries.each do |f|
47
+ if Jot.valid?(f)
48
+ self.jotes << Jot.new(base, f)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JotBook
4
+ VERSION = "0.0.1"
5
+ end
data/lib/JotBook.rb ADDED
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'JotBook/version'
4
+ require_relative 'JotBook/jot'
5
+ require_relative 'JotBook/plugin'
6
+ require_relative 'JotBook/generator'
7
+ require_relative 'JotBook/site'
8
+
9
+ module JotBook
10
+ class Build
11
+ def self.process(root_path)
12
+ config = {
13
+ source: root_path + '/_jotes',
14
+ destination: root_path + '/_site',
15
+ plugins: root_path + '/_plugins',
16
+ layouts: root_path + '/_layouts'
17
+ }
18
+
19
+ JotBook::Site.new(config)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ require 'jotdown'
2
+
3
+ module JotBook
4
+ class JotDown < Generator
5
+ attr_accessor :config,:jotes
6
+ def initialize(config,jotes)
7
+ @config = config
8
+ @jotes = jotes
9
+ end
10
+ def generate
11
+ @jotes.each do |jot|
12
+ jot_file = File.read(jot.base + '/' + jot.name)
13
+ result = Jotdown::Document.new(jot_file).render
14
+ output_file_name = "#{@config[:destination]}/#{jot.name.sub('.jd','.html')}"
15
+ File.open(output_file_name, 'w') do |f|
16
+ f.write(result)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: JotBook
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - HamidrezaSafari
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-03-15 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Write a longer description or delete this line.
14
+ email:
15
+ - HamidrezaSafari@hotmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - CHANGELOG.md
21
+ - JotBook.gemspec
22
+ - LICENSE
23
+ - README.md
24
+ - Rakefile
25
+ - lib/JotBook.rb
26
+ - lib/JotBook/generator.rb
27
+ - lib/JotBook/jot.rb
28
+ - lib/JotBook/plugin.rb
29
+ - lib/JotBook/site.rb
30
+ - lib/JotBook/version.rb
31
+ - template/jot_plug.rb
32
+ homepage: https://github.com/HamidrezaSafari/JotBook
33
+ licenses:
34
+ - MIT
35
+ metadata:
36
+ homepage_uri: https://github.com/HamidrezaSafari/JotBook
37
+ source_code_uri: https://github.com/HamidrezaSafari/JotBook
38
+ changelog_uri: https://github.com/HamidrezaSafari/JotBook
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubygems_version: 3.5.6
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: Write a short summary, because RubyGems requires one.
58
+ test_files: []