lurtz 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ .DS_Store
data/.rvmrc ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.3" > .rvmrc
9
+ environment_id="ruby-1.9.3-p194@lurtz"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.17.9 (stable)" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
35
+
36
+ # If you use bundler, this might be useful to you:
37
+ # if [[ -s Gemfile ]] && {
38
+ # ! builtin command -v bundle >/dev/null ||
39
+ # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
40
+ # }
41
+ # then
42
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
+ # gem install bundler
44
+ # fi
45
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
+ # then
47
+ # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
48
+ # fi
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem "rspec"
7
+ gem "rake"
8
+ gem "yard"
9
+ gem "rdoc-data"
10
+ gem 'debugger'
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,63 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lurtz (1.0.0)
5
+ activesupport
6
+ launchy
7
+ rack
8
+ sinatra
9
+
10
+ GEM
11
+ remote: http://rubygems.org/
12
+ specs:
13
+ activesupport (3.2.11)
14
+ i18n (~> 0.6)
15
+ multi_json (~> 1.0)
16
+ addressable (2.3.2)
17
+ columnize (0.3.6)
18
+ debugger (1.2.3)
19
+ columnize (>= 0.3.1)
20
+ debugger-linecache (~> 1.1.1)
21
+ debugger-ruby_core_source (~> 1.1.5)
22
+ debugger-linecache (1.1.2)
23
+ debugger-ruby_core_source (>= 1.1.1)
24
+ debugger-ruby_core_source (1.1.6)
25
+ diff-lcs (1.1.3)
26
+ i18n (0.6.1)
27
+ json (1.7.6)
28
+ launchy (2.1.2)
29
+ addressable (~> 2.3)
30
+ multi_json (1.5.0)
31
+ rack (1.4.4)
32
+ rack-protection (1.3.2)
33
+ rack
34
+ rake (10.0.3)
35
+ rdoc (3.12)
36
+ json (~> 1.4)
37
+ rdoc-data (3.12)
38
+ rdoc (> 2.5, < 4.0)
39
+ rspec (2.12.0)
40
+ rspec-core (~> 2.12.0)
41
+ rspec-expectations (~> 2.12.0)
42
+ rspec-mocks (~> 2.12.0)
43
+ rspec-core (2.12.2)
44
+ rspec-expectations (2.12.1)
45
+ diff-lcs (~> 1.1.3)
46
+ rspec-mocks (2.12.1)
47
+ sinatra (1.3.3)
48
+ rack (~> 1.3, >= 1.3.6)
49
+ rack-protection (~> 1.2)
50
+ tilt (~> 1.3, >= 1.3.3)
51
+ tilt (1.3.3)
52
+ yard (0.8.3)
53
+
54
+ PLATFORMS
55
+ ruby
56
+
57
+ DEPENDENCIES
58
+ debugger
59
+ lurtz!
60
+ rake
61
+ rdoc-data
62
+ rspec
63
+ yard
data/README.md ADDED
@@ -0,0 +1 @@
1
+ Lurtz
data/bin/lurtz ADDED
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require 'optparse'
5
+ require File.join(File.dirname(File.dirname(__FILE__)), 'lib/lurtz')
6
+
7
+ banner = %q{
8
+
9
+ Lurtz, is your minion...
10
+
11
+ }
12
+
13
+
14
+ opts = OptionParser.new do |opts|
15
+
16
+ opts.banner = banner
17
+
18
+ opts.on("-v", "--version") do
19
+ Lurtz.log "Version: #{Lurtz::VERSION}"
20
+ end
21
+
22
+ opts.on("--console", "start an IRB console session giving you access to your lurtz environment") do
23
+ Lurtz.root_dir = Dir.pwd
24
+ Lurtz::Console.new
25
+ end
26
+
27
+ opts.on("--start", "run a local web server and process your files on save") do
28
+ # begin
29
+ Lurtz.log banner
30
+ Lurtz.log "Press Control+C to quit"
31
+
32
+ require 'rack'
33
+ require 'sinatra'
34
+
35
+ Lurtz.root_dir = Dir.pwd
36
+
37
+ # server = fork {
38
+ app = Rack::Builder.app {
39
+ # use Lurtz::RequestModifier
40
+ run Lurtz::WebServer
41
+ # use Lurtz::ResponseModifier
42
+ }
43
+
44
+ Rack::Handler.default.run(app, :Port => 5000)
45
+ # }
46
+ # rescue Interrupt
47
+ # Process.kill("QUIT", server)
48
+ # Process.wait(server)
49
+ # exit
50
+ # end
51
+ end
52
+
53
+ end
54
+
55
+ if ARGV.size == 0
56
+ puts "send fourth your minion! \ntype --help for a command list"
57
+ exit 1
58
+ end
59
+
60
+ opts.parse!
data/lib/lurtz.rb ADDED
@@ -0,0 +1,64 @@
1
+ require 'rubygems'
2
+ require 'fileutils'
3
+ require 'logger'
4
+
5
+ $LOAD_PATH << "#{File.dirname(__FILE__)}/lurtz"
6
+
7
+ require 'version'
8
+
9
+ module Lurtz
10
+
11
+ class << self
12
+
13
+ attr_accessor :root_dir, :config
14
+
15
+ def root_dir=(path)
16
+ unless is_a_lurtz?(path)
17
+ log "no lurtz app found - are you in the right directory?"
18
+ exit 0
19
+ end
20
+
21
+ @root_dir = path
22
+
23
+ init
24
+ end
25
+
26
+ def log(message)
27
+ puts message if config[:enable_logging]
28
+ end
29
+
30
+ def app
31
+ YAML::load(File.read("#{@root_dir}/app_config.yml")) || {}
32
+ rescue ArgumentError
33
+ Lurtz.log "Badly formatted app_config.yml"
34
+ end
35
+
36
+ def config
37
+ @config || { :enable_logging => true }
38
+ end
39
+
40
+ private
41
+
42
+ def init
43
+ set_paths
44
+ end
45
+
46
+ def set_paths
47
+ Page.path = "#{@root_dir}/overrides"
48
+ end
49
+
50
+ def is_a_lurtz?(path)
51
+ File.directory?("#{path}/overrides")
52
+ end
53
+
54
+ end
55
+
56
+ autoload :Console, "console"
57
+ autoload :Page, "page"
58
+
59
+ autoload :RequestModifier, "request_modifier"
60
+ autoload :WebServer, "webserver"
61
+ autoload :ResponseModifier, "response_modifier"
62
+
63
+ end
64
+
@@ -0,0 +1,11 @@
1
+ require 'irb'
2
+
3
+ module Lurtz
4
+ class Console
5
+
6
+ def initialize
7
+ IRB.start(__FILE__)
8
+ end
9
+
10
+ end
11
+ end
data/lib/lurtz/page.rb ADDED
@@ -0,0 +1,49 @@
1
+ require 'yaml'
2
+
3
+ if RUBY_VERSION =~ /^1.9./
4
+ YAML::ENGINE.yamler = 'syck'
5
+ end
6
+
7
+ require 'active_support/inflector'
8
+
9
+ module Lurtz
10
+ class Page
11
+
12
+ class NotFound < StandardError; end;
13
+
14
+ class << self
15
+
16
+ attr_accessor :path
17
+
18
+ def pages; @pages ||= {} end
19
+
20
+ def all(dir_path = path, pattern = "**/*.*")
21
+ Dir["#{dir_path}/#{pattern}"].map { |p| Page.new p }
22
+ end
23
+
24
+ def find(web_path)
25
+ pages[web_path] ||= find!(web_path)
26
+ end
27
+
28
+ private
29
+
30
+ def find!(web_path)
31
+ disk_path = Dir["#{path}/#{web_path}"]
32
+
33
+ if disk_path.any?
34
+ return new disk_path.first
35
+ else
36
+ raise NotFound, "page '#{web_path}' not found at '#{path}'"
37
+ end
38
+ end
39
+
40
+ end
41
+
42
+ attr_reader :disk_path
43
+
44
+ def initialize(path)
45
+ @disk_path = path
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,26 @@
1
+ module Lurtz
2
+ class RequestModifier
3
+
4
+ # def initialize(app, message = "Response Link Modifier")
5
+ # @app = app
6
+ # @message = message
7
+ # end
8
+ #
9
+ def call(env)
10
+ # dup._call(env)
11
+ end
12
+
13
+ # def _call(env)
14
+ # @start = Time.now
15
+ # @status, @headers, @response = @app.call(env)
16
+ # @stop = Time.now
17
+ # [@status, @headers, self]
18
+ # end
19
+ #
20
+ # def each(&block)
21
+ # block.call("<!-- #{@message}: #{@stop - @start} -->\n") if @headers["Content-Type"].include? "text/html"
22
+ # @response.each(&block)
23
+ # end
24
+
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ module Lurtz
2
+ class ResponseModifier
3
+
4
+ # def initialize(app, message = "Response Link Modifier")
5
+ # @app = app
6
+ # @message = message
7
+ # end
8
+
9
+ def call(env)
10
+ # dup._call(env)
11
+ end
12
+
13
+ # def _call(env)
14
+ # @start = Time.now
15
+ # @status, @headers, @response = @app.call(env)
16
+ # @stop = Time.now
17
+ # [@status, @headers, self]
18
+ # end
19
+ #
20
+ # def each(&block)
21
+ # block.call("<!-- #{@message}: #{@stop - @start} -->\n") if @headers["Content-Type"].include? "text/html"
22
+ # @response.each(&block)
23
+ # end
24
+
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module Lurtz
2
+ VERSION = "0.0.0"
3
+ end
@@ -0,0 +1,32 @@
1
+ module Lurtz
2
+
3
+ class WebServer < Sinatra::Base
4
+ set :views, "#{File.dirname(__FILE__)}/webserver"
5
+
6
+ # before do
7
+ # Lurtz.log "BEFORE BANG!"
8
+ # # let registerd request modifiers run here
9
+ # end
10
+ #
11
+ # after do
12
+ # Lurtz.log "AFTER BANG!"
13
+ # # let registerd response modifiers run here
14
+ # end
15
+
16
+ get '/*' do
17
+ # Lurtz.log "DOING BANG!"
18
+
19
+ begin
20
+ page = Page.find(params[:splat].join)
21
+ send_file page.disk_path
22
+ rescue Exception => e
23
+ @error = e
24
+ erb :error
25
+ # passthrough
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
5
+ <title>Lurtz, an error occurred</title>
6
+ <style type="text/css" media="screen">
7
+ body { font-style: Times, "Times New Roman", serif; font-style: italic; text-shadow: white 1px 1px 1px; }
8
+ h1 { font-size: 1em; text-align: center; font-weight: normal; }
9
+ #main { width: 580px; margin: 0 auto; display: block; }
10
+ #square { width: 145px; height: 145px; background-color: black; margin: 3em auto; }
11
+ </style>
12
+ </head>
13
+ <body id="error">
14
+ <section id="main">
15
+ <div id="square"></div>
16
+ <h1><%= @error.to_s %></h1>
17
+ </section>
18
+ </body>
19
+ </html>
data/lurtz.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "lurtz/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "lurtz"
7
+ s.version = Lurtz::VERSION
8
+ s.authors = ["Aidan Steele", "Luke Cunningham"]
9
+ s.email = ["aidan@aidans.org", "luke@icaruswings.com"]
10
+ s.homepage = "http://github.com/icaruswings/lurtz"
11
+ s.summary = %Q{A static thing}
12
+ s.description = %Q{A static thing}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ # specify any dependencies here; for example:
20
+ s.add_dependency "rack"
21
+ s.add_dependency "sinatra"
22
+ s.add_dependency "launchy"
23
+ s.add_dependency "activesupport"
24
+
25
+ s.post_install_message = %q{
26
+
27
+ Lurtz, is your minion...
28
+
29
+
30
+ type `lurtz --help` to get started
31
+ }
32
+ end
@@ -0,0 +1,12 @@
1
+ require "#{File.dirname(__FILE__)}/../spec_helper"
2
+
3
+ describe Lurtz::Console do
4
+ it "should respond to new" do
5
+ Lurtz::Console.should respond_to(:new)
6
+ end
7
+
8
+ it "should start a new IRB session" do
9
+ IRB.should_receive(:start)
10
+ Lurtz::Console.new
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+
3
+ require "#{File.dirname(__FILE__)}/../spec_helper"
4
+
5
+ describe Lurtz::Page do
6
+
7
+ describe "class methods" do
8
+ it "should respond to all" do
9
+ Lurtz::Page.should respond_to :all
10
+ end
11
+
12
+ it "should contain pages" do
13
+ Lurtz::Page.all.first.should be_an_instance_of(Lurtz::Page)
14
+ end
15
+
16
+ it "should be equal" do
17
+ Lurtz::Page.find("test.json").should == Lurtz::Page.find("test.json")
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Lurtz do
4
+
5
+ it "should have a root dir" do
6
+ Lurtz.should respond_to :root_dir
7
+ end
8
+
9
+ it "should set the root dir" do
10
+ Lurtz.root_dir = "spec/support"
11
+ Lurtz.root_dir.should == "spec/support"
12
+ end
13
+
14
+ it "should throw an exception if it doesn't look like a lurtz app" do
15
+ lambda { Lurtz.root_dir = "spec" }.should raise_error
16
+ lambda { Lurtz.root_dir = "spec/support" }.should_not raise_error
17
+ end
18
+
19
+ it "should know the version" do
20
+ Lurtz::VERSION.should =~ /\d+.\d+.\d+/
21
+ end
22
+
23
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ -b
@@ -0,0 +1,14 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'lurtz'
5
+ require 'rspec'
6
+ require 'rspec/autorun'
7
+
8
+ RSpec.configure do |config|
9
+ Lurtz.config = { :enable_logging => false }
10
+
11
+ LURTZ_PATH = "#{File.dirname(__FILE__)}/support" unless defined? LURTZ_PATH
12
+ Lurtz.root_dir = LURTZ_PATH
13
+ end
14
+
@@ -0,0 +1,6 @@
1
+ {
2
+ "nested": "true",
3
+ {
4
+ "test": "true"
5
+ }
6
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "test": "true"
3
+ }
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lurtz
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Aidan Steele
9
+ - Luke Cunningham
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-01-18 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rack
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: sinatra
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: launchy
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: activesupport
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ description: A static thing
80
+ email:
81
+ - aidan@aidans.org
82
+ - luke@icaruswings.com
83
+ executables:
84
+ - lurtz
85
+ extensions: []
86
+ extra_rdoc_files: []
87
+ files:
88
+ - .gitignore
89
+ - .rvmrc
90
+ - Gemfile
91
+ - Gemfile.lock
92
+ - README.md
93
+ - bin/lurtz
94
+ - lib/lurtz.rb
95
+ - lib/lurtz/console.rb
96
+ - lib/lurtz/page.rb
97
+ - lib/lurtz/request_modifier.rb
98
+ - lib/lurtz/response_modifier.rb
99
+ - lib/lurtz/version.rb
100
+ - lib/lurtz/webserver.rb
101
+ - lib/lurtz/webserver/error.erb
102
+ - lurtz.gemspec
103
+ - spec/lurtz/console_spec.rb
104
+ - spec/lurtz/page_spec.rb
105
+ - spec/lurtz_spec.rb
106
+ - spec/spec.opts
107
+ - spec/spec_helper.rb
108
+ - spec/support/overrides/nested/test.json
109
+ - spec/support/overrides/test.json
110
+ homepage: http://github.com/icaruswings/lurtz
111
+ licenses: []
112
+ post_install_message: ! "\n\n Lurtz, is your minion...\n\n\n type `lurtz --help`
113
+ to get started\n "
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 1.8.24
132
+ signing_key:
133
+ specification_version: 3
134
+ summary: A static thing
135
+ test_files:
136
+ - spec/lurtz/console_spec.rb
137
+ - spec/lurtz/page_spec.rb
138
+ - spec/lurtz_spec.rb
139
+ - spec/spec.opts
140
+ - spec/spec_helper.rb
141
+ - spec/support/overrides/nested/test.json
142
+ - spec/support/overrides/test.json
143
+ has_rdoc: