rack-single-page-app 0.1.0

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
+ SHA1:
3
+ metadata.gz: 26a3e3186a29d68ba7c0db6f3905c8c5d95b495e
4
+ data.tar.gz: 2031da59cc9f94df3d8f7165124d0c8d072c3120
5
+ SHA512:
6
+ metadata.gz: bf107756717dc05770ab25807300aa339b3ba05dd91b283c18672c50d1a5fe2236d60e9785ff83dd325cb7543bccd6ded981bc1a6564f00c28237f1daa78f620
7
+ data.tar.gz: 7bbe83c7c8e5f3ba6aca9dd32c3921dd436c6ba3cec4a89841f8607a168b7e92b78a59870a2559297d035a80b4cf58b0e80d68f4a1212fbd139f5dbf9feb6e36
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.3
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rack-single-page-app.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Rob Sharp
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 ADDED
@@ -0,0 +1,43 @@
1
+ # Rack Single Page App Middleware
2
+
3
+ This middleware for Rack will route all web requests to a single file and return a '200' status code.
4
+
5
+ The intention is to allow rack-based application servers to run single-page webapps which use HTML5 routing, a
6
+ common pattern which is normally handled by the front-end web server.
7
+
8
+ If you are unable or unwilling to reconfigure your web server, this gem may provide what you require!
9
+
10
+
11
+ ## Installation
12
+
13
+ Install the gem:
14
+
15
+ `gem install rack-single-page-app`
16
+
17
+ Or in your Gemfile:
18
+
19
+ ```ruby
20
+ gem 'rack-single-page-app', :require => 'rack/single_page_app'
21
+ ```
22
+
23
+ ## Configuration
24
+
25
+ ### Rack
26
+
27
+ In `config.ru`, configure `Rack::SinglePageApp` by passing the destination file to the constructor:
28
+
29
+ ```ruby
30
+ run Rack::SinglePageApp.new("public/index.html")
31
+ ```
32
+
33
+ Generally, you'll run `Rack::Static` higher up in your `config.ru` so that you deliver static assets prior to single-page-app fall-through.
34
+
35
+ ### Testing
36
+
37
+ To contribute to the project, begin by cloning the repo and installing the necessary gems:
38
+
39
+ gem install json rack ruby-prof test-spec test-unit
40
+
41
+ To run the entire test suite, run
42
+
43
+ rake test
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ exec(*(["bundle", "exec", $PROGRAM_NAME] + ARGV)) if ENV['BUNDLE_GEMFILE'].nil?
2
+
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => ex
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+
11
+ require 'rdoc/task'
12
+ require 'rake/testtask'
13
+ require 'git-version-bump/rake-tasks'
14
+
15
+ desc "Run all the tests"
16
+ task :default => [:test]
17
+
18
+ desc "Run specs"
19
+ Rake::TestTask.new do |t|
20
+ t.libs << "test"
21
+ t.test_files = FileList['test/spec_*.rb']
22
+ end
23
+
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rack/single/page/app"
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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,26 @@
1
+ require 'rack'
2
+ require 'git-version-bump'
3
+
4
+ module Rack
5
+ # Rack::NotFound is a default endpoint. Initialize with the path to
6
+ # your 404 page.
7
+
8
+ class SinglePageApp
9
+ F = ::File
10
+
11
+ def self.release
12
+ GVB.version
13
+ end
14
+
15
+ def initialize(path)
16
+ file = F.expand_path(path)
17
+ @content = F.read(file)
18
+ @length = @content.size.to_s
19
+ end
20
+
21
+ def call(env)
22
+ [200, {'Content-Type' => 'text/html', 'Content-Length' => @length}, [@content]]
23
+ end
24
+ end
25
+ end
26
+
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ begin
6
+ require 'git-version-bump'
7
+ rescue LoadError
8
+ nil
9
+ end
10
+
11
+ Gem::Specification.new do |spec|
12
+ spec.name = "rack-single-page-app"
13
+ spec.version = GVB.version rescue "0.0.0.1.ENOGVB"
14
+ spec.date = GVB.date rescue Time.now.strftime("%F")
15
+
16
+ spec.authors = ["Rob Sharp"]
17
+ spec.email = ["rob.sharp@digivizer.com"]
18
+
19
+ spec.summary = %q{A rack middleware to assist running a single-page-app on rack.}
20
+ spec.description = %q{If you're running a javascript single-page-app with html5 routing,
21
+ you may notice that deep links will 404 unless your web front-end is
22
+ configured to rewrite all non-asset paths to index.html. If you'd like
23
+ to achieve the same rewrite using rack, this is the gem for you!}
24
+ spec.homepage = "https://github.com/qnm/rack-single-page-app"
25
+ spec.license = "MIT"
26
+
27
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_runtime_dependency 'rack', '~> 1.4'
33
+ spec.add_runtime_dependency 'git-version-bump', '~> 0.15'
34
+
35
+ spec.add_development_dependency "bundler", "~> 1.10"
36
+ spec.add_development_dependency "rake", "~> 10.0"
37
+ spec.add_development_dependency 'minitest', '~> 5.6'
38
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-single-page-app
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rob Sharp
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: git-version-bump
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.15'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.6'
83
+ description: |-
84
+ If you're running a javascript single-page-app with html5 routing,
85
+ you may notice that deep links will 404 unless your web front-end is
86
+ configured to rewrite all non-asset paths to index.html. If you'd like
87
+ to achieve the same rewrite using rack, this is the gem for you!
88
+ email:
89
+ - rob.sharp@digivizer.com
90
+ executables: []
91
+ extensions: []
92
+ extra_rdoc_files: []
93
+ files:
94
+ - ".gitignore"
95
+ - ".rspec"
96
+ - ".travis.yml"
97
+ - CODE_OF_CONDUCT.md
98
+ - Gemfile
99
+ - LICENSE.txt
100
+ - README.md
101
+ - Rakefile
102
+ - bin/console
103
+ - bin/setup
104
+ - lib/rack/single_page_app.rb
105
+ - rack-single-page-app.gemspec
106
+ homepage: https://github.com/qnm/rack-single-page-app
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.4.5
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: A rack middleware to assist running a single-page-app on rack.
130
+ test_files: []