make 0.1.1 → 0.1.2
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 +4 -4
- data/lib/make.rb +7 -4
- data/lib/make/builder.rb +21 -10
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdb05908a60e9123a53a661f39d8c86050f21261
|
4
|
+
data.tar.gz: fa17b88c27383792c321620785348540c8fd80c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19940ec381374c5b9a21ba2181419a6d44d1c35a7a85ce15dc050886a3c0bec092d58b4cf3cb9c10ab8662e9c95ac72dee0dacd80c258ad00f3cdb906e7b07bf
|
7
|
+
data.tar.gz: 940ea0f3bab7942ba5b1e13d7cb054c27a8b3f882cbc9efd6e07e96a6d6fcf26fb72155631f720426677dde53035f3a83a5e0bbf6274f971325143b65893739f
|
data/lib/make.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
|
-
require 'make/builder'
|
2
|
-
|
1
|
+
require 'make/builder.rb'
|
3
2
|
module Make
|
3
|
+
def initialize
|
4
|
+
@thead=''
|
5
|
+
@tbody=''
|
6
|
+
end
|
4
7
|
def self.header(title = 'title here')
|
5
8
|
string = Builder.header(title)
|
6
9
|
string = string.html_safe
|
7
10
|
return string
|
8
11
|
end
|
9
|
-
def self.form(input)
|
10
|
-
string = Builder.form(input.to_s, input.column_names)
|
12
|
+
def self.form(input, options = {})
|
13
|
+
string = Builder.form(input.to_s, input.column_names, options)
|
11
14
|
string = string.html_safe
|
12
15
|
return string
|
13
16
|
end
|
data/lib/make/builder.rb
CHANGED
@@ -2,18 +2,29 @@ module Builder
|
|
2
2
|
def self.header(title)
|
3
3
|
return '<meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><title>'+title+'</title><meta name="description" content=""><meta name="viewport" content="width=device-width, initial-scale=1">'
|
4
4
|
end
|
5
|
-
def self.form(
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
5
|
+
def self.form(model, columnNames, options = {})
|
6
|
+
# Convert given model into String
|
7
|
+
controller=model.to_s.downcase+"s"
|
8
|
+
# Set form action and method to create using REST conventions
|
9
|
+
form = '<form action="/' + controller + '" method="post">'
|
10
|
+
# if default optional parameters are passed in, make hidden inputs
|
11
|
+
if options[:default]
|
12
|
+
options[:default].each_pair do |key, value|
|
13
|
+
form = form + '<input type="hidden" name="'+key.to_s+'" value="'+value.to_s+'">'
|
14
|
+
# remove the created inputs from the columns Array (columnNames).
|
15
|
+
columnNames.delete(key.to_s)
|
15
16
|
end
|
16
17
|
end
|
18
|
+
# These are some typical form keys to ignore when rendering form
|
19
|
+
toRemove = ['id', 'created_at', 'updated_at', 'salt', 'encrypted_password']
|
20
|
+
toRemove.each do |item|
|
21
|
+
columnNames.delete(item)
|
22
|
+
end
|
23
|
+
# Create text input labels for simple form creation
|
24
|
+
columnNames.each do |column|
|
25
|
+
form = form + '<label>' + column.titleize + '</label><input type="text" name="'+column+'">'
|
26
|
+
end
|
27
|
+
# Add authentication to each form requested
|
17
28
|
form += '<input id="authenticity_token" name="authenticity_token" type="hidden" value="<%= form_authenticity_token %>"><input type="submit" value="Submit"></form>'
|
18
29
|
return form
|
19
30
|
end
|
metadata
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: make
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Sara Wong
|
7
|
+
- Sara Wong
|
8
|
+
- Ulysses Lin
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
@@ -15,7 +16,9 @@ description: A gem that shortcuts typing out forms for SQL users. Assuming your
|
|
15
16
|
and it will return an html-safe string from your column names for creating a new
|
16
17
|
record. In addition, you can type <%= Make.table(DB_Name.all) %> to automatically
|
17
18
|
generate a table. More functions to follow!
|
18
|
-
email:
|
19
|
+
email:
|
20
|
+
- swong2@wellesley.edu
|
21
|
+
- utemoc@gmail.com
|
19
22
|
executables:
|
20
23
|
- make
|
21
24
|
extensions: []
|
@@ -27,6 +30,7 @@ files:
|
|
27
30
|
homepage: http://rubygems.org/gems/make
|
28
31
|
licenses:
|
29
32
|
- Sara Wong
|
33
|
+
- Ulysses Lin
|
30
34
|
metadata: {}
|
31
35
|
post_install_message:
|
32
36
|
rdoc_options: []
|