railz_lite 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e7acea7b75dc9f8d1e05768f9c6c172f6e7984307824c69e9eb6b3c1055b993a
4
- data.tar.gz: 74bbe9fc95b69704453b158f4ca9d1625778942aefa23a0ecfbe4b7332ba79f3
3
+ metadata.gz: e2ebf1f78b9263164fa6d9c864a3344f834171df91856e8f5cfb18b318b7c215
4
+ data.tar.gz: 8844959b357a2ad711666cff1eadfdfd5a963621d09f1d035442162eb4ccd0f1
5
5
  SHA512:
6
- metadata.gz: 939f6f260cb17e847feb26d256f688eb1105bd35707c96c61036f32f609cedeb432e298c853112985f350be35561fd9526f4d0138ba2c1a2b74cef6b4c65ef18
7
- data.tar.gz: ec8d14870fe345b88359148e42c766c77c04f57747cd5f21381cd0dd654ccab5ceb30348b858c6b5e200072032d14e8c289368b78d1e1d8184e5b364180b266d
6
+ metadata.gz: 3e2f0f87d0a1cbb225d5987518e3f025446b04c075e28c6faf749f616cc3ac0393f12c09b963e08aaa33ac93fd29b8c9c6cbae43aebd0baa766615b62b4b5c50
7
+ data.tar.gz: 144b760958c29eaf21ba4c4977af41e47fe068c20eb651798c4fa751e5a2c791e2afd81e24d430a05a506482078f480b0931a9efb53f23846f674ec32d7ea2cc
@@ -24,7 +24,7 @@ module RailzLite
24
24
  end
25
25
 
26
26
  def add_server
27
- template("#{project_name}/server.rb", "config/server.rb")
27
+ template('server.rb', "#{project_name}/config/server.rb")
28
28
  end
29
29
 
30
30
  def add_views
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailzLite
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railz_lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - bryan lynch
@@ -141,7 +141,6 @@ email:
141
141
  - bml312@nyu.edu
142
142
  executables:
143
143
  - railz_lite
144
- - railz_lite.rb~
145
144
  extensions: []
146
145
  extra_rdoc_files: []
147
146
  files:
@@ -156,7 +155,6 @@ files:
156
155
  - bin/console
157
156
  - bin/setup
158
157
  - exe/railz_lite
159
- - exe/railz_lite.rb~
160
158
  - lib/railz_lite.rb
161
159
  - lib/railz_lite/cli.rb
162
160
  - lib/railz_lite/controllers/controller_base.rb
@@ -166,19 +164,15 @@ files:
166
164
  - lib/railz_lite/controllers/show_exceptions.rb
167
165
  - lib/railz_lite/controllers/static.rb
168
166
  - lib/railz_lite/controllers/templates/rescue.html.erb
169
- - lib/railz_lite/controllers/templates/rescue.html.erb~
170
167
  - lib/railz_lite/generators/project.rb
171
168
  - lib/railz_lite/generators/project.rb~
172
169
  - lib/railz_lite/generators/templates/application_controller.rb~
173
170
  - lib/railz_lite/generators/templates/server.rb
174
171
  - lib/railz_lite/models/associatable.rb
175
- - lib/railz_lite/models/associatable.rb~
176
172
  - lib/railz_lite/models/associatable2.rb
177
- - lib/railz_lite/models/associatable2.rb~
178
173
  - lib/railz_lite/models/attr_accessor_object.rb
179
174
  - lib/railz_lite/models/db_connection.rb
180
175
  - lib/railz_lite/models/searchable.rb
181
- - lib/railz_lite/models/searchable.rb~
182
176
  - lib/railz_lite/models/sql_object.rb
183
177
  - lib/railz_lite/models/validatable.rb
184
178
  - lib/railz_lite/version.rb
data/exe/railz_lite.rb~ DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- puts "hello world"
@@ -1,79 +0,0 @@
1
- require_relative '02_searchable'
2
- require 'active_support/inflector'
3
-
4
- class AssocOptions
5
- attr_accessor(
6
- :foreign_key,
7
- :class_name,
8
- :primary_key
9
- )
10
-
11
- def model_class
12
- class_name.constantize
13
- end
14
-
15
- def table_name
16
- model_class.table_name
17
- end
18
- end
19
-
20
- class BelongsToOptions < AssocOptions
21
- def initialize(name, options = {})
22
- foreign_key_sym = "#{name}_id".to_sym
23
- class_name_val = name.to_s.camelcase.singularize
24
- send("primary_key=", :id)
25
- send("foreign_key=", foreign_key_sym)
26
- send("class_name=", class_name_val)
27
-
28
- options.each do |attr, val|
29
- send("#{attr}=", val)
30
- end
31
- end
32
- end
33
-
34
- class HasManyOptions < AssocOptions
35
- def initialize(name, self_class_name, options = {})
36
- foreign_key_sym = "#{self_class_name.underscore}_id".to_sym
37
- class_name_val = name.to_s.camelcase.singularize
38
-
39
- send("primary_key=", :id)
40
- send("foreign_key=", foreign_key_sym)
41
- send("class_name=", class_name_val)
42
-
43
- options.each do |attr, val|
44
- send("#{attr}=", val)
45
- end
46
- end
47
- end
48
-
49
- module Associatable
50
- def belongs_to(name, options = {})
51
- options = BelongsToOptions.new(name, options)
52
- assoc_options[name] = options
53
- define_method(name) do
54
- foreign_key = send(options.foreign_key)
55
- primary_key = options.primary_key
56
- params = [[primary_key, foreign_key]].to_h
57
- options.model_class.where(params).first
58
- end
59
- end
60
-
61
- def has_many(name, options = {})
62
- options = HasManyOptions.new(name, self.name, options)
63
- define_method(name) do
64
- foreign_key = options.foreign_key
65
- primary_key = send(options.primary_key)
66
- params = [[foreign_key, primary_key]].to_h
67
- options.model_class.where(params)
68
- end
69
- end
70
-
71
- def assoc_options
72
- @assoc_options ||= {}
73
- @assoc_options
74
- end
75
- end
76
-
77
- class SQLObject
78
- extend Associatable
79
- end
@@ -1,35 +0,0 @@
1
- require_relative '03_associatable'
2
-
3
- module Associatable
4
- def has_one_through(name, through_name, source_name)
5
- define_method(name) do
6
- through_options = self.class.assoc_options[through_name]
7
- source_options =
8
- through_options.model_class.assoc_options[source_name]
9
-
10
- through_table = through_options.table_name
11
- through_pk = through_options.primary_key
12
- through_fk = through_options.foreign_key
13
-
14
- source_table = source_options.table_name
15
- source_pk = source_options.primary_key
16
- source_fk = source_options.foreign_key
17
-
18
- key_val = self.send(through_fk)
19
- results = DBConnection.execute(<<-SQL, key_val)
20
- SELECT
21
- #{source_table}.*
22
- FROM
23
- #{through_table}
24
- JOIN
25
- #{source_table}
26
- ON
27
- #{through_table}.#{source_fk} = #{source_table}.#{source_pk}
28
- WHERE
29
- #{through_table}.#{through_pk} = ?
30
- SQL
31
-
32
- source_options.model_class.parse_all(results).first
33
- end
34
- end
35
- end
@@ -1,21 +0,0 @@
1
- require_relative 'db_connection'
2
- require_relative '01_sql_object'
3
-
4
- module Searchable
5
- def where(params)
6
- where_line = params.keys.map { |attr_name| "#{attr_name} = ?" }.join(" AND ")
7
- results = DBConnection.execute(<<-SQL, *params.values)
8
- SELECT
9
- *
10
- FROM
11
- #{self.table_name}
12
- WHERE
13
- #{where_line}
14
- SQL
15
- results.map { |attrs| self.new(attrs) }
16
- end
17
- end
18
-
19
- class SQLObject
20
- extend Searchable
21
- end