Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/objects/local_string_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def run
end

enforce_utf8(self.outputs)
print_outputs if has_base64_inputs
print_outputs
end

def enforce_utf8(values)
Expand Down
35 changes: 35 additions & 0 deletions modules/generators/content/todo_list/secgen_local/local.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/ruby
require_relative '../../../../../lib/objects/local_string_generator.rb'
require 'erb'
require 'fileutils'
class TodoListGenerator < StringGenerator
attr_accessor :movies_sample
attr_accessor :chores_sample
attr_accessor :music_sample
attr_accessor :games_sample
LOCAL_DIR = File.expand_path('../../',__FILE__)
TEMPLATE_PATH = "#{LOCAL_DIR}/templates/todo_list.txt.erb"

def generate

movies_array = File.readlines('../../../../../lib/resources/linelists/top_100_movies.txt')
self.movies_sample = movies_array.sample(10)
chores_array = File.readlines('../../../../../lib/resources/linelists/household_chore_list.txt')
self.chores_sample = chores_array.sample(5)
music_array = File.readlines('../../../../../lib/resources/linelists/top_100_songs.txt')
self.music_sample = music_array.sample(10)
games_array = File.readlines('../../../../../lib/resources/linelists/top_100_games.txt')
self.games_sample = games_array.sample(5)
template_out = ERB.new(File.read(TEMPLATE_PATH), 0, '<>-')
self.outputs << template_out.result(self.get_binding)
end

# Returns binding for erb files (access to variables in this classes scope)
# @return binding
def get_binding
binding
end
end

TodoListGenerator.new.run

18 changes: 18 additions & 0 deletions modules/generators/content/todo_list/secgen_metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>

<generator xmlns="http://www.github/cliffe/SecGen/generator"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.github/cliffe/SecGen/generator">

<name>To Do List File Generator</name>
<author>Jack Biggs</author>
<module_license>MIT</module_license>
<description>Creates a To Do file which includes a different categories of things to do</description>

<type>string_generator</type>
<type>local_calculation</type>
<platform>linux</platform>

<!-- END: proxy_pass input -->
<output_type>generated_strings</output_type>
</generator>
44 changes: 44 additions & 0 deletions modules/generators/content/todo_list/templates/todo_list.txt.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**** To Do List ****\

/**** Movies to watch! ****\
<%
movies_count = 1
movies_sample.each { |movie|
%>
<%= movies_count %>. <%= movie %>
<% movies_count += 1 %>
<%
}
%>

/**** Chores to do! ****\
<%
chores_count = 1
chores_sample.each { |chores|
%>
<%= chores_count %>. <%= chores %>
<% chores_count = chores_count + 1 %>
<%
}
%>

/**** New music to listen to! ****\
<%
music_count = 1
music_sample.each { |song|
%>
<%= music_count %>. <%= song %>
<% music_count += 1 %>
<%
}
%>
/**** New games to try! ****\
<%
games_count = 1
games_sample.each { |game|
%>
<%= games_count %>. <%= game %>
<% games_count += 1 %>
<%
}
%>
Empty file.