sharp 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +3 -0
- data/Rakefile +1 -0
- data/bin/sharp +13 -0
- data/lib/sharp.rb +78 -0
- data/lib/sharp/version.rb +3 -0
- data/sharp.gemspec +20 -0
- metadata +105 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm 1.9.3@sharp --create
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Paul Barry
|
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
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/sharp
ADDED
data/lib/sharp.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require "sharp/version"
|
2
|
+
require "logger"
|
3
|
+
require "pathname"
|
4
|
+
require "rack-action"
|
5
|
+
require "rack-router"
|
6
|
+
require "yaml"
|
7
|
+
|
8
|
+
module Sharp
|
9
|
+
|
10
|
+
class << self
|
11
|
+
delegate :logger, :boot, :root, :router, :env, :db, :to => :app
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.app(*args, &init_routes)
|
15
|
+
if args.length == 0
|
16
|
+
@app
|
17
|
+
else
|
18
|
+
@app = Application.new(*args, &init_routes)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Application
|
23
|
+
attr_reader :root, :router
|
24
|
+
|
25
|
+
def initialize(root, &init_routes)
|
26
|
+
@root = Pathname.new(root)
|
27
|
+
@init_routes = init_routes
|
28
|
+
end
|
29
|
+
|
30
|
+
def logger
|
31
|
+
@logger ||= Logger.new(STDOUT)
|
32
|
+
end
|
33
|
+
|
34
|
+
def boot
|
35
|
+
if @booted
|
36
|
+
false
|
37
|
+
else
|
38
|
+
preboot
|
39
|
+
$:.unshift(root.join("lib/models"))
|
40
|
+
Dir.glob(root.join("lib/models/*.rb")) {|file| require file }
|
41
|
+
$:.unshift(root.join("lib/actions"))
|
42
|
+
Dir.glob(root.join("lib/actions/*.rb")) {|file| require file }
|
43
|
+
@booted = true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def preboot
|
48
|
+
# A hook for plugins to add boot logic
|
49
|
+
db # TODO: Pull out Sequel-specific code
|
50
|
+
end
|
51
|
+
|
52
|
+
def router
|
53
|
+
@router ||= begin
|
54
|
+
boot
|
55
|
+
Rack::Router.new(&@init_routes)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def env
|
60
|
+
@env ||= ENV['RACK_ENV'].present? ? ENV['RACK_ENV'].to_sym : :development
|
61
|
+
end
|
62
|
+
|
63
|
+
#TODO: Pull out Sequel-specific code
|
64
|
+
def db
|
65
|
+
@db ||= begin
|
66
|
+
db_config.inject({}) do |acc, (key, value)|
|
67
|
+
acc[key] = Sequel.connect(value.merge(:logger => logger))
|
68
|
+
Sequel::Model.db = acc[key] if key == :default
|
69
|
+
acc
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def db_config
|
75
|
+
@db_config ||= YAML.load_file(root.join("config/database.yml")).symbolize_keys[env].symbolize_keys
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/sharp.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = "sharp"
|
5
|
+
gem.version = "0.0.1"
|
6
|
+
gem.authors = ["Paul Barry"]
|
7
|
+
gem.email = ["mail@paulbarry.com"]
|
8
|
+
gem.description = %q{A web framework}
|
9
|
+
gem.summary = %q{A web framework}
|
10
|
+
gem.homepage = ""
|
11
|
+
|
12
|
+
gem.files = `git ls-files`.split($/)
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
|
17
|
+
gem.add_runtime_dependency "activesupport"
|
18
|
+
gem.add_runtime_dependency "rack-router"
|
19
|
+
gem.add_runtime_dependency "rack-action"
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sharp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Paul Barry
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
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: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rack-router
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '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: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rack-action
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
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: '0'
|
62
|
+
description: A web framework
|
63
|
+
email:
|
64
|
+
- mail@paulbarry.com
|
65
|
+
executables:
|
66
|
+
- sharp
|
67
|
+
extensions: []
|
68
|
+
extra_rdoc_files: []
|
69
|
+
files:
|
70
|
+
- .gitignore
|
71
|
+
- .rvmrc
|
72
|
+
- Gemfile
|
73
|
+
- LICENSE.txt
|
74
|
+
- README.md
|
75
|
+
- Rakefile
|
76
|
+
- bin/sharp
|
77
|
+
- lib/sharp.rb
|
78
|
+
- lib/sharp/version.rb
|
79
|
+
- sharp.gemspec
|
80
|
+
homepage: ''
|
81
|
+
licenses: []
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 1.8.24
|
101
|
+
signing_key:
|
102
|
+
specification_version: 3
|
103
|
+
summary: A web framework
|
104
|
+
test_files: []
|
105
|
+
has_rdoc:
|