rhino-framework 0.0.4 → 0.1.1

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: 492876e8b44ac07720daaa2f0f21da53899a3c83
4
- data.tar.gz: ba4db5600b64551d69bf934537b7fe11e6422436
3
+ metadata.gz: 412ba9a96517119ba80bc654b3deed90e37c30f9
4
+ data.tar.gz: ed58a073c98123dc03d5aebe4624d35be1ad5923
5
5
  SHA512:
6
- metadata.gz: 24279bbf2b49923991899d273694cc563be92e7fa2455efb432d66e3ee885f0bcbce16204df18002fbb3eee7d738258bcf55aae2aa2d735a393c15d5629bc2be
7
- data.tar.gz: d8ad14a65bbeb15242b0c1c1de5c01b67d92e9ef4340686b8bb5851b29e76fb25695ff8eda7002dfb5d0ac20e2599fe0dc765b43f1b7c46cd8357591a820719a
6
+ metadata.gz: 5d27191222b7f3cea729bcbcc2731744aef3a43d4e3575fab3be510287c8ca845c88b126eb5a5f2c45a8378990f0bda30d2325ba5d493be242cb72056d92a0b3
7
+ data.tar.gz: f3709ccdbd9817d20c16fb12603848eac6903f0622e9e9fde5ec4a03dfaca488c0e76465db7de23e1f0c634e6b5cd24a0747ddc51fdeda55927ca5a675a5008e
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rhino/cli'
4
+ Rhino::Cli.new(ARGV).run
@@ -1,42 +1,21 @@
1
+ require 'yaml'
1
2
  require "rhino/version"
2
3
  require "rhino/routing"
3
4
  require "rhino/util"
4
5
  require "rhino/dependencies"
5
6
  require "rhino/controller"
6
7
  require "rhino/file_model"
8
+ require "rhino/sqlite_model"
7
9
 
8
10
  module Rhino
9
-
10
11
  class Application
11
-
12
12
  def call(env)
13
- klass, act = get_controller_and_action(env)
14
- controller = klass.new(env)
15
- text = controller.send(act) rescue (return action_not_found)
16
- [200, {'Content-Type' => 'text/html'}, [text]]
17
- rescue LoadError => e
18
- return error_404(e)
19
- rescue => e # StandardError
20
- return error_500(e)
21
- end
22
-
23
- def error_404(error)
24
- [404, {'Content-Type' => 'text/html'}, ["The page not found ! <br/> <b>#{error.message}</b>"]]
13
+ if env['PATH_INFO'] == '/favicon.ico'
14
+ return [404,
15
+ {'Content-Type' => 'text/html'}, []]
16
+ end
17
+ rack_app = get_rack_app(env)
18
+ rack_app.call(env)
25
19
  end
26
-
27
- def action_not_found
28
- [404, {'Content-Type' => 'text/html'}, ['The action not found !']]
29
- end
30
-
31
- def error_500(error)
32
- [500, {'Content-Type' => 'text/html'}, ["Some thing went wrong ! <br/> <b>#{error.message}</b>"]]
33
- end
34
-
35
- def self.root_path
36
- "/home/buikhanh/projects/my_projects/ruby-framework/best_quotes/"
37
- end
38
-
39
20
  end
40
-
41
-
42
21
  end
@@ -0,0 +1,40 @@
1
+ module Rhino
2
+ class Cli
3
+ def initialize(args)
4
+ @args = args
5
+ @template_path = File.join(File.dirname(__FILE__), 'generators', 'template_codes')
6
+ end
7
+
8
+ def run
9
+ if @args[0] == 'new' && !@args[1].nil?
10
+ new_app(@args[1])
11
+ end
12
+ end
13
+
14
+ def new_app(app_name)
15
+ structure_path = @template_path + '/structure'
16
+ FileUtils.cp_r structure_path, app_name
17
+ create_application_file(app_name)
18
+ create_config_file(app_name)
19
+ p "created app `#{app_name}`"
20
+ end
21
+
22
+ def create_application_file(app_name)
23
+ template_file = File.read(@template_path + '/application.rb.tt')
24
+ new_file_content = template_file.gsub('{{app_name}}', module_app_name(app_name))
25
+ File.open("#{app_name}/config/application.rb", 'w') {|file| file.puts new_file_content }
26
+ end
27
+
28
+ def create_config_file(app_name)
29
+ template_file = File.read(@template_path + '/config.ru.tt')
30
+ new_file_content = template_file.gsub('{{app_name}}', module_app_name(app_name))
31
+ File.open("#{app_name}/config.ru", 'w') {|file| file.puts new_file_content }
32
+ end
33
+
34
+ # convert from string to module_name: 'new_app' => 'NewApp'
35
+ def module_app_name(name)
36
+ name.split("_").map!{|x| x.capitalize}.join
37
+ end
38
+
39
+ end
40
+ end
@@ -8,14 +8,48 @@ module Rhino
8
8
 
9
9
  def initialize(env)
10
10
  @env = env
11
+ @routing_params = {}
12
+ end
13
+
14
+ def dispatch(action, routing_params = {})
15
+ @routing_params = routing_params
16
+ text = self.send(action)
17
+ if get_response
18
+ st, hd, rs = get_response.to_a
19
+ [st, hd, [rs].flatten]
20
+ else
21
+ [200, {'Context-Type' => 'text/html'}, [text].flatten]
22
+ end
23
+ end
24
+
25
+ def self.action(act, rp = {})
26
+ proc {|e| self.new(e).dispatch(act, rp)}
11
27
  end
12
28
 
13
29
  def env
14
30
  @env
15
31
  end
16
32
 
33
+ def request
34
+ @request ||= Rack::Request.new(@env)
35
+ end
36
+
37
+ def response(text, status=200, headers = {})
38
+ raise "Already responded!" if @response
39
+ a = [text].flatten
40
+ @response = Rack::Response.new(a, status, headers)
41
+ end
42
+
43
+ def get_response
44
+ @response
45
+ end
46
+
47
+ def params
48
+ request.params.merge(@routing_params)
49
+ end
50
+
17
51
  def render(view_name, locals={})
18
- file_name = File.join Rhino::Application.root_path, 'app', 'views', controller_name, "#{view_name}.html.erb"
52
+ file_name = File.join 'app', 'views', controller_name, "#{view_name}.html.erb"
19
53
  template = File.read file_name
20
54
  eruby = Erubis::Eruby.new(template)
21
55
  eruby.result locals.merge(env: env)
@@ -22,13 +22,13 @@ module Rhino
22
22
  end
23
23
 
24
24
  def self.find(id)
25
- FileModel.new(Rhino::Application.root_path + "/db/quotes/#{id}.json")
25
+ FileModel.new("db/quotes/#{id}.json")
26
26
  rescue
27
27
  nil
28
28
  end
29
29
 
30
30
  def self.all
31
- files = Dir[Rhino::Application.root_path + '/db/quotes/*.json']
31
+ files = Dir['db/quotes/*.json']
32
32
  files.map{|f| FileModel.new f}.select{|x| !x.nil? }
33
33
  end
34
34
 
@@ -0,0 +1,8 @@
1
+ require 'rhino'
2
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'app', 'controllers')
3
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'app', 'models')
4
+
5
+ module {{app_name}}
6
+ class Application < Rhino::Application
7
+ end
8
+ end
@@ -0,0 +1,17 @@
1
+ require './config/application'
2
+
3
+ app = {{app_name}}::Application.new
4
+
5
+ use Rack::ContentType
6
+
7
+ app.route do
8
+ # default routes
9
+ match "", proc { [200, {}, ["Congratulation! You're running a application based on Rhino-Framework"]] }
10
+ match ":controller/:id/:action"
11
+ match ":controller/:id",
12
+ :default => { "action" => "show" }
13
+ match ":controller",
14
+ :default => { "action" => "index" }
15
+ end
16
+
17
+ run app
@@ -0,0 +1,17 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'rhino-framework'
4
+ gem 'rack'
5
+ gem 'bundler'
6
+
7
+ group :development do
8
+ gem 'thin'
9
+ gem 'rerun'
10
+ gem 'test-unit', '~> 3.0'
11
+ gem 'minitest', '~> 5.5'
12
+ gem 'rack-test', '~> 0.6'
13
+ gem 'better_errors'
14
+ gem 'pry'
15
+ end
16
+
17
+
@@ -0,0 +1,6 @@
1
+ # default using sqlite3 for database
2
+ # please install sqlite3 server first
3
+
4
+ database:
5
+ name: database.db
6
+
@@ -1,9 +1,95 @@
1
+ class RouteObject
2
+ def initialize
3
+ @rules = []
4
+ end
5
+
6
+ def match(url, *args)
7
+ options = {}
8
+ options = args.pop if args[-1].is_a?(Hash)
9
+ options[:default] ||= {}
10
+
11
+ dest = nil
12
+ dest = args.pop if args.size > 0
13
+ raise "Too many args!" if args.size > 0
14
+
15
+ parts = url.split("/")
16
+ parts.select! { |p| !p.empty? }
17
+
18
+ vars = []
19
+ regexp_parts = parts.map do |part|
20
+ if part[0] == ":"
21
+ vars << part[1..-1]
22
+ "([a-zA-Z0-9]+)"
23
+ elsif part[0] == "*"
24
+ vars << part[1..-1]
25
+ "(.*)"
26
+ else
27
+ part
28
+ end
29
+ end
30
+
31
+ regexp = regexp_parts.join("/")
32
+ @rules.push({
33
+ :regexp => Regexp.new("^/#{regexp}$"),
34
+ :vars => vars,
35
+ :dest => dest,
36
+ :options => options,
37
+ })
38
+ end
39
+
40
+ def check_url(url)
41
+ @rules.each do |r|
42
+ m = r[:regexp].match(url)
43
+
44
+ if m
45
+ options = r[:options]
46
+ params = options[:default].dup
47
+ r[:vars].each_with_index do |v, i|
48
+ params[v] = m.captures[i]
49
+ end
50
+ dest = nil
51
+ if r[:dest]
52
+ return get_dest(r[:dest], params)
53
+ else
54
+ controller = params["controller"]
55
+ action = params["action"]
56
+ return get_dest("#{controller}" +
57
+ "##{action}", params)
58
+ end
59
+ end
60
+ end
61
+
62
+ nil
63
+ end
64
+
65
+ def get_dest(dest, routing_params = {})
66
+ return dest if dest.respond_to?(:call)
67
+ if dest =~ /^([^#]+)#([^#]+)$/
68
+ name = $1.capitalize
69
+ cont = Object.const_get("#{name}Controller")
70
+ return cont.action($2, routing_params)
71
+ end
72
+ raise "No destination: #{dest.inspect}!"
73
+ end
74
+ end
75
+
1
76
  module Rhino
2
77
  class Application
78
+ def route(&block)
79
+ @route_obj ||= RouteObject.new
80
+ @route_obj.instance_eval(&block)
81
+ end
82
+
83
+ def get_rack_app(env)
84
+ raise "No routes!" unless @route_obj
85
+ @route_obj.check_url env["PATH_INFO"]
86
+ end
87
+
3
88
  def get_controller_and_action(env)
4
- _, cont, action, after = env['PATH_INFO'].split("/", 4)
5
- cont = cont.capitalize
6
- cont += "Controller"
89
+ _, cont, action, after =
90
+ env["PATH_INFO"].split('/', 4)
91
+ cont = cont.capitalize # "People"
92
+ cont += "Controller" # "PeopleController"
7
93
 
8
94
  [Object.const_get(cont), action]
9
95
  end
@@ -0,0 +1,109 @@
1
+ require 'sqlite3'
2
+ require 'rhino/util'
3
+
4
+ # initialize database. Only for sqlite 3
5
+ config_database = YAML.load_file('config/database.yml')
6
+ DB = SQLite3::Database.new("db/" + config_database['database']['name'])
7
+
8
+ module Rhino
9
+ module Model
10
+ class SQLite
11
+
12
+ def initialize(data = {})
13
+ @hash = data
14
+ end
15
+
16
+ def self.to_sql(val)
17
+ case val
18
+ when Numeric
19
+ val.to_s
20
+ when String
21
+ "'#{val}'"
22
+ else
23
+ raise "Can't change #{val.class} to SQL"
24
+ end
25
+ end
26
+
27
+ def self.find(id)
28
+ row = DB.execute("
29
+ SELECT #{schema.keys.join(',')} from #{table} where id = #{id};
30
+ ")
31
+ mapping_data row[0]
32
+ end
33
+
34
+ def self.all
35
+ rows = DB.execute("SELECT #{schema.keys.join(',')} from #{table};")
36
+ rows.map {|row| mapping_data row }
37
+ end
38
+
39
+ def [](name)
40
+ @hash[name.to_s]
41
+ end
42
+
43
+ def []=(name, value)
44
+ @hash[name.to_s] = value
45
+ end
46
+
47
+ def self.mapping_data(row_data)
48
+ self.new Hash[schema.keys.zip row_data]
49
+ end
50
+
51
+ def self.create(values)
52
+ values.delete "id"
53
+ keys = schema.keys - ['id']
54
+ vals = keys.map do |key|
55
+ values[key] ? to_sql(values[key]) : "NULL"
56
+ end
57
+ DB.execute "INSERT INTO #{table} (#{keys.join ","}) VALUES (#{vals.join ","});"
58
+
59
+ data = Hash[keys.zip vals]
60
+ sql = "SELECT last_insert_rowid();"
61
+ data["id"] = DB.execute(sql)[0][0]
62
+ self.new data
63
+ end
64
+
65
+ def save!
66
+ unless @hash["id"]
67
+ self.class.create @hash
68
+ return true
69
+ end
70
+ fields = @hash.map do |k,v|
71
+ "#{k}=#{self.class.to_sql(v)}"
72
+ end.join(",")
73
+
74
+ DB.execute ("
75
+ UPDATE #{self.class.table}
76
+ SET #{fields}
77
+ WHERE id = #{@hash['id']}
78
+ ")
79
+ true
80
+ end
81
+
82
+ def save
83
+ self.save! rescue false
84
+ end
85
+
86
+ def self.delete(id)
87
+ DB.execute("DELETE FROM #{table} WHERE id = #{id.to_i}")
88
+ true
89
+ end
90
+
91
+ def self.count
92
+ DB.execute("SELECT COUNT(*) FROM #{table}")[0][0]
93
+ end
94
+
95
+ def self.table
96
+ Rhino.to_underscore name
97
+ end
98
+
99
+ def self.schema
100
+ return @schema if @schema
101
+ @schema = {}
102
+ DB.table_info(table) do |row|
103
+ @schema[row["name"]] = row["type"]
104
+ end
105
+ @schema
106
+ end
107
+ end
108
+ end
109
+ end
@@ -1,3 +1,3 @@
1
1
  module Rhino
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhino-framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
- - rhino
7
+ - Rhino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-22 00:00:00.000000000 Z
11
+ date: 2015-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -42,30 +42,44 @@ dependencies:
42
42
  name: erubis
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '2.7'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '2.7'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: multi_json
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.11'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.11'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '0'
75
+ version: '1.3'
62
76
  type: :runtime
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ">="
80
+ - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '0'
82
+ version: '1.3'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: test-unit
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +94,20 @@ dependencies:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
96
  version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.10'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.10'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: minitest
85
113
  requirement: !ruby/object:Gem::Requirement
@@ -108,29 +136,34 @@ dependencies:
108
136
  - - "~>"
109
137
  - !ruby/object:Gem::Version
110
138
  version: '0.6'
111
- description: This is Rails-like, Rack based framework
139
+ description: This is Rack-based Ruby framework. I created it just for `Learning Ruby`
140
+ and for `Fun`
112
141
  email:
113
- - 18hino@gmail.com
114
- executables: []
142
+ - buikhanh.bk@gmail.com
143
+ executables:
144
+ - rhino
115
145
  extensions: []
116
146
  extra_rdoc_files: []
117
147
  files:
118
- - Gemfile
119
- - LICENSE.txt
120
- - README.md
121
- - Rakefile
148
+ - bin/rhino
122
149
  - lib/rhino.rb
123
- - lib/rhino/array.rb
150
+ - lib/rhino/cli.rb
124
151
  - lib/rhino/controller.rb
125
152
  - lib/rhino/dependencies.rb
126
153
  - lib/rhino/file_model.rb
154
+ - lib/rhino/generators/template_codes/application.rb.tt
155
+ - lib/rhino/generators/template_codes/config.ru.tt
156
+ - lib/rhino/generators/template_codes/structure/Gemfile
157
+ - lib/rhino/generators/template_codes/structure/app/controllers/.keep
158
+ - lib/rhino/generators/template_codes/structure/app/models/.keep
159
+ - lib/rhino/generators/template_codes/structure/app/views/.keep
160
+ - lib/rhino/generators/template_codes/structure/config/.keep
161
+ - lib/rhino/generators/template_codes/structure/config/database.yml
162
+ - lib/rhino/generators/template_codes/structure/db/database.db
127
163
  - lib/rhino/routing.rb
164
+ - lib/rhino/sqlite_model.rb
128
165
  - lib/rhino/util.rb
129
166
  - lib/rhino/version.rb
130
- - rhino.gemspec
131
- - test/erb_test.rb
132
- - test/test_application.rb
133
- - test/test_helper.rb
134
167
  homepage: http://1rhino.github.io
135
168
  licenses:
136
169
  - MIT
@@ -151,11 +184,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
184
  version: '0'
152
185
  requirements: []
153
186
  rubyforge_project:
154
- rubygems_version: 2.4.6
187
+ rubygems_version: 2.4.8
155
188
  signing_key:
156
189
  specification_version: 4
157
190
  summary: Rhino - Ruby Web Framework
158
- test_files:
159
- - test/erb_test.rb
160
- - test/test_application.rb
161
- - test/test_helper.rb
191
+ test_files: []
192
+ has_rdoc:
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in rhino.gemspec
4
- gemspec
@@ -1,22 +0,0 @@
1
- Copyright (c) 2015 Rhino
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 DELETED
@@ -1,27 +0,0 @@
1
- # Rhino
2
-
3
- This is a small Ruby Web Framework. Rails-like framework.
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'rhino'
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install rhino
20
-
21
- ## Contributing
22
-
23
- 1. Fork it ( https://github.com/[my-github-username]/rhino/fork )
24
- 2. Create your feature branch (`git checkout -b my-new-feature`)
25
- 3. Commit your changes (`git commit -am 'Add some feature'`)
26
- 4. Push to the branch (`git push origin my-new-feature`)
27
- 5. Create a new Pull Request
data/Rakefile DELETED
@@ -1,2 +0,0 @@
1
- require "bundler/gem_tasks"
2
-
@@ -1,5 +0,0 @@
1
- class Array
2
- def sum(start = 0)
3
- inject(start, &:+)
4
- end
5
- end
@@ -1,29 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'rhino/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "rhino-framework"
8
- spec.version = Rhino::VERSION
9
- spec.authors = ["rhino"]
10
- spec.email = ["18hino@gmail.com"]
11
- spec.summary = %q{Rhino - Ruby Web Framework}
12
- spec.description = %q{This is Rails-like, Rack based framework}
13
- spec.homepage = "http://1rhino.github.io"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_runtime_dependency "bundler", "~> 1.7"
22
- spec.add_runtime_dependency "rake", "~> 10.0"
23
- spec.add_runtime_dependency "erubis"
24
- spec.add_runtime_dependency "multi_json"
25
- spec.add_development_dependency "test-unit", "~> 3.0"
26
- spec.add_development_dependency "minitest", "~> 5.5"
27
- spec.add_development_dependency "rack-test", "~> 0.6"
28
-
29
- end
@@ -1,11 +0,0 @@
1
- require 'erubis'
2
-
3
- template = <<TEMPLATE
4
- This is a template.
5
- It has <%= some_thing %>.
6
- TEMPLATE
7
-
8
- eruby = Erubis::Eruby.new(template)
9
- puts eruby.src
10
- puts "========="
11
- puts eruby.result(some_thing: "Xicaloa")
@@ -1,27 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- class RhinoAppTest < Test::Unit::TestCase
4
- include Rack::Test::Methods
5
-
6
- def app
7
- BestQuotes::Application.new
8
- end
9
-
10
- def test_get
11
- get '/'
12
-
13
- assert last_response, "404"
14
- body = last_response.body
15
- assert body["not found"]
16
-
17
- end
18
-
19
- def test_request_post
20
- get '/quotes/a_quote'
21
-
22
- assert last_response.ok?
23
- body = last_response.body
24
- assert body["Ruby Version"]
25
- end
26
-
27
- end
@@ -1,11 +0,0 @@
1
- require 'rack/test'
2
- require 'test/unit'
3
-
4
- # Alway use the local code first
5
- dir = File.join(File.dirname(__FILE__), "..", 'lib')
6
- best_quotes_dir = File.join(File.dirname(__FILE__), "..", "..", 'best_quotes')
7
- $LOAD_PATH.unshift File.expand_path(dir)
8
- $LOAD_PATH.unshift File.expand_path(best_quotes_dir)
9
-
10
- require 'rhino'
11
- require 'config/application.rb'