demeler 1.0.2 → 1.0.3

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
  SHA1:
3
- metadata.gz: acfebb387fbe7468614262a490e3a139cc473a93
4
- data.tar.gz: ffc63a2408ee1fa55953579cd7a3a7a0b88c4ea2
3
+ metadata.gz: f45f975d6d264007855d0b65b8e99411c35ac272
4
+ data.tar.gz: 16a199c800c43a2673ef63694988ff5ca1a97329
5
5
  SHA512:
6
- metadata.gz: 3faea11d3c64618169f3fa6f99d7adb928a2c0b1c454f8d26150adbca80c81cedcc5de25f580361efdc9318b8de8ea003d1e724e592e7e3c37995b73b9e3dd81
7
- data.tar.gz: e3912710539a702240427b371c896f3f88fc9f778fd64713301faf2fe2223dca3fcbb4196a239da42bb58e9342e7880f6ba81ad1f6144734896ef2262b744b1d
6
+ metadata.gz: 057051d643c2387b0cf4234a5b221d9c73bb5b5e40750cb177bc5b4ebd9b7a213e90440e06df66d08b777ebff5101696a05230189a3fe91c3b633f2043d47360
7
+ data.tar.gz: af215ceb16abeb57bb96741b88d8b4784eeb2b33f93b4c3148555c691704d746a22fa6dd6d6dfa96a5d89afe659966c2dde9498d6c98bad7410c3d5c276640fc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 1.0.3
2
+
3
+ * Updated the README and Notes.
4
+
5
+
1
6
  # 1.0.2
2
7
 
3
8
  * Renamed the 'session' variable to be 'usr'. It's become clear to me that the only way a script can access data passed from the controller to the script is through this variable: therefore, it ought to have a generic name. The variable usr will have whatever is passed in through `new` or `build`.
@@ -13,7 +18,6 @@
13
18
  * Added a variable to `build` and `initialize` to be able to pass through a user argument. I called it `session` because that's what it would commonly be used for, but you could pass anything and access it in your Demeler code. For example, if you needed session _and_ some other variables, you would just pass them all in a Hash, including session.
14
19
  * Added a .gitignore file.
15
20
 
16
-
17
21
  # 1.0.0
18
22
 
19
23
  * Initial version.
data/README.md CHANGED
@@ -82,8 +82,58 @@ end
82
82
  puts d.to_html
83
83
  ```
84
84
 
85
+ ## Passing Variables into Demeler
86
+
87
+ There are three variables you'll be interested in in Demeler.
88
+
89
+ * `obj` The object, if any, that was passed as parameter 1 in `new` or `build`. I talk a little more about that one below.
90
+ * `usr` The object, if any, that was passed as parameter 3 in `build` or parameter 2 in `new`. This object can be anything you need access to in the Demeler script. If you need to pass several objects, simply put them into an array or hash and pass that.
91
+ * `out` This is an array where the intermediate results are held internally. To convert the array onto a String, use `to_s` or `to_html` if you created the Demeler object with `new`, and set parameter 2 to false or true if you used `build`.
92
+
93
+ For example,
94
+
95
+ ```ruby
96
+ countries = ['USA', 'Canada', 'France']
97
+ Demeler.build(nil, true, countries) do
98
+ p usr.inspect
99
+ end
100
+ ```
101
+
102
+ will generate:
103
+
104
+ ```html
105
+ <!-- begin generated output -->
106
+ <p>["USA", "Canada", "France"]</p>
107
+ <!-- end generated output -->
108
+ ```
109
+
110
+ If you have more than one thing to pass into Demeler, put your things into an Array or Hash. For example, say you have two lists of countries and cities.
111
+
112
+ ```ruby
113
+ countries = ['USA', 'Canada', 'France']
114
+ cities = ['Los Angeles', 'Paris', 'Berlin']
115
+ data = {:countries=>countries, :cities=>cities}
116
+ Demeler.build(nil, true, data) do
117
+ p usr[:countries].inspect
118
+ p usr[:cities].inspect
119
+ end
120
+ ```
121
+
122
+ The output is
123
+
124
+ ```html
125
+ <!-- begin generated output -->
126
+ <p>["USA", "Canada", "France"]</p>
127
+ <p>["Los Angeles", "Paris", "Berlin"]</p>
128
+ <!-- end generated output -->
129
+ ```
130
+
131
+ Note that the array is named `data` outside of Demeler, but once it's passed in through parameter 3 (usr) of `build`, inside Demeler it's name is `usr`.
132
+
85
133
  ## Fields from an object can be inserted automatically
86
134
 
135
+ First, a word of warning: if you use variables other than those below, you script will crash. If your script crashes, don't blame Demeler first; look in your script for variables that shouldn't be there.
136
+
87
137
  You can automatically load the values from a Sequel::Model object, or you can define an object and use it in place of Sequel. To define an object, use a definition similar to this:
88
138
 
89
139
  ```ruby
@@ -98,15 +148,15 @@ You can automatically load the values from a Sequel::Model object, or you can de
98
148
  Your new object is just a Hash+, so you can assign it values like this:
99
149
 
100
150
  ```ruby
101
- obj = Obj.new
102
- obj[:username] = "michael"
103
- obj[:password] = "my-password"
151
+ something = Obj.new
152
+ something[:username] = "michael"
153
+ something[:password] = "my-password"
104
154
  ```
105
155
 
106
156
  The object can now be used to fill `input` fields in a form:
107
157
 
108
158
  ```ruby
109
- html = Demeler.build(obj,true) do
159
+ html = Demeler.build(something,true) do
110
160
  text :username
111
161
  password :password
112
162
  end
@@ -115,8 +165,6 @@ The object can now be used to fill `input` fields in a form:
115
165
 
116
166
  That code will automatically insert the values from `obj` for you.
117
167
 
118
- > _NOTE: When the first argument is a symbol, it is used as the name of the field._
119
-
120
168
  ```html
121
169
  <!-- begin generated output -->
122
170
  <input name="username" type="text" value="michael" />
@@ -124,6 +172,8 @@ That code will automatically insert the values from `obj` for you.
124
172
  <!-- end generated output -->
125
173
  ```
126
174
 
175
+ > _NOTE: When the first argument is a symbol, it is used as the name of the field. Also, the form object is called `something` on the outside, but when we pass it through, it's name is `obj` on the inside._
176
+
127
177
  ### Demeler creates error messages, too
128
178
 
129
179
  You can put an error message into the object you created if your validation finds something wrong. Just insert a Hash element with the name of the element, and an array of lines, thusly:
@@ -1,4 +1,4 @@
1
1
  module Version
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  MODIFIED = "2017-06-12"
4
4
  end
data/notes CHANGED
@@ -30,7 +30,7 @@ git remote add origin https://github.com/mjwelchphd/demeler.git
30
30
  # UPDATE CHANGELOG
31
31
  # UPDATE README
32
32
  # BUILD THE GEM
33
- # UPDATE 1.x to 1.y BELOW
33
+ # UPDATE VERSION BELOW IN THE gem push COMMAND
34
34
  # COMMIT CHANGES IN GIT BEFORE PUSHING!
35
35
  git push -u origin master
36
36
 
@@ -39,6 +39,8 @@ git push -u origin master
39
39
  # To upload the gem to rubygems.org
40
40
  gem push demeler-1.0.2.gem
41
41
 
42
+ sudo gem install demeler
43
+
42
44
  #----------------------------------------
43
45
 
44
46
  # To run 'irb' for testing
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: demeler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael J. Welch, Ph.D.