alf-repl 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # 0.16.0 / 2014-02-18
2
+
3
+ * Enhancements
4
+
5
+ * Birthday!
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source 'http://rubygems.org'
2
+
3
+ group :runtime do
4
+ gem "rack", "~> 1.5"
5
+ gem "rack-robustness", "~> 1.1"
6
+ gem "sinatra", "~> 1.4"
7
+ gem "wlang", "~> 2.2"
8
+ gem "sprockets", "~> 2.10"
9
+
10
+ gem "alf-core", path: "../alf-core"
11
+ gem "alf-rack", path: "../alf-rack"
12
+ end
13
+
14
+ group :development do
15
+ gem "rake", "~> 10.1"
16
+ gem "rspec", "~> 2.14"
17
+ gem "rack-test", "~> 0.6.1"
18
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,82 @@
1
+ PATH
2
+ remote: ../alf-core
3
+ specs:
4
+ alf-core (0.16.0)
5
+ domain (~> 1.0)
6
+ myrrha (~> 3.0)
7
+ path (~> 1.3)
8
+ sexpr (~> 0.6.0)
9
+
10
+ PATH
11
+ remote: ../alf-rack
12
+ specs:
13
+ alf-rack (0.16.0)
14
+ alf-core (= 0.16.0)
15
+ rack (~> 1.5)
16
+ rack-accept (~> 0.4.5)
17
+ ruby_cop (~> 1.0)
18
+
19
+ GEM
20
+ remote: http://rubygems.org/
21
+ specs:
22
+ backports (2.8.2)
23
+ citrus (2.4.1)
24
+ diff-lcs (1.2.4)
25
+ domain (1.0.0)
26
+ hike (1.2.3)
27
+ multi_json (1.8.2)
28
+ myrrha (3.0.0)
29
+ domain (~> 1.0)
30
+ path (1.3.3)
31
+ quickl (0.4.3)
32
+ rack (1.5.2)
33
+ rack-accept (0.4.5)
34
+ rack (>= 0.4)
35
+ rack-protection (1.5.1)
36
+ rack
37
+ rack-robustness (1.1.0)
38
+ rack-test (0.6.2)
39
+ rack (>= 1.0)
40
+ rake (10.1.0)
41
+ rspec (2.14.1)
42
+ rspec-core (~> 2.14.0)
43
+ rspec-expectations (~> 2.14.0)
44
+ rspec-mocks (~> 2.14.0)
45
+ rspec-core (2.14.7)
46
+ rspec-expectations (2.14.3)
47
+ diff-lcs (>= 1.1.3, < 2.0)
48
+ rspec-mocks (2.14.4)
49
+ ruby_cop (1.0.5)
50
+ sexpr (0.6.0)
51
+ sinatra (1.4.4)
52
+ rack (~> 1.4)
53
+ rack-protection (~> 1.4)
54
+ tilt (~> 1.3, >= 1.3.4)
55
+ sprockets (2.10.0)
56
+ hike (~> 1.2)
57
+ multi_json (~> 1.0)
58
+ rack (~> 1.0)
59
+ tilt (~> 1.1, != 1.3.0)
60
+ temple (0.6.7)
61
+ tilt (1.4.1)
62
+ wlang (2.2.3)
63
+ backports (~> 2.6)
64
+ citrus (~> 2.4.1)
65
+ path (~> 1.3)
66
+ quickl (~> 0.4.3)
67
+ temple (~> 0.6)
68
+
69
+ PLATFORMS
70
+ ruby
71
+
72
+ DEPENDENCIES
73
+ alf-core!
74
+ alf-rack!
75
+ rack (~> 1.5)
76
+ rack-robustness (~> 1.1)
77
+ rack-test (~> 0.6.1)
78
+ rake (~> 10.1)
79
+ rspec (~> 2.14)
80
+ sinatra (~> 1.4)
81
+ sprockets (~> 2.10)
82
+ wlang (~> 2.2)
data/LICENCE.md ADDED
@@ -0,0 +1,22 @@
1
+ # The MIT Licence
2
+
3
+ Copyright (c) 2013 - Bernard Lambeau
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/Manifest.txt ADDED
@@ -0,0 +1,12 @@
1
+ repl.gemspec
2
+ repl.noespec
3
+ CHANGELOG.md
4
+ Gemfile
5
+ Gemfile.lock
6
+ lib/**/*
7
+ LICENCE.md
8
+ Manifest.txt
9
+ Rakefile
10
+ README.md
11
+ spec/**/*
12
+ tasks/**/*
data/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # Alf::Repl
2
+
3
+ [![Build Status](https://secure.travis-ci.org/alf-tool/alf-repl.png)](http://travis-ci.org/blambeau/alf-repl)
4
+ [![Dependency Status](https://gemnasium.com/alf-tool/alf-repl.png)](https://gemnasium.com/blambeau/alf-repl)
5
+
6
+ Read-Eval-Print-Loop (web) for Alf
7
+
8
+ ## Links
9
+
10
+ http://github.com/blambeau/alf-sql
11
+ http://github.com/blambeau/alf
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ # We run tests by default
2
+ task :default => :test
3
+
4
+ #
5
+ # Install all tasks found in tasks folder
6
+ #
7
+ # See .rake files there for complete documentation.
8
+ #
9
+ Dir["tasks/*.rake"].each do |taskfile|
10
+ load taskfile
11
+ end
data/lib/alf-repl.rb ADDED
@@ -0,0 +1 @@
1
+ require_relative "alf/repl"
data/lib/alf/repl.rb ADDED
@@ -0,0 +1,30 @@
1
+ require_relative 'repl/version'
2
+ require_relative 'repl/loader'
3
+ module Alf
4
+ module Repl
5
+
6
+ def self.database
7
+ @database ||= begin
8
+ adapter = ENV['DATABASE_URL']
9
+ adapter = Alf.examples_adapter unless adapter
10
+ raise "No database found" unless adapter
11
+ Alf::Database.new(adapter)
12
+ end
13
+ end
14
+
15
+ def self.database=(db)
16
+ @database = db
17
+ end
18
+
19
+ def self.launch
20
+ require_relative 'repl/service'
21
+ x = Class.new(Sinatra::Base) do
22
+ def call(env)
23
+ Alf::Repl::Service.call(env)
24
+ end
25
+ end
26
+ x.run!
27
+ end
28
+
29
+ end # module Repl
30
+ end # module Alf
File without changes
@@ -0,0 +1,29 @@
1
+ module Rack
2
+ class Nocache
3
+
4
+ def initialize(app)
5
+ @app = app
6
+ end
7
+
8
+ def call(env)
9
+ status, headers, body = @app.call(patch_request_headers(env))
10
+ [status, patch_response_headers(headers), body]
11
+ end
12
+
13
+ protected
14
+ CACHE_BUSTER = {
15
+ "Cache-Control" => "no-cache, no-store, max-age=0, must-revalidate",
16
+ "Pragma" => "no-cache",
17
+ "Expires" => "Fri, 29 Aug 1997 02:14:00 EST"
18
+ }
19
+
20
+ def patch_request_headers(env)
21
+ env.reject{|k,v| k =~ /^HTTP_IF/i }
22
+ end
23
+
24
+ def patch_response_headers(env)
25
+ env.reject{|k,v| k =~ /^ETag$/i }.merge(CACHE_BUSTER)
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,46 @@
1
+ require "alf-core"
2
+ require "alf-rack"
3
+ require "alf/rack/query"
4
+ require "rack"
5
+ require "rack/robustness"
6
+ require "sprockets"
7
+
8
+ require_relative 'nocache'
9
+ require_relative 'webapp'
10
+
11
+ module Alf
12
+ module Repl
13
+ Service = ::Rack::Builder.new do
14
+
15
+ # Log everything on STDOUT
16
+ use ::Rack::CommonLogger
17
+
18
+ # Serve the assets through Sprockets
19
+ map '/assets' do
20
+ environment = Sprockets::Environment.new
21
+ environment.append_path Path.backfind('assets/css')
22
+ environment.append_path Path.backfind('assets/js')
23
+ run environment
24
+ end
25
+
26
+ # Deploy the query ability under /query
27
+ map '/query' do
28
+ use ::Rack::Robustness do |g|
29
+ g.status 400
30
+ g.content_type "text/plain"
31
+ g.body{|ex| ex.message }
32
+ end
33
+ use ::Rack::Nocache
34
+ use ::Alf::Rack::Connect do |cfg|
35
+ cfg.database = Repl.database
36
+ end
37
+ run ::Alf::Rack::Query.new{|q|
38
+ q.type_check = false
39
+ q.catch_all = false
40
+ }
41
+ end
42
+
43
+ run WebApp
44
+ end # Service
45
+ end # module Repl
46
+ end # module Alf
@@ -0,0 +1,16 @@
1
+ module Alf
2
+ module Repl
3
+ module Version
4
+
5
+ MAJOR = 0
6
+ MINOR = 16
7
+ TINY = 0
8
+
9
+ def self.to_s
10
+ [ MAJOR, MINOR, TINY ].join('.')
11
+ end
12
+
13
+ end
14
+ VERSION = Version.to_s
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ require 'sinatra/base'
2
+ require "wlang"
3
+ require "wlang/tilt"
4
+ module Alf
5
+ module Repl
6
+ class WebApp < Sinatra::Base
7
+ set :public_folder, Path.backfind('public')
8
+ set :views, Path.backfind('views')
9
+ set :raise_errors, true
10
+ set :show_exceptions, false
11
+ set :dump_errors, true
12
+ set :wlang, {layout: :html5}
13
+
14
+ get '/' do
15
+ wlang :repl
16
+ end
17
+
18
+ end # class WebApp
19
+ end # module Repl
20
+ end # module Alf
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+ module Alf
3
+ module Repl
4
+ describe Service, "assets" do
5
+ include ::Rack::Test::Methods
6
+
7
+ def app
8
+ Service
9
+ end
10
+
11
+ it 'serves css correctly' do
12
+ get '/assets/style.css'
13
+ last_response.should be_ok
14
+ last_response.content_type.should =~ /text\/css/
15
+ end
16
+
17
+ it 'serves js correctly' do
18
+ get '/assets/application.js'
19
+ last_response.should be_ok
20
+ last_response.content_type.should =~ /application\/javascript/
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+ module Alf
3
+ module Repl
4
+ describe Service, "get /" do
5
+ include ::Rack::Test::Methods
6
+
7
+ def app
8
+ Service
9
+ end
10
+
11
+ subject{
12
+ get('/')
13
+ }
14
+
15
+ before do
16
+ subject
17
+ end
18
+
19
+ it 'serves html correctly' do
20
+ last_response.should be_ok
21
+ last_response.content_type.should =~ /text\/html/
22
+ end
23
+
24
+ it 'composes the repl' do
25
+ last_response.body.should =~ /<html/
26
+ last_response.body.should =~ /QueryController/
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,14 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'alf-repl'
3
+ require 'alf/repl/service'
4
+ require "rspec"
5
+ require 'rack/test'
6
+
7
+ module Helpers
8
+ end
9
+
10
+ RSpec.configure do |c|
11
+ c.include Helpers
12
+ c.extend Helpers
13
+ c.filter_run_excluding :ruby19 => (RUBY_VERSION < "1.9")
14
+ end
data/tasks/gem.rake ADDED
@@ -0,0 +1,8 @@
1
+ require 'rubygems/package_task'
2
+ gemspec_file = File.expand_path('../../alf-repl.gemspec', __FILE__)
3
+ gemspec = Kernel.eval(File.read(gemspec_file))
4
+ Gem::PackageTask.new(gemspec) do |t|
5
+ t.name = gemspec.name
6
+ t.version = gemspec.version
7
+ t.package_files = gemspec.files
8
+ end
data/tasks/test.rake ADDED
@@ -0,0 +1,6 @@
1
+ require "rspec/core/rake_task"
2
+ desc "Run tests"
3
+ RSpec::Core::RakeTask.new(:test) do |t|
4
+ t.pattern = "spec/**/test_*.rb"
5
+ t.rspec_opts = ["--color"]
6
+ end
metadata ADDED
@@ -0,0 +1,230 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alf-repl
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.16.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Bernard Lambeau
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-02-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '10.1'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '10.1'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '2.14'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.14'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rack-test
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.6.1
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.6.1
62
+ - !ruby/object:Gem::Dependency
63
+ name: sinatra
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '1.4'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '1.4'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rack
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '1.5'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '1.5'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rack-robustness
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '1.1'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '1.1'
110
+ - !ruby/object:Gem::Dependency
111
+ name: wlang
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '2.2'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '2.2'
126
+ - !ruby/object:Gem::Dependency
127
+ name: sprockets
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: '2.10'
134
+ type: :runtime
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: '2.10'
142
+ - !ruby/object:Gem::Dependency
143
+ name: alf-core
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - '='
148
+ - !ruby/object:Gem::Version
149
+ version: 0.16.0
150
+ type: :runtime
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - '='
156
+ - !ruby/object:Gem::Version
157
+ version: 0.16.0
158
+ - !ruby/object:Gem::Dependency
159
+ name: alf-rack
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - '='
164
+ - !ruby/object:Gem::Version
165
+ version: 0.16.0
166
+ type: :runtime
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 0.16.0
174
+ description: This project provides a Alf-driven web REPL to any database
175
+ email:
176
+ - blambeau at gmail.com
177
+ executables: []
178
+ extensions: []
179
+ extra_rdoc_files: []
180
+ files:
181
+ - CHANGELOG.md
182
+ - Gemfile
183
+ - Gemfile.lock
184
+ - lib/alf/repl/loader.rb
185
+ - lib/alf/repl/nocache.rb
186
+ - lib/alf/repl/service.rb
187
+ - lib/alf/repl/version.rb
188
+ - lib/alf/repl/webapp.rb
189
+ - lib/alf/repl.rb
190
+ - lib/alf-repl.rb
191
+ - LICENCE.md
192
+ - Manifest.txt
193
+ - Rakefile
194
+ - README.md
195
+ - spec/service/test_assets.rb
196
+ - spec/service/test_index.rb
197
+ - spec/spec_helper.rb
198
+ - tasks/gem.rake
199
+ - tasks/test.rake
200
+ homepage: http://github.com/blambeau/alf-sql
201
+ licenses: []
202
+ post_install_message:
203
+ rdoc_options: []
204
+ require_paths:
205
+ - lib
206
+ required_ruby_version: !ruby/object:Gem::Requirement
207
+ none: false
208
+ requirements:
209
+ - - ! '>='
210
+ - !ruby/object:Gem::Version
211
+ version: '0'
212
+ segments:
213
+ - 0
214
+ hash: -1468653037871803550
215
+ required_rubygems_version: !ruby/object:Gem::Requirement
216
+ none: false
217
+ requirements:
218
+ - - ! '>='
219
+ - !ruby/object:Gem::Version
220
+ version: '0'
221
+ segments:
222
+ - 0
223
+ hash: -1468653037871803550
224
+ requirements: []
225
+ rubyforge_project:
226
+ rubygems_version: 1.8.25
227
+ signing_key:
228
+ specification_version: 3
229
+ summary: Read-Eval-Print-Loop (web) for Alf
230
+ test_files: []