tynn 1.0.0 → 1.1.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: d821049145b6aac7727124929f21acbc7596502a
4
- data.tar.gz: 9766f2492ecba5bc81cf6630d517d3f3a1245d48
3
+ metadata.gz: caaa63933cf9306d02ec269daf58276c16cd28d3
4
+ data.tar.gz: f42352bb844554c1dd98f020bbceec81e5f6a6bb
5
5
  SHA512:
6
- metadata.gz: b39573bfd1b8d61d9963a74f51dd27ba04da957f834f34fd08a8d0c0ec6038e8a33a6e03d4f99083592238171f0c305a18e2c32545658cbccddb377892aeea8b
7
- data.tar.gz: 5aa36b7ab17f017c45028c43f0ecacaa0614e5ff040ebff7fb47ca6f46d8a64075395e3f6b74e3cefe48c6fa38b36dca99aa5ce3736694484131d603224f85c5
6
+ metadata.gz: 22ca341ae338b0305f31632ee651dea757344c1e6185ef33f18d2821ea0af12202275e0dda1a811f2d4a89ffcc803f5cbad409e7e2188c85f7d773c0bf625c62
7
+ data.tar.gz: 29923d6637a08a4d0d945ccfafe95b2ed9dbe2643c76085bc5ee1c476f0c55dff973e906bca95ab1c458d2b04a13503b1aaaef9b98bdb8f15f81038d31d9929e
data/lib/tynn.rb CHANGED
@@ -7,31 +7,33 @@ require_relative "tynn/version"
7
7
  class Tynn
8
8
  include Syro::Deck::API
9
9
 
10
- # Public: Extends Tynn functionality with the given +helper+ module.
10
+ # Public: Loads given +plugin+ into the application.
11
11
  #
12
12
  # Examples
13
13
  #
14
14
  # require "tynn"
15
15
  # require "tynn/protection"
16
+ # require "tynn/session"
16
17
  #
17
- # Tynn.helpers(Tynn::Protection)
18
+ # Tynn.plugin(Tynn::Protection)
19
+ # Tynn.plugin(Tynn::Session, secret: "__a_random_secret_key")
18
20
  #
19
- def self.helpers(helper, *args, &block)
20
- if defined?(helper::InstanceMethods)
21
- self.include(helper::InstanceMethods)
21
+ def self.plugin(plugin, *args, &block)
22
+ if defined?(plugin::InstanceMethods)
23
+ self.include(plugin::InstanceMethods)
22
24
  end
23
25
 
24
- if defined?(helper::ClassMethods)
25
- self.extend(helper::ClassMethods)
26
+ if defined?(plugin::ClassMethods)
27
+ self.extend(plugin::ClassMethods)
26
28
  end
27
29
 
28
- if helper.respond_to?(:setup)
29
- helper.setup(self, *args, &block)
30
+ if plugin.respond_to?(:setup)
31
+ plugin.setup(self, *args, &block)
30
32
  end
31
33
  end
32
34
 
33
- # Internal: Default helpers.
34
- helpers(Tynn::Settings)
35
+ # Internal: Default plugins.
36
+ plugin(Tynn::Settings)
35
37
 
36
38
  # Public: Sets the application handler.
37
39
  #
@@ -98,7 +100,7 @@ class Tynn
98
100
  # require "tynn"
99
101
  # require "tynn/environment"
100
102
  #
101
- # Tynn.helpers(Tynn::Environment)
103
+ # Tynn.plugin(Tynn::Environment)
102
104
  #
103
105
  # Tynn.set(:environment, :staging)
104
106
  # Tynn.environment
@@ -6,7 +6,7 @@ class Tynn
6
6
  # require "tynn"
7
7
  # require "tynn/all_methods"
8
8
  #
9
- # Tynn.helpers(Tynn::AllMethods)
9
+ # Tynn.plugin(Tynn::AllMethods)
10
10
  #
11
11
  module AllMethods
12
12
  module InstanceMethods
@@ -6,7 +6,7 @@ class Tynn
6
6
  # require "tynn"
7
7
  # require "tynn/environment"
8
8
  #
9
- # Tynn.helpers(Tynn::Environment)
9
+ # Tynn.plugin(Tynn::Environment)
10
10
  #
11
11
  # Tynn.environment # => :development
12
12
  #
@@ -18,7 +18,7 @@ class Tynn
18
18
  #
19
19
  # Examples
20
20
  #
21
- # Tynn.helpers(Tynn::Environment, env: ENV["RACK_ENV"])
21
+ # Tynn.plugin(Tynn::Environment, env: ENV["RACK_ENV"])
22
22
  #
23
23
  module Environment
24
24
  # Internal: Configures current environment.
@@ -8,7 +8,7 @@ class Tynn
8
8
  # require "tynn/force_ssl"
9
9
  # require "tynn/test"
10
10
  #
11
- # Tynn.helpers(Tynn::ForceSSL)
11
+ # Tynn.plugin(Tynn::ForceSSL)
12
12
  #
13
13
  # Tynn.define { }
14
14
  #
data/lib/tynn/hsts.rb CHANGED
@@ -9,7 +9,7 @@ class Tynn
9
9
  # require "tynn"
10
10
  # require "tynn/hsts"
11
11
  #
12
- # Tynn.helpers(Tynn::HSTS)
12
+ # Tynn.plugin(Tynn::HSTS)
13
13
  #
14
14
  # Tynn.define { }
15
15
  #
@@ -33,7 +33,7 @@ class Tynn
33
33
  #
34
34
  # Examples
35
35
  #
36
- # Tynn.helpers(
36
+ # Tynn.plugin(
37
37
  # Tynn::HSTS,
38
38
  # expires: 31_536_000,
39
39
  # includeSubdomains: true,
@@ -49,7 +49,7 @@ class Tynn
49
49
  #
50
50
  # Examples
51
51
  #
52
- # Tynn.helpers(Tynn::HSTS, expires: 0)
52
+ # Tynn.plugin(Tynn::HSTS, expires: 0)
53
53
  #
54
54
  module HSTS
55
55
  # Internal: Sets the HSTS header as a default header.
data/lib/tynn/json.rb CHANGED
@@ -8,7 +8,7 @@ class Tynn
8
8
  # require "tynn"
9
9
  # require "tynn/json"
10
10
  #
11
- # Tynn.helpers(Tynn::JSON)
11
+ # Tynn.plugin(Tynn::JSON)
12
12
  #
13
13
  module JSON
14
14
  CONTENT_TYPE = "application/json".freeze
data/lib/tynn/matchers.rb CHANGED
@@ -6,7 +6,7 @@ class Tynn
6
6
  # require "tynn"
7
7
  # require "tynn/matchers"
8
8
  #
9
- # Tynn.helpers(Tynn::Matchers)
9
+ # Tynn.plugin(Tynn::Matchers)
10
10
  #
11
11
  module Matchers
12
12
  module InstanceMethods
@@ -8,7 +8,7 @@ class Tynn
8
8
  # require "tynn"
9
9
  # require "tynn/protection"
10
10
  #
11
- # Tynn.helpers(Tynn::Protection)
11
+ # Tynn.plugin(Tynn::Protection)
12
12
  #
13
13
  # If you are using SSL/TLS (HTTPS), it's recommended to set
14
14
  # the +:ssl+ option:
@@ -18,9 +18,9 @@ class Tynn
18
18
  # require "tynn"
19
19
  # require "tynn/protection"
20
20
  #
21
- # Tynn.helpers(Tynn::Protection, ssl: true)
21
+ # Tynn.plugin(Tynn::Protection, ssl: true)
22
22
  #
23
- # By default, it includes the following security helpers:
23
+ # By default, it includes the following security plugins:
24
24
  #
25
25
  # - Tynn::SecureHeaders
26
26
  #
@@ -31,22 +31,22 @@ class Tynn
31
31
  # - Tynn::ForceSSL
32
32
  #
33
33
  module Protection
34
- # Internal: Configures security related helpers.
34
+ # Internal: Configures security related plugins.
35
35
  def self.setup(app, ssl: false, force_ssl: ssl, hsts: {})
36
- app.helpers(Tynn::SecureHeaders)
36
+ app.plugin(Tynn::SecureHeaders)
37
37
 
38
38
  if ssl
39
39
  app.settings[:ssl] = true
40
40
 
41
41
  require_relative "hsts"
42
42
 
43
- app.helpers(Tynn::HSTS, hsts)
43
+ app.plugin(Tynn::HSTS, hsts)
44
44
  end
45
45
 
46
46
  if force_ssl
47
47
  require_relative "force_ssl"
48
48
 
49
- app.helpers(Tynn::ForceSSL)
49
+ app.plugin(Tynn::ForceSSL)
50
50
  end
51
51
  end
52
52
  end
@@ -6,9 +6,9 @@ class Tynn
6
6
  # require "tynn"
7
7
  # require "tynn/secure_headers"
8
8
  #
9
- # Tynn.helpers(Tynn::SecureHeaders)
9
+ # Tynn.plugin(Tynn::SecureHeaders)
10
10
  #
11
- # This helper applies the following headers:
11
+ # This plugin applies the following headers:
12
12
  #
13
13
  # *X-Content-Type-Options:* <tt>"nosniff"</tt>
14
14
  #
data/lib/tynn/session.rb CHANGED
@@ -7,7 +7,7 @@ class Tynn
7
7
  # require "tynn"
8
8
  # require "tynn/session"
9
9
  #
10
- # Tynn.helpers(Tynn::Session, secret: "__change_me__")
10
+ # Tynn.plugin(Tynn::Session, secret: "__change_me__")
11
11
  #
12
12
  # Tynn.define do
13
13
  # root do
@@ -30,7 +30,7 @@ class Tynn
30
30
  #
31
31
  # Examples
32
32
  #
33
- # Tynn.helpers(Tynn::Session, secret: ENV["SESSION_SECRET"])
33
+ # Tynn.plugin(Tynn::Session, secret: ENV["SESSION_SECRET"])
34
34
  #
35
35
  # Under the hood, Tynn::Session uses the +Rack::Session::Cookie+ middleware.
36
36
  # Thus, supports all the options available for this middleware:
@@ -50,7 +50,7 @@ class Tynn
50
50
  #
51
51
  # Examples
52
52
  #
53
- # Tynn.helpers(
53
+ # Tynn.plugin(
54
54
  # Tynn::Session,
55
55
  # key: "app",
56
56
  # secret: ENV["SESSION_SECRET"],
data/lib/tynn/settings.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Tynn
2
- # Public: It provides a settings API for applications. This helper is
2
+ # Public: It provides a settings API for applications. This plugin is
3
3
  # included by default.
4
4
  #
5
5
  # Examples
@@ -18,7 +18,7 @@ class Tynn
18
18
  # end
19
19
  # end
20
20
  #
21
- # Tynn.helpers(AppName, "MyApp")
21
+ # Tynn.plugin(AppName, "MyApp")
22
22
  #
23
23
  # Tynn.app_name
24
24
  # # => "MyApp"
data/lib/tynn/static.rb CHANGED
@@ -7,7 +7,7 @@ class Tynn
7
7
  # require "tynn"
8
8
  # require "tynn/static"
9
9
  #
10
- # Tynn.helpers(Tynn::Static, ["/js", "/css"])
10
+ # Tynn.plugin(Tynn::Static, ["/js", "/css"])
11
11
  #
12
12
  # By default, serves all requests beginning with the given paths from
13
13
  # the folder +public+ in the current directory (e.g. +public/js/*+,
@@ -16,7 +16,7 @@ class Tynn
16
16
  #
17
17
  # Examples
18
18
  #
19
- # Tynn.helpers(Tynn::Static, ["/js", "/css"], root: "assets")
19
+ # Tynn.plugin(Tynn::Static, ["/js", "/css"], root: "assets")
20
20
  #
21
21
  # Under the hood, it uses the +Rack::Static+ middleware. Thus,
22
22
  # supports all the options available by the middleware. Check
@@ -25,7 +25,7 @@ class Tynn
25
25
  #
26
26
  # Examples
27
27
  #
28
- # Tynn.helpers(Tynn::Static, ["/js", "/css"], index: "index.html")
28
+ # Tynn.plugin(Tynn::Static, ["/js", "/css"], index: "index.html")
29
29
  #
30
30
  module Static
31
31
  # Internal: Configures Rack::Static middleware.
data/lib/tynn/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  class Tynn # :nodoc: all
2
2
  VERSION = [
3
3
  MAJOR_VERSION = 1,
4
- MINOR_VERSION = 0,
4
+ MINOR_VERSION = 1,
5
5
  PATCH_VERSION = 0,
6
6
  PRE_VERSION = nil
7
7
  ].compact.join(".")
@@ -1,6 +1,6 @@
1
1
  require_relative "../lib/tynn/all_methods"
2
2
 
3
- Tynn.helpers(Tynn::AllMethods)
3
+ Tynn.plugin(Tynn::AllMethods)
4
4
 
5
5
  test "methods" do
6
6
  [:head, :options].each do |method|
@@ -4,7 +4,7 @@ test "use RACK_ENV by default" do
4
4
  begin
5
5
  old, ENV["RACK_ENV"] = ENV["RACK_ENV"], "production"
6
6
 
7
- Tynn.helpers(Tynn::Environment)
7
+ Tynn.plugin(Tynn::Environment)
8
8
 
9
9
  assert_equal(:production, Tynn.environment)
10
10
 
@@ -18,7 +18,7 @@ test "use RACK_ENV by default" do
18
18
  end
19
19
 
20
20
  test "use custom value" do
21
- Tynn.helpers(Tynn::Environment, env: "development")
21
+ Tynn.plugin(Tynn::Environment, env: "development")
22
22
 
23
23
  assert_equal(:development, Tynn.environment)
24
24
  assert Tynn.development?
@@ -5,7 +5,7 @@ setup do
5
5
  end
6
6
 
7
7
  test "redirects to https" do |app|
8
- Tynn.helpers(Tynn::ForceSSL)
8
+ Tynn.plugin(Tynn::ForceSSL)
9
9
 
10
10
  Tynn.define do
11
11
  end
@@ -17,7 +17,7 @@ test "redirects to https" do |app|
17
17
  end
18
18
 
19
19
  test "https request" do |app|
20
- Tynn.helpers(Tynn::ForceSSL)
20
+ Tynn.plugin(Tynn::ForceSSL)
21
21
 
22
22
  Tynn.define do
23
23
  root do
data/test/hmote_test.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require_relative "../lib/tynn/hmote"
2
2
 
3
3
  setup do
4
- Tynn.helpers(Tynn::HMote, views: File.expand_path("./test/views"))
4
+ Tynn.plugin(Tynn::HMote, views: File.expand_path("./test/views"))
5
5
 
6
6
  Tynn::Test.new
7
7
  end
data/test/hsts_test.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require_relative "../lib/tynn/hsts"
2
2
 
3
3
  test "hsts header" do |app|
4
- Tynn.helpers(Tynn::HSTS)
4
+ Tynn.plugin(Tynn::HSTS)
5
5
 
6
6
  Tynn.define do
7
7
  end
@@ -15,7 +15,7 @@ test "hsts header" do |app|
15
15
  end
16
16
 
17
17
  test "hsts header options" do |app|
18
- Tynn.helpers(Tynn::HSTS, expires: 1, subdomains: false, preload: true)
18
+ Tynn.plugin(Tynn::HSTS, expires: 1, subdomains: false, preload: true)
19
19
 
20
20
  Tynn.define do
21
21
  end
data/test/json_test.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require_relative "../lib/tynn/json"
2
2
 
3
3
  test "json" do
4
- Tynn.helpers(Tynn::JSON)
4
+ Tynn.plugin(Tynn::JSON)
5
5
 
6
6
  Tynn.define do
7
7
  root do
@@ -1,7 +1,7 @@
1
1
  require_relative "../lib/tynn/matchers"
2
2
 
3
3
  setup do
4
- Tynn.helpers(Tynn::Matchers)
4
+ Tynn.plugin(Tynn::Matchers)
5
5
 
6
6
  Tynn::Test.new
7
7
  end
@@ -1,7 +1,7 @@
1
1
  require_relative "../lib/tynn/not_found"
2
2
 
3
3
  test "not found" do
4
- Tynn.helpers(Tynn::NotFound)
4
+ Tynn.plugin(Tynn::NotFound)
5
5
 
6
6
  class Tynn
7
7
  def not_found
@@ -4,7 +4,7 @@ require_relative "../lib/tynn/session"
4
4
  test "supports hsts options" do
5
5
  hsts = { expires: 100, subdomains: false, preload: true }
6
6
 
7
- Tynn.helpers(Tynn::Protection, ssl: true, hsts: hsts)
7
+ Tynn.plugin(Tynn::Protection, ssl: true, hsts: hsts)
8
8
 
9
9
  Tynn.define do
10
10
  end
@@ -18,8 +18,8 @@ test "supports hsts options" do
18
18
  end
19
19
 
20
20
  test "adds secure flag to session cookie" do
21
- Tynn.helpers(Tynn::Protection, ssl: true)
22
- Tynn.helpers(Tynn::Session, secret: "_this_must_be_random_")
21
+ Tynn.plugin(Tynn::Protection, ssl: true)
22
+ Tynn.plugin(Tynn::Session, secret: "_this_must_be_random_")
23
23
 
24
24
  Tynn.define do
25
25
  root do
data/test/render_test.rb CHANGED
@@ -2,7 +2,7 @@ require "erubis"
2
2
  require_relative "../lib/tynn/render"
3
3
 
4
4
  setup do
5
- Tynn.helpers(Tynn::Render, views: File.expand_path("./test/views"))
5
+ Tynn.plugin(Tynn::Render, views: File.expand_path("./test/views"))
6
6
 
7
7
  Tynn::Test.new
8
8
  end
@@ -1,7 +1,7 @@
1
1
  require_relative "../lib/tynn/secure_headers"
2
2
 
3
3
  test "secure headers" do
4
- Tynn.helpers(Tynn::SecureHeaders)
4
+ Tynn.plugin(Tynn::SecureHeaders)
5
5
 
6
6
  Tynn.define do
7
7
  root do
data/test/session_test.rb CHANGED
@@ -2,7 +2,7 @@ require "securerandom"
2
2
  require_relative "../lib/tynn/session"
3
3
 
4
4
  test "session" do
5
- Tynn.helpers(Tynn::Session, secret: SecureRandom.hex(64))
5
+ Tynn.plugin(Tynn::Session, secret: SecureRandom.hex(64))
6
6
 
7
7
  Tynn.define do
8
8
  root do
data/test/static_test.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require_relative "../lib/tynn/static"
2
2
 
3
3
  test "static" do
4
- Tynn.helpers(Tynn::Static, %w(/test), root: Dir.pwd)
4
+ Tynn.plugin(Tynn::Static, %w(/test), root: Dir.pwd)
5
5
 
6
6
  Tynn.define do
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tynn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francesco Rodríguez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-28 00:00:00.000000000 Z
11
+ date: 2015-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack