madride 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require './spec/spec_helper' --color --format documentation
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in madride.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Aleksey V Zapparov
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ MADRIDe
2
+ =======
3
+
4
+ Zero-configuration command-line HTTP server with cow super-powers...
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new
7
+
8
+ task :default => :spec
9
+ task :test => :spec
data/bin/madride ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+
3
+
4
+ require 'optparse'
5
+ require 'madride'
6
+
7
+
8
+ environment = Madride::Environment.new Dir.pwd
9
+ options = {:Port => 3000}
10
+
11
+
12
+ OptionParser.new("", 24, ' ') do |opts|
13
+ opts.banner = "Usage: madride [options] [PATH ...]"
14
+
15
+ opts.separator ""
16
+ opts.separator "Options:"
17
+
18
+ opts.on("-h", "--host HOST", "listen on HOST (default: 0.0.0.0)") do |host|
19
+ options[:Host] = host
20
+ end
21
+
22
+ opts.on("-p", "--port PORT", "use PORT (default: 3000)") do |port|
23
+ options[:Port] = port
24
+ end
25
+
26
+
27
+ if ARGV.empty?
28
+ puts opts.help
29
+ exit
30
+ end
31
+
32
+
33
+ begin
34
+ opts.order(ARGV) do |path|
35
+ environment.append_path path
36
+ end
37
+ rescue OptionParser::ParseError => e
38
+ opts.warn e.message
39
+ puts opts.help
40
+ exit
41
+ end
42
+ end
43
+
44
+
45
+ Madride::Server.new(environment, options).start
data/lib/madride.rb ADDED
@@ -0,0 +1,10 @@
1
+ require "madride/version"
2
+ require "madride/environment"
3
+ require "madride/server"
4
+
5
+
6
+ module Madride
7
+ autoload :Environment, "madride/environment"
8
+ autoload :Server, "madride/server"
9
+ autoload :Cli, "madride/cli"
10
+ end
@@ -0,0 +1,13 @@
1
+ require "sprockets"
2
+ require "madride/templates/slim"
3
+
4
+
5
+ module Madride
6
+ class Environment < Sprockets::Environment
7
+ def initialize *args
8
+ super
9
+
10
+ register_engine '.slim', SlimTemplate
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,18 @@
1
+ require "rack"
2
+
3
+
4
+ module Madride
5
+ class Server < Rack::Server
6
+ def initialize(environment, options = {})
7
+ @app = self.class.app environment
8
+ super options
9
+ end
10
+
11
+
12
+ def self.app environment
13
+ Rack::Builder.new do
14
+ run environment
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ require "slim"
2
+
3
+
4
+ module Madride
5
+ class SlimTemplate < Slim::Template
6
+ class << self
7
+ attr_reader :default_mime_type
8
+ @default_mime_type = 'text/html'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Madride
2
+ VERSION = "0.0.1"
3
+ end
data/madride.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/madride/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "madride"
6
+ gem.version = Madride::VERSION
7
+ gem.homepage = ""
8
+ gem.authors = ["Aleksey V Zapparov"]
9
+ gem.email = ["ixti@member.fsf.org"]
10
+ gem.summary = "madride-#{Madride::VERSION}"
11
+ gem.description = %q{Zero-configuration command-line HTTP server.}
12
+
13
+ gem.add_dependency "sprockets", "~> 2.4"
14
+ gem.add_dependency "rack", "~> 1.0"
15
+ gem.add_dependency "slim", "~> 1.2"
16
+
17
+ gem.add_development_dependency "rspec", "~> 2.11"
18
+ gem.add_development_dependency "rack-test", "~> 0.6"
19
+
20
+ gem.files = `git ls-files`.split($\)
21
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
22
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
23
+
24
+ gem.require_paths = ["lib"]
25
+ end
data/spec/.gitkeep ADDED
File without changes
@@ -0,0 +1 @@
1
+ var bar = 'bar';
@@ -0,0 +1,2 @@
1
+ //= require bar
2
+ var foo = 'foo';
@@ -0,0 +1,5 @@
1
+ html
2
+ head
3
+ title Hello World
4
+ body
5
+ h1 Madride works!
@@ -0,0 +1,29 @@
1
+ module Madride
2
+ describe Server do
3
+ include Rack::Test::Methods
4
+
5
+
6
+ def app
7
+ env = Environment.new fixtures_root.to_s
8
+ env.append_path '.'
9
+ Server.new(env).app
10
+ end
11
+
12
+
13
+ it "should serve html" do
14
+ get "/hello.html"
15
+ last_response.should be_ok
16
+ end
17
+
18
+ it "should serve js" do
19
+ get "/foo.js"
20
+ last_response.should be_ok
21
+ end
22
+
23
+
24
+ it "should respond with 404 if not found" do
25
+ get "/moo.html"
26
+ last_response.should_not be_ok
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,32 @@
1
+ # stdlib
2
+ require 'pathname'
3
+
4
+ # 3rd-party
5
+ require 'rack/test'
6
+
7
+ # internal
8
+ require_relative '../lib/madride'
9
+
10
+
11
+ module Madride
12
+ module RSpec
13
+ module Helpers
14
+ extend self
15
+
16
+
17
+ def fixtures_root
18
+ @fixtures_root ||= Pathname.new(__FILE__).parent.join('fixtures')
19
+ end
20
+
21
+
22
+ def fixtures_path path
23
+ fixtures_root.join(path.to_s)
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+
30
+ RSpec.configure do |config|
31
+ config.include Madride::RSpec::Helpers
32
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: madride
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Aleksey V Zapparov
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sprockets
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.4'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '2.4'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rack
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: slim
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '1.2'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.2'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '2.11'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '2.11'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rack-test
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '0.6'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '0.6'
94
+ description: Zero-configuration command-line HTTP server.
95
+ email:
96
+ - ixti@member.fsf.org
97
+ executables:
98
+ - madride
99
+ extensions: []
100
+ extra_rdoc_files: []
101
+ files:
102
+ - .gitignore
103
+ - .rspec
104
+ - Gemfile
105
+ - LICENSE
106
+ - README.md
107
+ - Rakefile
108
+ - bin/madride
109
+ - lib/madride.rb
110
+ - lib/madride/environment.rb
111
+ - lib/madride/server.rb
112
+ - lib/madride/templates/slim.rb
113
+ - lib/madride/version.rb
114
+ - madride.gemspec
115
+ - spec/.gitkeep
116
+ - spec/fixtures/bar.js
117
+ - spec/fixtures/foo.js
118
+ - spec/fixtures/hello.html.slim
119
+ - spec/server_spec.rb
120
+ - spec/spec_helper.rb
121
+ homepage: ''
122
+ licenses: []
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ segments:
134
+ - 0
135
+ hash: -126278893
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ segments:
143
+ - 0
144
+ hash: -126278893
145
+ requirements: []
146
+ rubyforge_project:
147
+ rubygems_version: 1.8.23
148
+ signing_key:
149
+ specification_version: 3
150
+ summary: madride-0.0.1
151
+ test_files:
152
+ - spec/.gitkeep
153
+ - spec/fixtures/bar.js
154
+ - spec/fixtures/foo.js
155
+ - spec/fixtures/hello.html.slim
156
+ - spec/server_spec.rb
157
+ - spec/spec_helper.rb