<commit_before>require 'rubygems'
require File.join(File.dirname(__FILE__), '..', 'lib', 'preposterous')

#
# creating a posterous object
#

# all requests need to be authenticated
# this creates your client object and sets up 
# your posterous object for actions
client = Preposterous::HTTPAuth.new("<EMAIL>", "password")
posterous = Preposterous::Base.new(client)

#
# get and print a list of your posterous sites
#
posterous.getsites.each do |site|
  puts "#{site['id']} #{site['url']}"
end

#
# standard post w/no files
#

# initialize the fields
# field names are here: http://posterous.com/api/posting
fields = {
  :site_id => 99999999,
  :title => "This is my post",
  :body => "This is some boring text for my autogenerated post."    
}

# perform the actual post
posterous.newpost(fields, *files)

#
# standard post w/files
#

# initialize array of files
files = [
  File.open("file_one.png"),
  File.open("file_two.png")
]

# initialize fields
fields = {
  :site_id => 1313830,
  :title => "Check out these sweet pics",
  :body => "I love these pics."    
}

# perform the actual post
posterous.newpost(fields, *files)

#
# update post w/files
#

# initialize array of files
files = [
  File.open("examples/three.png"),
  File.open("examples/four.png")
]

# initialize fields
fields = {
  :post_id => 18195104,
  :title => "Autogenerated post from Preposterous Gem [#{Time.now}]",
  :body => "This is some new text for my autogenerated post."    
}

# perform the update
posterous.updatepost(fields, *files)

#
# fetch the tags from your site
#

puts posterous.gettags
<commit_msg>Updated the example to show all the new methods<commit_after>require 'rubygems'
require File.join(File.dirname(__FILE__), '..', 'lib', 'preposterous')

#
# creating a posterous object
#

# all requests need to be authenticated
# this creates your client object and sets up 
# your posterous object for actions
client = Preposterous::HTTPAuth.new("<EMAIL>", "password")
posterous = Preposterous::Base.new(client)

#
# get and print a list of your posterous sites
#
posterous.getsites.each do |site|
  puts "#{site['id']} #{site['url']}"
end

#
# standard post w/no files
#

# initialize the fields
# field names are here: http://posterous.com/api/posting
fields = {
  :site_id => 99999999,
  :title => "This is my post",
  :body => "This is some boring text for my autogenerated post."    
}

# perform the actual post
posterous.newpost(fields, *files)

#
# standard post w/files
#

# initialize array of files
files = [
  File.open("file_one.png"),
  File.open("file_two.png")
]

# initialize fields
fields = {
  :site_id => 1313830,
  :title => "Check out these sweet pics",
  :body => "I love these pics."    
}

# perform the actual post
posterous.newpost(fields, *files)

#
# update post w/files
#

# initialize array of files
files = [
  File.open("examples/three.png"),
  File.open("examples/four.png")
]

# initialize fields
fields = {
  :post_id => 12345678,
  :title => "Autogenerated post from Preposterous Gem [#{Time.now}]",
  :body => "This is some new text for my autogenerated post."    
}

# perform the update
posterous.updatepost(fields, *files)

#
# fetch the tags from your site
#

puts posterous.gettags

{'fraction_non_alphanumeric': 0.13308457711442787, 'fraction_numerical': 0.014303482587064677, 'mean_word_length': 4.098256735340729, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5168963', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1084, 'n_words': 334}