Skip to content

Commit

Permalink
Added rake task to seed database with blog posts
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodacious committed Jun 19, 2015
1 parent 9fe31ff commit 20a2c45
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -12,7 +12,7 @@ load 'rails/tasks/engine.rake'
Bundler::GemHelper.install_tasks


Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
Dir[File.join(File.dirname(__FILE__), 'lib/tasks/**/*.rake')].each {|f| load f }

Dir[File.join(File.dirname(__FILE__), 'spec/dummy/lib/tasks/**/*.rake')].each {|f| load f}

Expand Down
4 changes: 0 additions & 4 deletions lib/tasks/blog_tasks.rake

This file was deleted.

41 changes: 41 additions & 0 deletions lib/tasks/blogit.rake
@@ -0,0 +1,41 @@
require 'yaml'

namespace :blogit do

desc "Add a bunch of mock blog posts to the database for dev"
task :seed => :environment do
if Rails.env.production?
warn "Can't seed your production database bro, too risky!"
else
load_all_models
seed_blog_content.each do |blog_post_atts|
state = Blogit.configuration.active_states.first
begin
blogger.first.blog_posts.create!(blog_post_atts.merge(state: state))
rescue NoMethodError
warn "Couldn't find a blogger model record :("
end
end
end
end


private


def seed_blog_content
YAML.load(File.read(File.join("lib/tasks/seed_blog_posts.yml")))
end


def load_all_models
Dir[Rails.root.join("app/models/**/*.rb")].each { |file| load file }
end

# The fellow who's going to write these posts...
def blogger
ActiveRecord::Base.subclasses.detect(&:blogs?) ||
warn("Can't seed your database, couldn't find a model that #blogs?")
end

end
95 changes: 95 additions & 0 deletions lib/tasks/seed_blog_posts.yml
@@ -0,0 +1,95 @@
-
title: Everything you wanted to know about the Honey-Badger

# Courtesy of Wikipedia: https://en.wikipedia.org/wiki/Honey_badger
description: |
The honey badger (Mellivora capensis), also known as the ratel or is a species of mustelid native to Africa, Southwest Asia, and the Indian subcontinent. Despite its name, the honey badger does not closely resemble other badger species; instead, it bears more anatomical similarities to weasels. It is classed as Least Concern by the IUCN owing to its extensive range and general environmental adaptations. It is primarily a carnivorous species and has few natural predators because of its thick skin and ferocious defensive abilities.
body: |
The honey badger has a fairly long body, but is distinctly thick-set and broad across the back. Its skin is remarkably loose, and allows it to turn and twist freely within it. The skin around the neck is 6 millimetres (0.24 in) thick, an adaptation to fighting conspecifics. The head is small and flat, with a short muzzle. The eyes are small, and the ears are little more than ridges on the skin, another possible adaptation to avoiding damage while fighting.
### How it looks
The honey badger has short and sturdy legs, with five toes on each foot. The feet are armed with very strong claws, which are short on the hind legs and remarkably long on the forelimbs. It is a partially plantigrade animal whose soles are thickly padded and naked up to the wrists. The tail is short and is covered in long hairs, save for below the base.
Honey badgers are the largest terrestrial mustelids in Africa. Adults measure 23 to 28 cm (9.1 to 11.0 in) in shoulder height and 55–77 cm (22–30 in) in body length, with the tail adding another 12–30 cm (4.7–11.8 in). Females are smaller than males. Males weigh 9 to 16 kg (20 to 35 lb) while females weigh 5 to 10 kg (11 to 22 lb) on average. Skull length is 13.9–14.5 cm (5.5–5.7 in) in males and 13 cm (5.1 in) for females.
There are two pairs of mammae. The honey badger possesses an anal pouch which, unusual among mustelids, is eversible,d a trait shared with hyenas and mongooses. The smell of the pouch is reportedly "suffocating", and may assist in calming bees when raiding beehives.
The skull bears little similarity to that of the European badger, and greatly resembles a larger version of a marbled polecat skull. The skull is very solidly built, with that of adults having no trace of an independent bone structure. The braincase is broader than that of dogs."
tag_list: "honeybadger, badass, animal"

-
title: Why katanas are so cool
# Courtesy of Wikipedia: https://en.wikipedia.org/wiki/Katana
description: |
Historically, katana (刀) were one of the traditionally made Japanese swords (日本刀 nihontō) that were used by the samurai of feudal Japan. Modern versions of the katana are sometimes made using non-traditional materials and methods. The katana is characterized by its distinctive appearance: a curved, slender, single-edged blade with a circular or squared guard and long grip to accommodate two hands.
body: |
The production of swords in Japan is divided into specific time periods:
* Jokoto (ancient swords, until around 900 A.D.)
* Koto (old swords from around 900–1596)
* Shinto (new swords 1596–1780)
* Shinshinto (newer swords 1781–1876)
* Gendaito (modern swords 1876–1945)
* Shinsakuto (newly made swords 1953–present)
The first use of "katana" (gatana) as a word to describe a long sword that was different from a tachi occurs as early as the Kamakura Period (1185–1333). These references to "[uchigatana](https://en.wikipedia.org/wiki/Uchigatana)" and "tsubagatana" seem to indicate a different style of sword, possibly a less costly sword for lower-ranking warriors. The evolution of the tachi into the katana seems to have started during the early Muromachi period (1337 to 1573).
Starting around the year 1400, long swords signed with the "katana" signature were made. This was in response to samurai wearing their tachi in what is now called "katana style" (cutting edge up). Japanese swords are traditionally worn with the signature facing away from the wearer. When a tachi was worn in the style of a katana, with the cutting edge up, the tachi's signature would be facing the wrong way. The fact that swordsmiths started signing swords with a katana signature shows that some samurai of that time period had started wearing their swords in a different manner.
The rise in popularity of katana amongst samurai came about due to the changing nature of close-combat warfare. The quicker draw of the sword was well suited to combat where victory depended heavily on fast response times. The katana further facilitated this by being worn thrust through a belt-like sash (obi) with the sharpened edge facing up. Ideally, samurai could draw the sword and strike the enemy in a single motion. Previously, the curved tachi had been worn with the edge of the blade facing down and suspended from a belt.
The length of the katana blade varied considerably during the course of its history. In the late 14th and early 15th centuries, katana blades tended to have lengths between 70 and 73 cm (27½ and 28½ in). During the early 16th century, the average length approached closer to 60 cm (23½ in). By the late 16th century, the average length returned to approximately 73 cm (28½ in).
The katana was often paired with a similar smaller companion sword, such as a wakizashi or it could also be worn with the tantō, a smaller, similarly shaped dagger. The pairing of a katana with a smaller sword is called the daishō. Only samurai could wear the daisho: it represented the social power and personal honor of the [samurai](https://en.wikipedia.org/wiki/Samurai).
## Modern katana (gendaito)
During the Meiji period, the samurai class was gradually disbanded, and the special privileges granted to them were taken away including the right to carry swords in public. The Haitōrei Edict in 1876 forbade the carrying of swords in public except for certain individuals, such as former samurai lords (daimyo), the military, and police. Skilled swordsmiths had trouble making a living during this period as Japan modernized its military, and many swordsmiths started making other items, such as farm equipment, tools, and cutlery. Military action by Japan in China and Russia during the Meiji period helped revive interest in swords, but it was not until the Showa period that swords were produced on a large scale again. Japanese military swords produced between 1875 and 1945 are referred to as guntō (military swords).
During the pre-World War II military buildup and throughout the war, all Japanese officers were required to wear a sword. Traditionally made swords were produced during this period, but in order to supply such large numbers of swords, blacksmiths with little or no knowledge of traditional Japanese sword manufacture were recruited. In addition, supplies of the Japanese steel (tamahagane) used for swordmaking were limited, so several other types of steel were used, as well. Quicker methods of forging were also used, such as the use of power-hammers, and quenching the blade in oil, rather than hand forging and water quenching. The non-traditionally made swords from this period are called "showato," after the regnal name of the Emperor Hirohito, and in 1937, the Japanese government started requiring the use of special stamps on the tang (nakago) to distinguish these swords from traditionally made swords. During this period of war, older antique swords were remounted for use in military mounts. Presently, in Japan, showato are not considered to be "true" Japanese swords, and they can be confiscated. Outside of Japan, however, they are collected as historical artifacts.
tag_list: "swords, katana, katanas, japan"
-
title: Have you ever tried this weird traditional food?!
description: |
Haggis is a savoury pudding containing sheep's pluck ([heart, liver and lungs](https://en.wikipedia.org/wiki/Offal)); minced with onion, oatmeal, suet, spices, and salt, mixed with stock, traditionally encased in the animal's stomach though now often in an artificial casing instead. According to the 2001 English edition of the Larousse Gastronomique: "Although its description is not immediately appealing, haggis has an excellent nutty texture and delicious savoury flavour".
It is believed that food similar to haggis (though not so named), perishable offal quickly cooked inside an animal's stomach, all conveniently available after a hunt, was eaten from ancient times.
body: |
Haggis is popularly assumed to be of Scottish origin, but there is a lack of historical evidence that could conclusively attribute its origins to any one place. The first known written recipes for a dish of the name made with offal and herbs, are, as "hagese", in the verse cookbook Liber Cure Cocorum dating from around 1430 in Lancashire, North West England, and, as "hagws of a schepe" from an English cookbook also of c1430.
> For hagese'.
> Þe hert of schepe, þe nere þou take,
> Þo bowel noght þou shalle forsake,
> On þe turbilen made, and boyled wele,
> Hacke alle togeder with gode persole,
The Scottish poem Flyting of Dunbar and Kennedy, which is dated before 1520 (the generally accepted date prior to the death of William Dunbar, one of the composers), refers to 'haggeis'.
> Thy fowll front had, and he that Bartilmo flaid;
> The gallowis gaipis eftir thy graceles gruntill, As thow wald for ane haggeis, hungry gled.
> — William Dunbar, Flyting of Dunbar and Kennedy
An early printed recipe for haggis appears in 1615 in “The English Huswife” by Gervase Markham. It contains a section entitled “Skill in Oate meale”.
> The use and vertues of these two severall kinds of Oate-meales in maintaining the Family, they are so many (according to the many customes of many Nations) that it is almost impossible to recken all;” and then proceeds to give a description of “oat-meale mixed with blood, and the Liver of either Sheepe, Calfe or Swine, maketh that pudding which is called the Haggas or Haggus, of whose goodnesse it is in vaine to boast, because there is hardly to be found a man that doth not affect them
> — Gervase Markham, The English Huswife
Food writer Alan Davidson suggests that the Ancient Romans were the first known to have made products of the haggis type. Even earlier, a kind of primitive haggis is referred to in Homer's Odyssey, in book 20, (towards the end of the eighth century BC) when Odysseus is compared to "a man before a great blazing fire turning swiftly this way and that a stomach full of fat and blood, very eager to have it roasted quickly." Haggis was "born of necessity, as a way to utilize the least expensive cuts of meat and the innards as well."
Clarissa Dickson Wright says that it "came to Scotland in a longship [i.e., from Scandinavia] even before Scotland was a single nation." She cites etymologist Walter William Skeat as further suggestion of possible Scandinavian origins: Skeat claimed that the hag– element of the word is derived from the Old Norse haggw or the Old Icelandic hoggva (höggva in modern Icelandic), Modern Scots hag, meaning 'to hew' or strike with a sharp weapon, relating to the chopped-up contents of the dish.
Dickson Wright suggests that haggis was invented as a way of cooking quick-spoiling offal near the site of a hunt, without the need to carry along an additional cooking vessel. The liver and kidneys could be grilled directly over a fire, but this treatment was unsuitable for the stomach, intestines, or lungs. Chopping up the lungs and stuffing the stomach with them and whatever fillers might have been on hand, then boiling the assembly—probably in a vessel made from the animal's hide—was one way to make sure these parts were not wasted.
### Folklore
In the absence of hard facts as to haggis' origins, popular folklore has provided some notions. One is that the dish originates from the days of the old Scottish cattle drovers. When the men left the Highlands to drive their cattle to market in Edinburgh the women would prepare rations for them to eat during the long journey down through the glens. They used the ingredients that were most readily available in their homes and conveniently packaged them in a sheep's stomach allowing for easy transportation during the journey. Other speculations have been based on Scottish slaughtering practices. When a chieftain or laird required an animal to be slaughtered for meat (whether sheep or cattle) the workmen were allowed to keep the offal as their share.
A joke sometimes maintained is that a haggis is a small Scottish animal with longer legs on one side, so that it can run around the steep hills of the Scottish Highlands without falling over. The Hebridean Haggis is "thought" to be the original native species. The Lewis Haggis is different from the Haggis on the mainland: unlike its mainland relative all its legs are of the same length. According to one poll, 33% of American visitors to Scotland believed haggis to be an animal
tag_list: "Haggis, food, scotland"

0 comments on commit 20a2c45

Please sign in to comment.