shittodo 0.0.1

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.
Files changed (3) hide show
  1. data/lib/shittodo/version.rb +3 -0
  2. data/lib/shittodo.rb +220 -0
  3. metadata +47 -0
@@ -0,0 +1,3 @@
1
+ module Shittodo
2
+ VERSION = "0.0.1"
3
+ end
data/lib/shittodo.rb ADDED
@@ -0,0 +1,220 @@
1
+ require 'nokogiri'
2
+ require 'prawn'
3
+ require 'open-uri'
4
+ require 'green_shoes'
5
+
6
+ Shoes.app(:title => "Shit To Do",
7
+ :width => 375, :height => 150, :resizable => true, :align => "center") do
8
+
9
+
10
+ background gradient(white, cornsilk)
11
+ bebasFont = font(Dir.pwd + "/fonts/BEBAS___.ttf")
12
+
13
+ @title = title("Shit To Do")
14
+ @title.style(:align => "center", :font => bebasFont[0])
15
+ flow(:align => "center"){
16
+ button("Show Today", :align => "center"){
17
+ id = ask("Your ID, Please")
18
+ save_as = ask_save_file
19
+ assignments = []
20
+ hhms = Nokogiri::XML(open("http://homework.harker.org/view/student.php?t=xml&i="+id+"&s=1"))
21
+
22
+ name = hhms.xpath('//student/name').text
23
+
24
+ hhms.xpath('//class/assignment').each do |node|
25
+
26
+ assignments << node
27
+ end
28
+
29
+ location = Dir.pwd
30
+
31
+ Prawn::Document.generate(save_as + ".pdf")do
32
+
33
+ font_families.update("Droid Sans" => {
34
+ :normal => location + "/fonts/DroidSans.ttf",
35
+ :bold => location + "/fonts/DroidSans-Bold.ttf"
36
+ })
37
+
38
+ font(location + "/fonts/BEBAS___.ttf", :size => 25) do
39
+ text name + ",", :align=> :center
40
+ text "You've got Shit To Do", :align => :center
41
+ font_size 13
42
+ text hhms.xpath('//date/today/date').text
43
+ end
44
+ stroke_horizontal_rule
45
+
46
+
47
+
48
+ for element in assignments do
49
+
50
+ move_down 40
51
+
52
+ font("Droid Sans") do
53
+
54
+ font_size 20
55
+
56
+ parentNode = element.parent()
57
+
58
+ text "<b>" + element.xpath('./type').text + ": </b>" + element.xpath('../coursename').text, :inline_format => true
59
+
60
+
61
+ font_size 11
62
+
63
+ text "Beginning " + element.xpath('./begin').text, :inline_format => true
64
+ text "Ending " + element.xpath('./end').text, :inline_format => true
65
+
66
+ font_size 18
67
+
68
+ move_down 10
69
+
70
+ text element.xpath('./title').text
71
+ move_down 5
72
+ font_size 15
73
+ text element.xpath('./description-notags').text, :width => 350
74
+
75
+ end
76
+ end
77
+ end
78
+
79
+ alert("PDF outputted to "+ save_as+ ".pdf. \n\nI love you.")
80
+
81
+ }
82
+ button("Show a Date", :align => "center") {
83
+ range = ask("What day? Enter yyyy-mm-dd")
84
+ date = range.split("-")
85
+ id = ask("Your ID, Please")
86
+ save_as = ask_save_file
87
+ hhms = Nokogiri::XML(open("http://homework.harker.org/view/student.php?t=xml&i="+id+"&s=1&y=" + date[0] + "&m=" + date[1] + "&d=" + date[2]))
88
+
89
+ assignments = []
90
+
91
+ name = hhms.xpath('//student/name').text
92
+
93
+ hhms.xpath('//class/assignment').each do |node|
94
+
95
+ assignments << node
96
+ end
97
+
98
+ location = Dir.pwd
99
+
100
+ Prawn::Document.generate(save_as + ".pdf")do
101
+
102
+ font_families.update("Droid Sans" => {
103
+ :normal => location + "/fonts/DroidSans.ttf",
104
+ :bold => location + "/fonts/DroidSans-Bold.ttf"
105
+ })
106
+
107
+ font(location + "/fonts/BEBAS___.ttf", :size => 25) do
108
+ text name + ",", :align=> :center
109
+ text "You've got Shit To Do", :align => :center
110
+ font_size 13
111
+ text hhms.xpath('//date/today/date').text
112
+ end
113
+ stroke_horizontal_rule
114
+
115
+
116
+
117
+ for element in assignments do
118
+
119
+ move_down 40
120
+
121
+ font("Droid Sans") do
122
+
123
+ font_size 20
124
+
125
+ parentNode = element.parent()
126
+
127
+ text "<b>" + element.xpath('./type').text + ": </b>" + element.xpath('../coursename').text, :inline_format => true
128
+
129
+
130
+ font_size 11
131
+
132
+ text "Beginning " + element.xpath('./begin').text, :inline_format => true
133
+ text "Ending " + element.xpath('./end').text, :inline_format => true
134
+
135
+ font_size 18
136
+
137
+ move_down 10
138
+
139
+ text element.xpath('./title').text
140
+ move_down 5
141
+ font_size 15
142
+ text element.xpath('./description-notags').text, :width => 350
143
+
144
+ end
145
+ end
146
+ end
147
+ alert("PDF outputted to "+ save_as+ ".pdf. \n\nI love you.")
148
+ }
149
+ button("Show a Week", :align => "center") {
150
+ weekOf = ask("Week of? Enter yyyy-mm-dd")
151
+ date = weekOf.split("-")
152
+ id = ask("Your ID, Please")
153
+ save_as = ask_save_file
154
+ hhms = Nokogiri::XML(open("http://homework.harker.org/view/student.php?t=xml&i="+id+"&s=1&y=" + date[0] + "&m=" + date[1] + "&d=" + date[2] + "&mode=weekly"))
155
+ assignments = []
156
+
157
+ name = hhms.xpath('//student/name').text
158
+
159
+ hhms.xpath('//class/assignment').each do |node|
160
+
161
+ assignments << node
162
+ end
163
+
164
+ location = Dir.pwd
165
+
166
+ Prawn::Document.generate(save_as + ".pdf")do
167
+
168
+ font_families.update("Droid Sans" => {
169
+ :normal => location + "/fonts/DroidSans.ttf",
170
+ :bold => location + "/fonts/DroidSans-Bold.ttf"
171
+ })
172
+
173
+ font(location + "/fonts/BEBAS___.ttf", :size => 25) do
174
+ text name + ",", :align=> :center
175
+ text "You've got Shit To Do", :align => :center
176
+ font_size 13
177
+ text "Week of " + hhms.xpath('//date/today/date').text
178
+ end
179
+ stroke_horizontal_rule
180
+
181
+
182
+
183
+ for element in assignments do
184
+
185
+ move_down 40
186
+
187
+ font("Droid Sans") do
188
+
189
+ font_size 20
190
+
191
+ parentNode = element.parent()
192
+
193
+ text "<b>" + element.xpath('./type').text + ": </b>" + element.xpath('../coursename').text, :inline_format => true
194
+
195
+
196
+ font_size 11
197
+
198
+ text "Beginning " + element.xpath('./begin').text, :inline_format => true
199
+ text "Ending " + element.xpath('./end').text, :inline_format => true
200
+
201
+ font_size 18
202
+
203
+ move_down 10
204
+
205
+ text element.xpath('./title').text
206
+ move_down 5
207
+ font_size 15
208
+ text element.xpath('./description-notags').text, :width => 350
209
+
210
+ end
211
+ end
212
+ end
213
+ alert("PDF outputted to "+ save_as+ ".pdf. \n\nI love you.")
214
+
215
+ }
216
+ }
217
+
218
+
219
+
220
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shittodo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Simon Orr
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-13 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Fixes HHMS printouts for Harker students
15
+ email:
16
+ - simon@simonorrstudio.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/shittodo.rb
22
+ - lib/shittodo/version.rb
23
+ homepage:
24
+ licenses: []
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project: ! '[none]'
43
+ rubygems_version: 1.8.25
44
+ signing_key:
45
+ specification_version: 3
46
+ summary: Fixes HHMS printouts for Harker students
47
+ test_files: []