make 0.2.3 → 0.2.4

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: 61865a3ac907f64b4728d84efceaa07aea2fe97f
4
- data.tar.gz: b82392c918b182f522d09a4afabb49ad74b85e8c
3
+ metadata.gz: 79ac078514af6ee434000d2190d1849f5bbba72b
4
+ data.tar.gz: 4f02f085249edbe40ed8747f415e3fcf5236f2b7
5
5
  SHA512:
6
- metadata.gz: b5c7d6c5b9ac2dfe6c99652bc90dc5fc62c47e552f562a84bcaf8bb58284f085a01286167b146f238a874c99a828637bd966905825d7f755f493ff5dfe7dc94d
7
- data.tar.gz: cb77279d01346b1c5805584d82e1a0c6cda46a6653ae116db3072ce8b9711140a8cca39c08107bd08351d6d162fda9ae8736a7db4a201840297f8fc4d163f59f
6
+ metadata.gz: 4b2cb3222c3e2a46764c4374e93d82855bc786245e82ab2a8cd16642f0a90e765604e936ff261d7f7505f92e81868d5c73d26a81a73da77e13e195c0cdadfd08
7
+ data.tar.gz: 0c11cd30284a5342cf65b656a13877401ef598f654ab5c5e8411a9a460f333265a0daf2c54036dfd3f631dc38eaad085937aaca7571adb79c8054812ec2c36d3
data/bin/make CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'sarawong'
4
- puts Sarawong.hi(ARGV[0])
3
+ require 'make'
4
+ puts make.header(ARGV[0])
data/lib/make/form.rb CHANGED
@@ -7,7 +7,7 @@ class Form
7
7
  @formMethodHidden=nil
8
8
  @formStart=''
9
9
  @formMiddle=[]
10
- @formEnd='<input id="authenticity_token" name="authenticity_token" type="hidden" value="<%= form_authenticity_token %>"><input type="submit" value="Submit"></form>'
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,19 +58,19 @@ 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 = '<label>' + columnName + '</label><select name="' + @modelName + '[' + column + ']">'
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 += '<option value="' + id.to_s + '">' + val.to_s + '</option>'
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 += '<option value="' + item.to_s + '">' + item.to_s + '</option>'
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 += '</select>'
73
+ input += '\n\t</select>'
74
74
  @formMiddle.push(input)
75
75
  return self
76
76
  end
@@ -78,7 +78,7 @@ class Form
78
78
  def starter
79
79
  if @formMethodHidden
80
80
  @formStart = '<form class="' + @formClass + '" action="' + @formAction + '/'+ @id.to_s + '" method="' + @formMethod + '">'
81
- @formStart += '<input name="_method" type="hidden" value="' + @formMethodHidden + '">'
81
+ @formStart += '\n\t<input name="_method" type="hidden" value="' + @formMethodHidden + '">'
82
82
  else
83
83
  @formStart = '<form class="' + @formClass + '" action="' + @formAction + '" method="' + @formMethod + '">'
84
84
  end
@@ -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 = '<label>Password</label><input type="text" name="' + @modelName + '[password]">'
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 = '<label>Confirm Password</label><input type="text"' + @modelName + '[password_confirmation]">'
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 = '<label>' + column.titleize + '</label><input type="text" name="' + @modelName + '[' + column + ']">'
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 = '<input type="hidden" name="'+ @modelName + '[' + key.to_s + ']" value="' + value.to_s + '">'
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)
data/lib/make/table.rb CHANGED
@@ -10,6 +10,7 @@ class Table
10
10
  @crud=''
11
11
  @all_columns=[]
12
12
  @run_make_head=true
13
+ @file=false
13
14
  end
14
15
 
15
16
  # Assigns desired column names to be combined
@@ -141,7 +142,13 @@ class Table
141
142
  end
142
143
 
143
144
  # Writes table html code to 'table_html.txt' file located in application's root folder
144
- def file
145
+ def file!
146
+ remake_columns
147
+ if @run_make_head
148
+ make_head
149
+ end
150
+ make_body
151
+ @file=true
145
152
  File.open('table_html.txt', 'w') { |f| f.write(("<table>\n\t<thead>\n\t\t<tr>"+@thead+"\n\t\t</tr>\n\t</thead>\n\t<tbody>"+@tbody+"\n\t</tbody>\n</table>")) }
146
153
  return self
147
154
  end
@@ -162,11 +169,13 @@ class Table
162
169
 
163
170
  # Place table code into view
164
171
  def now!
165
- remake_columns
166
- if @run_make_head
167
- make_head
168
- end
169
- make_body
172
+ if !@file
173
+ remake_columns
174
+ if @run_make_head
175
+ make_head
176
+ end
177
+ make_body
178
+ end
170
179
  return ('<table><thead><tr>'+@thead+'</tr></thead><tbody>'+@tbody+'</tbody></table>').html_safe
171
180
  end
172
181
  end
data/lib/make.rb CHANGED
@@ -14,7 +14,4 @@ module Make
14
14
  def self.table
15
15
  Table.new
16
16
  end
17
- def self.ctable
18
- Ctable.new
19
- end
20
17
  end
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.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sara Wong
@@ -15,7 +15,7 @@ description: A gem that shortcuts typing out forms for SQL users. Assuming your
15
15
  is named Model_Name, just type <%= Make.form(Model) %> wherever in your Rails view
16
16
  and it will return an html-safe string from your column names for creating a new
17
17
  record. In addition, you can type <%= Make.table.model("Table_Name").now! %> to
18
- automatically generate a table. More functions to follow!
18
+ automatically 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