servel 0.8.0 → 0.9.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: 110f9b74c9c900dfe2febfde8eb58d671831b549
4
- data.tar.gz: 0e2acd5f66b547f9ccfb53d52896ba3c3ce4184b
3
+ metadata.gz: 0bbb0f367b145394675e204c7a80df6418b6bbb2
4
+ data.tar.gz: 6070307eafbfe804dd06539c736a95c0991c93b3
5
5
  SHA512:
6
- metadata.gz: f1d8a384505b7b707e484adbb3e5238ebce1eca1c0e451839a6ad99751521799216e4b65e8ba5bfbf5a12c883a8e9b30e6c66366251eacfe39ae1f3fbe2ac554
7
- data.tar.gz: 95a5fb8d8ae8e43642a70291bba5b2c2c9e231c81c1cc4e044857efb8333fafabbb59e5b84e7e47d4417452c27770938f749e9c2d408a6723b572d143d1a8cc6
6
+ metadata.gz: 865cdba7e39632c9b242d6d7961f2a17940a9b509a158e9d120f9f15fe26c1a0986cd9bce0e6f3e40880d528aa96a50e36de67ae7f6d2619a4f1f20145809caf
7
+ data.tar.gz: 07d88d0349d4e20e2eb42cad1003b91679a276c37b9105015c6b792b76b01688b8b75842c8626921d3a717465ba5bdb7451d49749b7e3a6243c38c505fc67f3d
data/.gitignore CHANGED
@@ -1,9 +1,9 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
9
  /Gemfile.lock
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in servel.gemspec
6
- gemspec
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in servel.gemspec
6
+ gemspec
data/LICENSE.txt CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2017 Brenton "B-Train" Fletcher
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Brenton "B-Train" Fletcher
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,39 +1,39 @@
1
- # Servel
2
-
3
- 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/servel`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'servel'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install servel
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- 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.
30
-
31
- 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/servel.
36
-
37
- ## License
38
-
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
1
+ # Servel
2
+
3
+ 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/servel`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'servel'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install servel
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/servel.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console CHANGED
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "servel"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "servel"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/servel CHANGED
@@ -1,5 +1,5 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "servel"
4
-
1
+ #!/usr/bin/env ruby
2
+
3
+ require "servel"
4
+
5
5
  Servel::CLI.new(ARGV).start
data/bin/setup CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/servel.rb CHANGED
@@ -1,27 +1,27 @@
1
- require 'rack'
2
- require 'rack/handler/puma'
3
- require 'haml'
4
- require 'naturalsorter'
5
- require 'active_support/all'
6
-
7
- require 'json'
8
- require 'pathname'
9
- require 'delegate'
10
-
11
- module Servel
12
- def self.build_app(path_map)
13
- url_map = path_map.map { |root, url_root| [url_root, Servel::App.new(root)] }.to_h
14
- url_map["/"] = Servel::HomeApp.new(path_map.values) unless url_map.keys.include?("/")
15
-
16
- Rack::URLMap.new(url_map)
17
- end
18
- end
19
-
20
- require "servel/version"
21
- require "servel/path"
22
- require "servel/path_builder"
23
- require "servel/haml_context"
24
- require "servel/locals"
25
- require "servel/app"
26
- require "servel/home_app"
27
- require "servel/cli"
1
+ require 'rack'
2
+ require 'rack/handler/puma'
3
+ require 'haml'
4
+ require 'naturalsorter'
5
+ require 'active_support/all'
6
+
7
+ require 'json'
8
+ require 'pathname'
9
+ require 'delegate'
10
+
11
+ module Servel
12
+ def self.build_app(path_map)
13
+ url_map = path_map.map { |root, url_root| [url_root, Servel::App.new(root)] }.to_h
14
+ url_map["/"] = Servel::HomeApp.new(path_map.values) unless url_map.keys.include?("/")
15
+
16
+ Rack::URLMap.new(url_map)
17
+ end
18
+ end
19
+
20
+ require "servel/version"
21
+ require "servel/path"
22
+ require "servel/path_builder"
23
+ require "servel/haml_context"
24
+ require "servel/locals"
25
+ require "servel/app"
26
+ require "servel/home_app"
27
+ require "servel/cli"
data/lib/servel/app.rb CHANGED
File without changes
data/lib/servel/cli.rb CHANGED
@@ -1,18 +1,18 @@
1
- class Servel::CLI
2
- def initialize(argv)
3
- @argv = argv
4
- end
5
-
6
- def start
7
- Rack::Handler::Puma.run(Servel.build_app(path_map))
8
- end
9
-
10
- def path_map
11
- @argv.map do |arg|
12
- root, url_root = arg.split(":" , 2)
13
- root = Pathname.new(root).realpath
14
-
15
- [root, url_root || "/"]
16
- end.to_h
17
- end
1
+ class Servel::CLI
2
+ def initialize(argv)
3
+ @argv = argv
4
+ end
5
+
6
+ def start
7
+ Rack::Handler::Puma.run(Servel.build_app(path_map))
8
+ end
9
+
10
+ def path_map
11
+ @argv.map do |arg|
12
+ root, url_root = arg.split(":" , 2)
13
+ root = Pathname.new(root).realpath
14
+
15
+ [root, url_root || "/"]
16
+ end.to_h
17
+ end
18
18
  end
@@ -1,29 +1,29 @@
1
- class Servel::HamlContext
2
- include ActiveSupport::NumberHelper
3
-
4
- ENGINE_OPTIONS = { remove_whitespace: true, escape_html: true, ugly: true }
5
-
6
- def initialize()
7
- @build_path = Pathname.new(__FILE__).dirname.realpath + 'templates'
8
- @haml_engine_cache = {}
9
- end
10
-
11
- def render(template, locals = {})
12
- haml_engine(template).render(self, locals)
13
- end
14
-
15
- def partial(name, locals = {})
16
- render("_#{name}.haml", locals)
17
- end
18
-
19
- def include(path)
20
- (@build_path + path).read
21
- end
22
-
23
- def haml_engine(path)
24
- unless @haml_engine_cache.key?(path)
25
- @haml_engine_cache[path] = Haml::Engine.new(include(path), ENGINE_OPTIONS.merge(filename: path))
26
- end
27
- @haml_engine_cache[path]
28
- end
1
+ class Servel::HamlContext
2
+ include ActiveSupport::NumberHelper
3
+
4
+ ENGINE_OPTIONS = { remove_whitespace: true, escape_html: true, ugly: true }
5
+
6
+ def initialize()
7
+ @build_path = Pathname.new(__FILE__).dirname.realpath + 'templates'
8
+ @haml_engine_cache = {}
9
+ end
10
+
11
+ def render(template, locals = {})
12
+ haml_engine(template).render(self, locals)
13
+ end
14
+
15
+ def partial(name, locals = {})
16
+ render("_#{name}.haml", locals)
17
+ end
18
+
19
+ def include(path)
20
+ (@build_path + path).read
21
+ end
22
+
23
+ def haml_engine(path)
24
+ unless @haml_engine_cache.key?(path)
25
+ @haml_engine_cache[path] = Haml::Engine.new(include(path), ENGINE_OPTIONS.merge(filename: path))
26
+ end
27
+ @haml_engine_cache[path]
28
+ end
29
29
  end
@@ -1,12 +1,12 @@
1
- class Servel::HomeApp
2
- def initialize(roots)
3
- @roots = roots
4
- end
5
-
6
- def call(env)
7
- @haml_context ||= Servel::HamlContext.new
8
- body = @haml_context.render('home.haml', { roots: @roots })
9
-
10
- [200, {}, [body]]
11
- end
1
+ class Servel::HomeApp
2
+ def initialize(roots)
3
+ @roots = roots
4
+ end
5
+
6
+ def call(env)
7
+ @haml_context ||= Servel::HamlContext.new
8
+ body = @haml_context.render('home.haml', { roots: @roots })
9
+
10
+ [200, {}, [body]]
11
+ end
12
12
  end
data/lib/servel/locals.rb CHANGED
File without changes
data/lib/servel/path.rb CHANGED
@@ -1,38 +1,38 @@
1
- class Servel::Path
2
- attr_reader :type, :media_type, :listing_classes, :icon, :href, :name, :size, :mtime
3
-
4
- def initialize(type:, media_type: nil, listing_classes:, icon:, href:, name:, size: nil, mtime: nil)
5
- @type = type
6
- @media_type = media_type
7
- @listing_classes = listing_classes
8
- @icon = icon
9
- @href = href
10
- @name = name
11
- @size = size
12
- @mtime = mtime
13
- end
14
-
15
- def media?
16
- !@media_type.nil?
17
- end
18
-
19
- def self.top(href)
20
- Servel::Path.new(
21
- type: "Dir",
22
- listing_classes: "top directory",
23
- icon: "🔝",
24
- href: href,
25
- name: "Top Directory"
26
- )
27
- end
28
-
29
- def self.parent(href)
30
- Servel::Path.new(
31
- type: "Dir",
32
- listing_classes: "parent directory",
33
- icon: "⬆️",
34
- href: href,
35
- name: "Parent Directory"
36
- )
37
- end
1
+ class Servel::Path
2
+ attr_reader :type, :media_type, :listing_classes, :icon, :href, :name, :size, :mtime
3
+
4
+ def initialize(type:, media_type: nil, listing_classes:, icon:, href:, name:, size: nil, mtime: nil)
5
+ @type = type
6
+ @media_type = media_type
7
+ @listing_classes = listing_classes
8
+ @icon = icon
9
+ @href = href
10
+ @name = name
11
+ @size = size
12
+ @mtime = mtime
13
+ end
14
+
15
+ def media?
16
+ !@media_type.nil?
17
+ end
18
+
19
+ def self.top(href)
20
+ Servel::Path.new(
21
+ type: "Dir",
22
+ listing_classes: "top directory",
23
+ icon: "🔝",
24
+ href: href,
25
+ name: "Top Directory"
26
+ )
27
+ end
28
+
29
+ def self.parent(href)
30
+ Servel::Path.new(
31
+ type: "Dir",
32
+ listing_classes: "parent directory",
33
+ icon: "⬆️",
34
+ href: href,
35
+ name: "Parent Directory"
36
+ )
37
+ end
38
38
  end