make 0.2.4 → 0.2.5
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/form.rb +12 -12
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc2e17396ad4f8794796ee8df3cb816f4dd8acb3
|
4
|
+
data.tar.gz: aed1aae67a5dd024f080c10de86e756d65269927
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 632bcc12f0c50d19ac47e547304fc750e9c6e99c51763d2225c3b274d0e9f8a470d4775039419bcc52f944b933a5e88f9578632db2631de724e8fee033230fae
|
7
|
+
data.tar.gz: 6d23c640e134a9df2148d765bf9f003e18928540dba306cefd2d22dfab66b7a62b8a6b2417cba559da72173392d5474f9f3c0d6fce9b8aa889075c7ba60a1311
|
data/lib/make/form.rb
CHANGED
@@ -7,7 +7,7 @@ class Form
|
|
7
7
|
@formMethodHidden=nil
|
8
8
|
@formStart=''
|
9
9
|
@formMiddle=[]
|
10
|
-
@formEnd=
|
10
|
+
@formEnd="\n\t<input id=\"authenticity_token\" name=\"authenticity_token\" type=\"hidden\" value=\"<%= form_authenticity_token %>\">\n\t<input type=\"submit\" value=\"Submit\">\n</form>"
|
11
11
|
@default_keys_to_ignore = ['id', 'created_at', 'updated_at']
|
12
12
|
@potential_keys_to_ignore = ['salt']
|
13
13
|
@defaults = {}
|
@@ -58,29 +58,29 @@ class Form
|
|
58
58
|
# Similar to default, but instead of a hidden specific value you pass in an array and create a select/option field.
|
59
59
|
def select column, array, assoc = false
|
60
60
|
columnName = column.titleize
|
61
|
-
input =
|
61
|
+
input = "\n\t<label>" + columnName + "\n\t</label>\n\t<select name=\"" + @modelName + "[' + column + ']\">"
|
62
62
|
if assoc #if association is checked true
|
63
63
|
array.each do |id|
|
64
64
|
val = column[0...-3].capitalize.constantize.find(id).attributes.values[1]
|
65
|
-
input +=
|
65
|
+
input += "\n\t\t\t<option value=\"" + id.to_s + "\">" + val.to_s + "</option>"
|
66
66
|
end
|
67
67
|
else #if no associations exist for array
|
68
68
|
array.each do |item|
|
69
|
-
input +=
|
69
|
+
input += "\n\t\t\t<option value=\"" + item.to_s + "\">" + item.to_s + "</option>"
|
70
70
|
end
|
71
71
|
end
|
72
72
|
@potential_keys_to_ignore.push(column)
|
73
|
-
input +=
|
73
|
+
input += "\n\t</select>"
|
74
74
|
@formMiddle.push(input)
|
75
75
|
return self
|
76
76
|
end
|
77
77
|
# Build starting code from class variables called upon by now!
|
78
78
|
def starter
|
79
79
|
if @formMethodHidden
|
80
|
-
@formStart =
|
81
|
-
@formStart +=
|
80
|
+
@formStart = "<form class=\"" + @formClass + "\" action=\"" + @formAction + "/"+ @id.to_s + "\" method=\"" + @formMethod + "\">"
|
81
|
+
@formStart += "\n\t<input name=\"_method\" type=\"hidden\" value=\"" + @formMethodHidden + "\">"
|
82
82
|
else
|
83
|
-
@formStart =
|
83
|
+
@formStart = "<form class=\"" + @formClass + "\" action=\"" + @formAction + "\" method=\"" + @formMethod + "\">"
|
84
84
|
end
|
85
85
|
end
|
86
86
|
# Build remaining code from class variables called upon by now!
|
@@ -95,19 +95,19 @@ class Form
|
|
95
95
|
# Create text input labels
|
96
96
|
@columns.each do |column|
|
97
97
|
if column.include? 'password'
|
98
|
-
input =
|
98
|
+
input = "\n\t<label>Password</label>\n\t<input type=\"text\" name=\"" + @modelName + "[password]\">"
|
99
99
|
@formMiddle.push(input)
|
100
100
|
if @password_confirmation
|
101
|
-
input =
|
101
|
+
input = "\n\t<label>Confirm Password</label>\n\t<input type=\"text\"" + @modelName + "[password_confirmation]\">"
|
102
102
|
@formMiddle.push(input)
|
103
103
|
end
|
104
104
|
else
|
105
|
-
input =
|
105
|
+
input = "\n\t<label>" + column.titleize + "\n\t</label>\n\t<input type=\"text\" name=\"" + @modelName + '[' + column + "]\">"
|
106
106
|
@formMiddle.push(input)
|
107
107
|
end
|
108
108
|
end
|
109
109
|
@defaults.each_pair do |key, value|
|
110
|
-
input =
|
110
|
+
input = "\n\t<input type=\"hidden\" name=\"" + @modelName + '[' + key.to_s + "]\" value=\"" + value.to_s + "\">"
|
111
111
|
puts input
|
112
112
|
puts @formMiddle
|
113
113
|
@formMiddle.push(input)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: make
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sara Wong
|
@@ -12,10 +12,10 @@ cert_chain: []
|
|
12
12
|
date: 2014-02-09 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A gem that shortcuts typing out forms for SQL users. Assuming your model
|
15
|
-
is named
|
16
|
-
and it will return an html-safe string from your column names for creating
|
17
|
-
record. In addition, you can type
|
18
|
-
|
15
|
+
is named ModelName, just type Make.form.model(ModelName).now! wherever in your Rails
|
16
|
+
controller and it will return an html-safe string from your column names for creating
|
17
|
+
a new record. In addition, you can type Make.table.model("ModelName").now! to automatically
|
18
|
+
generate a table. Use Make.header("Title") to make a default header.
|
19
19
|
email:
|
20
20
|
- swong2@wellesley.edu
|
21
21
|
- utemoc@gmail.com
|