track 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -23,6 +23,20 @@ or install it via rubygems
23
23
 
24
24
  `gem install track`
25
25
 
26
+ ## Install example application
27
+
28
+ Clone the [http://github.com/larskuhnt/track-example](track-example) project:
29
+
30
+ ```
31
+ git clone https://github.com/larskuhnt/track-example.git
32
+ ```
33
+
34
+ or install it via the gem executable
35
+
36
+ ```
37
+ track new my_track_project
38
+ ```
39
+
26
40
  ## Usage
27
41
 
28
42
  Subclass the `Track::Controller` class to define controllers:
@@ -61,6 +75,15 @@ You can build arbitrary path match patterns by using regaular expressions.
61
75
 
62
76
  The `pre` method calls a method prior to the action. If `fail` is called in before filter method the action will not get called and the given response will be returned.
63
77
 
78
+ ## Plugins
79
+
80
+ Currently available:
81
+
82
+ * ActiveRecord
83
+ * Sequel
84
+
85
+ Go to the [track-plugins](http://www.github.com/larskuhnt/track-plugins) project for more details.
86
+
64
87
  ## Author
65
88
 
66
89
  [Lars Kuhnt](http://www.github.com/larskuhnt)
data/lib/track.rb CHANGED
@@ -3,15 +3,16 @@ require 'track/controller'
3
3
 
4
4
  module Track
5
5
 
6
- @@env = ENV['RACK_ENV'].to_sym.freeze
7
- @@config = nil
8
- @@root = nil
6
+ @@env = ENV['RACK_ENV'].to_sym.freeze
7
+ @@config = nil
8
+ @@root = nil
9
+ @@plugins = []
9
10
 
10
11
  class << self
11
12
  def boot!(root)
12
13
  @@root = root
13
14
  @@config = load_config_file!(:config)
14
- DB.connect! if defined?(DB)
15
+ boot_plugins!
15
16
  end
16
17
 
17
18
  def [](key)
@@ -38,6 +39,10 @@ module Track
38
39
  VERSION
39
40
  end
40
41
 
42
+ def use(plugin)
43
+ @@plugins << plugin
44
+ end
45
+
41
46
  def load_config_file!(filename)
42
47
  begin
43
48
  YAML.load(File.open(File.join(root, 'config', "#{filename}.yml")))[env.to_s]
@@ -46,5 +51,9 @@ module Track
46
51
  YAML.load(File.open(File.join(root, 'config', "#{filename}.example.yml")))[env.to_s]
47
52
  end
48
53
  end
54
+
55
+ def boot_plugins!
56
+ @@plugins.each { |plugin| plugin.boot! }
57
+ end
49
58
  end
50
59
  end
data/lib/track/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Track
2
- VERSION = '0.2.3'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: track
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-09 00:00:00.000000000Z
12
+ date: 2011-12-10 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
16
- requirement: &70166160483100 !ruby/object:Gem::Requirement
16
+ requirement: &70223625727700 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70166160483100
24
+ version_requirements: *70223625727700
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70166160482420 !ruby/object:Gem::Requirement
27
+ requirement: &70223625725260 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70166160482420
35
+ version_requirements: *70223625725260
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rack-test
38
- requirement: &70166160481700 !ruby/object:Gem::Requirement
38
+ requirement: &70223625719580 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70166160481700
46
+ version_requirements: *70223625719580
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: active_record
49
- requirement: &70166160481280 !ruby/object:Gem::Requirement
49
+ requirement: &70223625717640 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70166160481280
57
+ version_requirements: *70223625717640
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: thor
60
- requirement: &70166160480780 !ruby/object:Gem::Requirement
60
+ requirement: &70223625715720 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70166160480780
68
+ version_requirements: *70223625715720
69
69
  description: Nano framework to build small server applications based on rack and ruby
70
70
  1.9
71
71
  email:
@@ -77,7 +77,6 @@ extra_rdoc_files: []
77
77
  files:
78
78
  - lib/track/controller.rb
79
79
  - lib/track/filter_map.rb
80
- - lib/track/orm/active_record.rb
81
80
  - lib/track/route_map.rb
82
81
  - lib/track/version.rb
83
82
  - lib/track.rb
@@ -1,29 +0,0 @@
1
- require 'active_record'
2
-
3
- module Track
4
- module DB
5
-
6
- @@config = nil
7
-
8
- class << self
9
-
10
- def [](key)
11
- @@config[key.to_s]
12
- end
13
-
14
- def connected?
15
- ActiveRecord::Base.connected?
16
- end
17
-
18
- def connect!
19
- @@config = Track.load_config_file!('database') if @@config.nil?
20
- unless connected?
21
- ActiveRecord::Base.establish_connection(@@config)
22
- ActiveRecord::Base.connection
23
- end
24
- end
25
-
26
- end
27
-
28
- end
29
- end