troll 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.
data/lib/troll.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'troll/collector'
2
+ require 'troll/troller'
@@ -0,0 +1,13 @@
1
+ module Troll
2
+ class Collector
3
+ attr_accessor :directory
4
+
5
+ def initialize(dir)
6
+ self.directory = dir
7
+ end
8
+
9
+ def files
10
+ Dir["#{self.directory}/lib/**/*.rb"]
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,49 @@
1
+ module Trolby
2
+ class Troller
3
+ attr_accessor :file, :result
4
+
5
+ def initialize(file_path=nil)
6
+ self.file = file_path
7
+ end
8
+
9
+ def troll
10
+ contents = File.read(self.file)
11
+ self.result = troll_string(contents)
12
+ end
13
+
14
+ def troll!
15
+ troll
16
+ write_file
17
+ end
18
+
19
+ def troll_string(str)
20
+ result = ""
21
+ str.each_line { |line| result += troll_line(line) }
22
+ result
23
+ end
24
+
25
+ private
26
+ def troll_line(line)
27
+ case line
28
+ when /^\s+$/
29
+ line
30
+ when /^.*;\s*$/
31
+ line
32
+ when /^.*\n$/
33
+ "#{line.chomp};\n"
34
+ else
35
+ "#{line};"
36
+ end
37
+ end
38
+
39
+ def write_file
40
+ File.open(output_file, 'w') do |f|
41
+ f.puts self.result
42
+ end
43
+ end
44
+
45
+ def output_file
46
+ self.file
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ module Troll
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: troll
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - scudco
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-17 00:00:00.000000000 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+ description: Trolling for fun and profit
16
+ email: adamandersonis@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/troll/collector.rb
22
+ - lib/troll/troller.rb
23
+ - lib/troll/version.rb
24
+ - lib/troll.rb
25
+ has_rdoc: true
26
+ homepage: http://github.com/scudco/troll
27
+ licenses: []
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project: troll
46
+ rubygems_version: 1.6.2
47
+ signing_key:
48
+ specification_version: 3
49
+ summary: Trolling is a art
50
+ test_files: []