fringe 0.0.11 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8dc6146656d8fd9d869f687d6db08b4558ea522b
4
- data.tar.gz: 9712205b24318aee25500ff5de159d645b0a0b42
3
+ metadata.gz: a2dd12601102e9d02d2844129a3c436a2ec208cf
4
+ data.tar.gz: d452d98e9f76804df035dc17cc001da4dc78196f
5
5
  SHA512:
6
- metadata.gz: 88c34535146a414f1b2f2309eb04fbe243af3409bc0ccfbccd2f717ac474415a1225fe12fa0cd331a3d1caff0e0f8df76dce8fbec19b350c0660e5f6b6bc1fa5
7
- data.tar.gz: e7d1378809284eb0e3b64e2e55589f7d48e175a0f79bc71354f56c6460709fa761e78fae58745baf155dd74b486faad4986c10c80fb4dca7bb606b585a3203dc
6
+ metadata.gz: 48f173fdead7e3288b81c7692572a40946f689d267b3175eec63aa473d0f87599fc923a9492b18ce137cc9d8b5ee92444c6e73751b4021d28e464f9d31f660a3
7
+ data.tar.gz: 49e85552b9252deb5d96e348dcc44a99d5220d73a0920c76519727605110006d3d1396c05d6e054f2f9b89a8ac313eef9dce429861c142d03d6c01f4421ef2a8
data/README.md CHANGED
@@ -1,2 +1,43 @@
1
+ ## Installation
2
+
3
+ * `gem install fringe`
4
+ * `fringe new app`
5
+ * `cd app`
6
+ * `bundle`
7
+ * `rackup`
8
+
9
+ ## Example
10
+
11
+ *HelloWorldController* `app/controllers/hello_world_controller.rb`
12
+ ```
13
+ class HelloWorldController < Fringe::BaseController
14
+ def greeting
15
+ [
16
+ 200,
17
+ {'Content-Type' => 'text/plain'},
18
+ [
19
+ 'Hello, World!'
20
+ ]
21
+ ]
22
+ end
23
+ end
24
+ ```
25
+
26
+ *Routes* `app/routes.rb`
27
+ ```
28
+ module Routes
29
+ extend Fringe::RouteHelpers
30
+ get(/\/greet/i, HelloWorldController, :greeting)
31
+ end
32
+ ```
33
+ start the app!
34
+ `rackup`
35
+
36
+ ```
37
+ > curl http://localhost:9292/greet
38
+ Hello, World!
39
+ ```
40
+
41
+
1
42
  ## License
2
43
  Fringe is released under the [MIT License](http://www.opensource.org/licenses/MIT).
@@ -0,0 +1,31 @@
1
+ class String
2
+ require 'json'
3
+ # Barrow these from ActiveSupport
4
+ def camelize(uppercase_first_letter = true)
5
+ string = self.dup
6
+ if uppercase_first_letter
7
+ string = string.sub(/^[a-z\d]*/) { $&.capitalize }
8
+ end
9
+ string.gsub(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{$2.capitalize}" }.gsub('/', '::')
10
+ end
11
+
12
+ def underscore
13
+ word = self.dup
14
+ word.gsub!('::', '/')
15
+ word.gsub!(/(?:([A-Za-z\d])|^)((?=a)b)(?=\b|[^a-z])/) { "#{$1}#{$1 && '_'}#{$2.downcase}" }
16
+ word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
17
+ word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
18
+ word.tr!("-", "_")
19
+ word.downcase!
20
+ word
21
+ end
22
+
23
+ def constantize
24
+ Object.const_get(self)
25
+ end
26
+
27
+ # Custom additions
28
+ def from_json
29
+ JSON.parse(self)
30
+ end
31
+ end
@@ -1 +1,2 @@
1
+ require 'ext/string'
1
2
  Dir[File.join(File.dirname(__FILE__), 'fringe', '**', '*.rb')].each {|file| require file }
@@ -45,20 +45,31 @@ module Fringe
45
45
  require("#{@@app_dir}/config/initializers/#{file_name}")
46
46
  end
47
47
  end
48
+ model_files = []
48
49
  Dir["#{@@app_dir}/app/models/*.rb"].each do |file|
49
50
  match = file.match(/\/([^\/.]+)\.rb$/)
50
51
  if match
51
52
  file_name = match[1]
53
+ model_files << file_name
52
54
  autoload(file_name.camelize.to_sym, file)
53
55
  end
54
56
  end
57
+ model_files.each do |file_name|
58
+ require("#{@@app_dir}/app/models/#{file_name}")
59
+ end
60
+ require("#{@@app_dir}/app/controllers/application_controller")
61
+ controller_files = []
55
62
  Dir["#{@@app_dir}/app/controllers/*.rb"].each do |file|
56
63
  match = file.match(/\/([^\/.]+)\.rb$/)
57
64
  if match
58
65
  file_name = match[1]
59
- require("#{@@app_dir}/app/controllers/#{file_name}")
66
+ controller_files << file_name
67
+ autoload(file_name.camelize.to_sym, file)
60
68
  end
61
69
  end
70
+ controller_files.each do |file_name|
71
+ require("#{@@app_dir}/app/controllers/#{file_name}")
72
+ end
62
73
 
63
74
  require("#{@@app_dir}/app/routes")
64
75
  end
@@ -1,3 +1,3 @@
1
1
  module Fringe
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.16"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fringe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Hecht
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-22 00:00:00.000000000 Z
11
+ date: 2015-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -73,6 +73,7 @@ files:
73
73
  - bin/scaffold/config.ru
74
74
  - bin/scaffold/config/initializers/.gitignore
75
75
  - fringe.gemspec
76
+ - lib/ext/string.rb
76
77
  - lib/fringe.rb
77
78
  - lib/fringe/server.rb
78
79
  - lib/fringe/version.rb