haml-transpiler-server 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +1 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/LICENSE.md +25 -0
- data/README.md +64 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/hamlts +8 -0
- data/haml-transpiler-server.gemspec +29 -0
- data/lib/haml-transpiler-server/cli.rb +50 -0
- data/lib/haml-transpiler-server/version.rb +3 -0
- data/lib/haml-transpiler-server.rb +5 -0
- metadata +171 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 86651c066205f13ba3d5440aafa439a4c238e129
|
4
|
+
data.tar.gz: f1fcc3d17bbcb487a948cd55523c22613882928a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5d186761f790e84209636d47053f9d3ced8a4fe5c6bf3f1ee5b1ee3ace9f56ee4a06be730191a8ff45eada2bf7727476c0328074cddb507a89f67656791eab69
|
7
|
+
data.tar.gz: 78553c758e9e08e410369a2bf20ba07f679795a9d99c4a3de6bd51f7fbe211f25a0b0f91015e8c679ca54ad0a91e59d6a4758843ae42daf58b3778874bdd885f
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
=====================
|
3
|
+
|
4
|
+
Copyright © `2016` `Francesco Belladonna`
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person
|
7
|
+
obtaining a copy of this software and associated documentation
|
8
|
+
files (the “Software”), to deal in the Software without
|
9
|
+
restriction, including without limitation the rights to use,
|
10
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
copies of the Software, and to permit persons to whom the
|
12
|
+
Software is furnished to do so, subject to the following
|
13
|
+
conditions:
|
14
|
+
|
15
|
+
The above copyright notice and this permission notice shall be
|
16
|
+
included in all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
20
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
22
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
23
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
24
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
25
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# haml-transpiler-server
|
2
|
+
|
3
|
+
Simple HTTP server which allows transpiling HAML files through HTTP request
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'haml-transpiler-server'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install haml-transpiler-server
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Usage is simple:
|
24
|
+
|
25
|
+
hamlts
|
26
|
+
|
27
|
+
It will start an HTTP server on port 5487.
|
28
|
+
|
29
|
+
Performing an HTTP POST request to `/content` with `content` param set to a
|
30
|
+
valid HAML string will return the HTML version of it in the body.
|
31
|
+
|
32
|
+
Performing an HTTP POST request to `/path` with `path` param set to a _full_
|
33
|
+
file path with where the server is hosted will return the HTML version of the
|
34
|
+
content of the file, if it's valid HAML.
|
35
|
+
|
36
|
+
If any error is raised, a generic `500` code is reported, with error message
|
37
|
+
and backtrace as body.
|
38
|
+
|
39
|
+
## Configuration
|
40
|
+
|
41
|
+
The gem starts in development/production/test based on `RACK_ENV` environment
|
42
|
+
variable.
|
43
|
+
|
44
|
+
Port can be set to something different by setting the `HAMLTS_PORT` env
|
45
|
+
variable.
|
46
|
+
|
47
|
+
By default, the server binds to `0.0.0.0`, but you can change it by setting
|
48
|
+
`HAMLTS_BIND` env variable.
|
49
|
+
|
50
|
+
## Development
|
51
|
+
|
52
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
53
|
+
|
54
|
+
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).
|
55
|
+
|
56
|
+
## Usage with Javascript
|
57
|
+
|
58
|
+
Can be used with [haml-transpiler-server-loader](https://github.com/Fire-Dragon-DoL/haml-transpiler-server-loader) to compile HAML files without the overhead of
|
59
|
+
reloading the entire ruby env every HAML file you need to compile with `hamlrb`.
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Fire-Dragon-DoL/haml-transpiler-server.
|
64
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "haml-transpiler-server"
|
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
data/exe/hamlts
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "haml-transpiler-server/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "haml-transpiler-server"
|
8
|
+
spec.version = HamlTranspilerServer::VERSION
|
9
|
+
spec.authors = ["Fire-Dragon-DoL"]
|
10
|
+
spec.email = ["francesco.belladonna@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Simple HTTP server which allows transpiling HAML files using Ruby implementation}
|
13
|
+
spec.description = %q{Simple HTTP server which allows transpiling HAML files through HTTP request using Ruby implementation}
|
14
|
+
spec.homepage = "https://github.com/Fire-Dragon-DoL/haml-transpiler-server"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
spec.add_development_dependency "rack-test", "~> 0.6"
|
25
|
+
spec.add_dependency "sinatra", "~> 1.4"
|
26
|
+
spec.add_dependency "puma", "~> 3.2"
|
27
|
+
spec.add_dependency "haml"
|
28
|
+
spec.add_dependency "tilt"
|
29
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "sinatra/base"
|
2
|
+
require "haml"
|
3
|
+
require "tilt/haml"
|
4
|
+
|
5
|
+
module HamlTranspilerServer
|
6
|
+
class CLI < Sinatra::Base
|
7
|
+
use Rack::Logger
|
8
|
+
|
9
|
+
configure do
|
10
|
+
set :server, :puma
|
11
|
+
set :port, (ENV["HAMLTS_PORT"] || 5487).to_i
|
12
|
+
set :bind, ENV["HAMLTS_BIND"] || "0.0.0.0"
|
13
|
+
set :lock, false
|
14
|
+
end
|
15
|
+
|
16
|
+
post "/path" do
|
17
|
+
render_path(params[:path])
|
18
|
+
end
|
19
|
+
|
20
|
+
post "/content" do
|
21
|
+
render_content(params[:content])
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def render_error(error)
|
27
|
+
[500, {}, "#{ error }\n#{ error.backtrace.join("\n") }"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def render_path(path)
|
31
|
+
logger.info "path: #{ path }"
|
32
|
+
|
33
|
+
raise "File not existent" if path.nil? || !(File.exist?(path.to_s))
|
34
|
+
|
35
|
+
content = File.read(path)
|
36
|
+
render_content(content)
|
37
|
+
rescue => error
|
38
|
+
render_error(error)
|
39
|
+
end
|
40
|
+
|
41
|
+
def render_content(content)
|
42
|
+
content = content.to_s
|
43
|
+
logger.info "content: #{ content }"
|
44
|
+
|
45
|
+
haml content
|
46
|
+
rescue => error
|
47
|
+
render_error(error)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: haml-transpiler-server
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fire-Dragon-DoL
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rack-test
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sinatra
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.4'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.4'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: puma
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.2'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.2'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: haml
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: tilt
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Simple HTTP server which allows transpiling HAML files through HTTP request
|
126
|
+
using Ruby implementation
|
127
|
+
email:
|
128
|
+
- francesco.belladonna@gmail.com
|
129
|
+
executables:
|
130
|
+
- hamlts
|
131
|
+
extensions: []
|
132
|
+
extra_rdoc_files: []
|
133
|
+
files:
|
134
|
+
- ".gitignore"
|
135
|
+
- ".rspec"
|
136
|
+
- ".travis.yml"
|
137
|
+
- Gemfile
|
138
|
+
- LICENSE.md
|
139
|
+
- README.md
|
140
|
+
- Rakefile
|
141
|
+
- bin/console
|
142
|
+
- bin/setup
|
143
|
+
- exe/hamlts
|
144
|
+
- haml-transpiler-server.gemspec
|
145
|
+
- lib/haml-transpiler-server.rb
|
146
|
+
- lib/haml-transpiler-server/cli.rb
|
147
|
+
- lib/haml-transpiler-server/version.rb
|
148
|
+
homepage: https://github.com/Fire-Dragon-DoL/haml-transpiler-server
|
149
|
+
licenses: []
|
150
|
+
metadata: {}
|
151
|
+
post_install_message:
|
152
|
+
rdoc_options: []
|
153
|
+
require_paths:
|
154
|
+
- lib
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
requirements: []
|
166
|
+
rubyforge_project:
|
167
|
+
rubygems_version: 2.4.8
|
168
|
+
signing_key:
|
169
|
+
specification_version: 4
|
170
|
+
summary: Simple HTTP server which allows transpiling HAML files using Ruby implementation
|
171
|
+
test_files: []
|