Class: ContentBofu

Inherits:
Object
  • Object
show all
Defined in:
lib/contentbofu.rb

Instance Method Summary collapse

Constructor Details

#initializeContentBofu

Returns a new instance of ContentBofu.



3
4
5
6
7
8
# File 'lib/contentbofu.rb', line 3

def initialize
	# Just the defaults that I use.
	@tbs_method = 'replaceEveryonesFavorites'
	@tbs_maxsyns = '7'
	@tbs_quality = '1'
end

Instance Method Details

#madlib(body) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/contentbofu.rb', line 10

def madlib(body)

	# Replaces {}, {|},{|||||||||}, etc
	output = body.gsub(/(\{\}|\{\|*\})/,'')
	#srand(Time.now.nsec + rand(999999999999999))	


	while true do 
		vars = output.scan(/\{[^\{\}]+?\}/)

		if vars.count == 0
	            # No more madlib eval's, break out
		    break;
		end


		# Evaluate the spintax on the run
		vars.each do |ind|
	   		parts = ind.gsub(/(\{|\})/,'').split(/\|/)
	   		output = output.gsub(ind,parts[rand(parts.size)])
		end

	end

	return output

end

#tbs_maxsynsObject

TBS Maxsyns (Max Synonyms) Definition & Setting - Quality only applies for the method replaceEveryonesFavorites



78
79
80
# File 'lib/contentbofu.rb', line 78

def tbs_maxsyns
  return @tbs_maxsyns
end

#tbs_maxsyns=(value) ⇒ Object



82
83
84
# File 'lib/contentbofu.rb', line 82

def tbs_maxsyns=(value)
  @tbs_maxsyns = value
end

#tbs_methodObject

TBS Method Definition & Setting



60
61
62
# File 'lib/contentbofu.rb', line 60

def tbs_method
  return @tbs_method
end

#tbs_method=(value) ⇒ Object



64
65
66
# File 'lib/contentbofu.rb', line 64

def tbs_method=(value)
  @tbs_method = value
end

#tbs_passObject

TBS Password Definition & Setting



50
51
52
# File 'lib/contentbofu.rb', line 50

def tbs_pass
  return @tbs_pass
end

#tbs_pass=(value) ⇒ Object



54
55
56
# File 'lib/contentbofu.rb', line 54

def tbs_pass=(value)
  @tbs_pass = value
end

#tbs_qualityObject

TBS Quality Definition & Setting - Quality only applies for the method replaceEveryonesFavorites



69
70
71
# File 'lib/contentbofu.rb', line 69

def tbs_quality
  return @tbs_quality
end

#tbs_quality=(value) ⇒ Object



73
74
75
# File 'lib/contentbofu.rb', line 73

def tbs_quality=(value)
  @tbs_quality = value
end

#tbs_spin(body) ⇒ Object

TBS Spin



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/contentbofu.rb', line 142

def tbs_spin(body)

	require 'rubygems'
	require 'mechanize'
	require 'php_serialize'

	if (@tbs_user == nil) || (@tbs_pass == nil)
		raise "Your username (tbs_user) or password (tbs_pass) are unset."
	end


	api_url = "http://thebestspinner.com/api.php"
	
	# Set basics to establish the session
	data = Hash.new
	data['action'] = 'authenticate'
	data['format'] = 'php'
	data['username'] = @tbs_user
	data['password'] = @tbs_pass

	agent = Mechanize.new
	session_info = PHP.unserialize(agent.post(api_url,data).content)

	# If the "session" is set correctly, continue		
	if session_info['success'] == "true"

		data = Hash.new
		data['session'] = session_info['session']
		data['format'] = 'php'
		data['text'] = body
		data['action'] = @tbs_method
		if @tbs_method == 'replaceEveryonesFavorites'
			data['maxsyns'] = @tbs_maxsyns
			data['quality'] = @tbs_quality
		end

		# Post & Get Result
		spin_return = PHP.unserialize(agent.post(api_url,data).content)

		# Return just the output (still in spintax, NOT evaluated)
		return spin_return['output']

	end

end

#tbs_userObject

TBS User Definition & Setting



40
41
42
# File 'lib/contentbofu.rb', line 40

def tbs_user
  return @tbs_user
end

#tbs_user=(value) ⇒ Object



44
45
46
# File 'lib/contentbofu.rb', line 44

def tbs_user=(value)
  @tbs_user = value
end

#wai_nooriginalObject

WordAI No Original Setting - on = Do NOT return original word back.



133
134
135
# File 'lib/contentbofu.rb', line 133

def wai_nooriginal
  return @wai_nooriginal
end

#wai_nooriginal=(value) ⇒ Object



137
138
139
# File 'lib/contentbofu.rb', line 137

def wai_nooriginal=(value)
	@wai_nooriginal = value
end

#wai_passObject

WordAI Password Definition & Setting



97
98
99
# File 'lib/contentbofu.rb', line 97

def wai_pass
  return @wai_pass
end

#wai_pass=(value) ⇒ Object



101
102
103
# File 'lib/contentbofu.rb', line 101

def wai_pass=(value)
	@wai_pass = value
end

#wai_protectedObject

WordAI Protected Words (no spaces, separated by commas)



115
116
117
# File 'lib/contentbofu.rb', line 115

def wai_protected
  return @wai_protected
end

#wai_protected=(value) ⇒ Object



119
120
121
# File 'lib/contentbofu.rb', line 119

def wai_protected=(value)
	@wai_protected = value
end

#wai_sliderObject

WordAI Slider Value



106
107
108
# File 'lib/contentbofu.rb', line 106

def wai_slider
  return @wai_slider
end

#wai_slider=(value) ⇒ Object



110
111
112
# File 'lib/contentbofu.rb', line 110

def wai_slider=(value)
	@wai_slider = value
end

#wai_speedObject

WordAI Speed Value (on = no nested)



124
125
126
# File 'lib/contentbofu.rb', line 124

def wai_speed
  return @wai_speed
end

#wai_speed=(value) ⇒ Object



128
129
130
# File 'lib/contentbofu.rb', line 128

def wai_speed=(value)
	@wai_speed = value
end

#wai_spin(body) ⇒ Object



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/contentbofu.rb', line 188

def wai_spin(body)

  require 'rubygems'
  require 'mechanize'

  if (@wai_user == nil) || (@wai_pass == nil) || (@wai_slider == nil) || (body == nil)
    raise "You have not set your username (@wai_user), password (@wai_pass), slider value (@wai_slider) or Body."
  end

  agent = Mechanize.new

  agent.read_timeout = 600

  api_url = "http://beta.wordai.com/spinit.php"

  data = Hash.new
  data['s'] = body
  data['slider'] = @wai_slider
  data['api'] = "true"
  data['email'] = @wai_user
  data['pass'] = @wai_pass
  data['speed'] = @wai_speed if @wai_speed != nil
  data['protected'] = @wai_protected if @wai_protected != nil
  data['nooriginal'] = @wai_nooriginal if @wai_nooriginal != nil


# Post & Get Result
spin_return = agent.post(api_url,data).content

# Return (still in spintax, NOT evaluated)
return spin_return


end

#wai_userObject

TBS User Definition & Setting



87
88
89
# File 'lib/contentbofu.rb', line 87

def wai_user
  return @wai_user
end

#wai_user=(value) ⇒ Object



91
92
93
# File 'lib/contentbofu.rb', line 91

def wai_user=(value)
  @wai_user = value
end