edango 0.5.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.
Files changed (47) hide show
  1. data/Copying.txt +679 -0
  2. data/History.txt +6 -0
  3. data/Manifest.txt +46 -0
  4. data/PostInstall.txt +6 -0
  5. data/README.rdoc +117 -0
  6. data/Rakefile +21 -0
  7. data/bin/edango +34 -0
  8. data/lib/edango.rb +42 -0
  9. data/lib/edango/context.rb +23 -0
  10. data/lib/edango/context/directories.rb +67 -0
  11. data/lib/edango/context/files.rb +37 -0
  12. data/lib/edango/context/language.rb +101 -0
  13. data/lib/edango/context/parameters.rb +44 -0
  14. data/lib/edango/context/services.rb +147 -0
  15. data/lib/edango/di/container.rb +160 -0
  16. data/lib/edango/di/helpers.rb +41 -0
  17. data/lib/edango/di/proxy.rb +54 -0
  18. data/lib/edango/di/service.rb +60 -0
  19. data/lib/edango/di/service_factory.rb +40 -0
  20. data/lib/edango/environment.rb +77 -0
  21. data/lib/edango/executor.rb +64 -0
  22. data/lib/edango/helpers/hash.rb +30 -0
  23. data/lib/edango/helpers/kernel.rb +41 -0
  24. data/lib/edango/helpers/object.rb +65 -0
  25. data/lib/edango/helpers/string.rb +29 -0
  26. data/lib/edango/helpers/symbol.rb +39 -0
  27. data/lib/edango/logic/ticket_extractor.rb +258 -0
  28. data/lib/edango/site/core.rb +182 -0
  29. data/lib/edango/site/public/favicon.ico +0 -0
  30. data/lib/edango/site/public/images/btn-back-help.png +0 -0
  31. data/lib/edango/site/public/images/bullet.png +0 -0
  32. data/lib/edango/site/public/images/ctrl-back.gif +0 -0
  33. data/lib/edango/site/public/images/frm-back-err.png +0 -0
  34. data/lib/edango/site/public/images/frm-back-help.png +0 -0
  35. data/lib/edango/site/public/images/frm-back.png +0 -0
  36. data/lib/edango/site/public/images/logo.png +0 -0
  37. data/lib/edango/site/public/scripts/jquery.js +4376 -0
  38. data/lib/edango/site/public/scripts/jquery.min.js +19 -0
  39. data/lib/edango/site/public/scripts/logic.js +6 -0
  40. data/lib/edango/site/public/styles/layout.css +270 -0
  41. data/lib/edango/site/views/errors.haml +12 -0
  42. data/lib/edango/site/views/help.haml +10 -0
  43. data/lib/edango/site/views/index.haml +27 -0
  44. data/lib/edango/site/views/layout.haml +15 -0
  45. data/lib/edango/site/views/result.haml +10 -0
  46. data/lib/edango/starter.rb +141 -0
  47. metadata +162 -0
@@ -0,0 +1,60 @@
1
+ # EDango - torrent ticket extractor.
2
+ # Copyright (C) 2010 Dmitrii Toksaitov
3
+ #
4
+ # This file is part of EDango.
5
+ #
6
+ # EDango is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # EDango is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with EDango. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ require 'observer'
20
+
21
+ module EDango
22
+ module DI
23
+
24
+ class Service
25
+ include Observable
26
+
27
+ attr_reader :definition
28
+
29
+ def initialize(definition = nil)
30
+ @definition = definition || default_definition
31
+ state_update()
32
+ end
33
+
34
+ def [](key)
35
+ @definition[key]
36
+ end
37
+
38
+ def []=(key, value)
39
+ previous_value, @definition[key] = @definition[key], value
40
+ state_update() if previous_value != value
41
+
42
+ value
43
+ end
44
+
45
+ def nil?
46
+ @definition.nil?
47
+ end
48
+
49
+ private
50
+ def state_update
51
+ changed(); notify_observers(@definition)
52
+ end
53
+
54
+ def default_definition
55
+ {:block => nil, :instance => nil, :interfaces => nil, :file => nil}
56
+ end
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,40 @@
1
+ # EDango - torrent ticket extractor.
2
+ # Copyright (C) 2010 Dmitrii Toksaitov
3
+ #
4
+ # This file is part of EDango.
5
+ #
6
+ # EDango is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # EDango is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with EDango. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ require 'edango/di/service'
20
+
21
+ module EDango
22
+ module DI
23
+
24
+ class ServiceFactory
25
+ def self.service
26
+ Service.new()
27
+ end
28
+ end
29
+
30
+ class DummyServiceFactory < ServiceFactory
31
+ def self.service
32
+ service = Service.new()
33
+ service.definition[:interfaces] = {}
34
+
35
+ service
36
+ end
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,77 @@
1
+ # EDango - torrent ticket extractor.
2
+ # Copyright (C) 2010 Dmitrii Toksaitov
3
+ #
4
+ # This file is part of EDango.
5
+ #
6
+ # EDango is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # EDango is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with EDango. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ require 'singleton'
20
+
21
+ module EDango
22
+
23
+ class Environment
24
+ include Singleton
25
+
26
+ attr_reader :arguments
27
+
28
+ attr_reader :logger
29
+ attr_reader :options, :modes, :tasks
30
+
31
+ def initialize
32
+ @arguments = ARGV
33
+
34
+ @logger = SERVICES[:logger]
35
+
36
+ @options = PARAMETERS[:options]
37
+ @modes = PARAMETERS[:modes]
38
+ @tasks = PARAMETERS[:tasks]
39
+ end
40
+
41
+ def log_error(exception, message)
42
+ @logger.error(message)
43
+ @logger.error(exception.message)
44
+
45
+ unless @modes.nil?
46
+ @logger.error(exception.backtrace) if @modes[:verbose] or
47
+ @modes[:debug]
48
+ end
49
+
50
+ GLOBALS[:errors_number] ||= 0
51
+ GLOBALS[:errors_number] += 1
52
+ end
53
+
54
+ def log_warning(text)
55
+ @logger.warn(text)
56
+ end
57
+
58
+ def log_message(text)
59
+ @logger.info(text)
60
+ end
61
+
62
+ def show_message(message, log = false)
63
+ puts(message) unless @modes[:quiet]
64
+ log_message(message) if log
65
+ end
66
+
67
+ def state(message)
68
+ puts(message) if @modes[:verbose]
69
+ log_message(message)
70
+ end
71
+
72
+ def save_options(*args)
73
+ PARAMETERS.update(*args)
74
+ end
75
+ end
76
+
77
+ end
@@ -0,0 +1,64 @@
1
+ # EDango - torrent ticket extractor.
2
+ # Copyright (C) 2010 Dmitrii Toksaitov
3
+ #
4
+ # This file is part of EDango.
5
+ #
6
+ # EDango is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # EDango is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with EDango. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ module EDango
20
+
21
+ class Executor
22
+ def initialize
23
+ @environment = SERVICES[:environment]
24
+ @tasks = @environment.tasks
25
+ end
26
+
27
+ def run
28
+ if @tasks[:show_version]
29
+ output_version()
30
+ elsif @tasks[:show_help]
31
+ output_help()
32
+ else
33
+ begin
34
+ fake_stderr SERVICES[:logger] do
35
+ SERVICES[:core].run!()
36
+ end
37
+ rescue Exception => e
38
+ @environment.log_error(e, 'Core failure')
39
+ end
40
+ end
41
+ end
42
+
43
+ private
44
+ def output_help
45
+ output_version()
46
+ output_options()
47
+ end
48
+
49
+ def output_version
50
+ @environment.show_message("#{FULL_NAME} version #{VERSION}")
51
+ @environment.show_message("#{COPYRIGHT}")
52
+ end
53
+
54
+ def output_options
55
+ @environment.show_message("Available options: \n\n")
56
+ @environment.show_message("Usage: #{UNIX_NAME} {[option] [parameter]}")
57
+
58
+ SERVICES[:starter].usage.each do |name, options|
59
+ @environment.show_message("\n\t#{options[2]}\n\t\t#{options[0]}, #{options[1]}")
60
+ end
61
+ end
62
+ end
63
+
64
+ end
@@ -0,0 +1,30 @@
1
+ # EDango - torrent ticket extractor.
2
+ # Copyright (C) 2010 Dmitrii Toksaitov
3
+ #
4
+ # This file is part of EDango.
5
+ #
6
+ # EDango is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # EDango is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with EDango. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ class Hash
20
+ def intern_keys
21
+ inject({}) do |result, (key, value)|
22
+ result[(key.intern() rescue key) || key] = value
23
+ result
24
+ end
25
+ end
26
+
27
+ def intern_keys!
28
+ self.replace(self.symbolize_keys)
29
+ end
30
+ end
@@ -0,0 +1,41 @@
1
+ # EDango - torrent ticket extractor.
2
+ # Copyright (C) 2010 Dmitrii Toksaitov
3
+ #
4
+ # This file is part of EDango.
5
+ #
6
+ # EDango is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # EDango is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with EDango. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ module Kernel
20
+ def fake_stdout(io, &block)
21
+ result = io
22
+
23
+ $stdout = result
24
+ yield if block_given?
25
+
26
+ return result
27
+ ensure
28
+ $stdout = STDOUT
29
+ end
30
+
31
+ def fake_stderr(io, &block)
32
+ result = io
33
+
34
+ $stderr = result
35
+ yield if block_given?
36
+
37
+ return result
38
+ ensure
39
+ $stderr = STDERR
40
+ end
41
+ end
@@ -0,0 +1,65 @@
1
+ # EDango - torrent ticket extractor.
2
+ # Copyright (C) 2010 Dmitrii Toksaitov
3
+ #
4
+ # This file is part of EDango.
5
+ #
6
+ # EDango is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # EDango is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with EDango. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ class Object
20
+ def valid?(item, *args, &block)
21
+ result = item ? true : false
22
+
23
+ if result
24
+ args.each do |object|
25
+ (result = false; break) unless object
26
+ end
27
+
28
+ yield if block_given?
29
+ end
30
+
31
+ result
32
+ end
33
+
34
+ def try(method_name, *args, &block)
35
+ send(method_name, *args, &block) if respond_to?(method_name, true)
36
+ end
37
+
38
+ def nil_or_empty?
39
+ nil? or try(:empty?)
40
+ end
41
+
42
+ unless method_defined?(:instance_exec)
43
+
44
+ module InstanceExecHelper; end
45
+ include InstanceExecHelper
46
+
47
+ #noinspection RubyScope,RubyDeadCode
48
+ def instance_exec(*args, &block)
49
+ method_name = "__instance_exec_#{Thread.current.object_id.abs}_#{object_id.abs}"
50
+
51
+ InstanceExecHelper.module_eval { define_method(method_name, &block) }
52
+
53
+ result = nil
54
+
55
+ begin
56
+ result = send(method_name, *args)
57
+ ensure
58
+ InstanceExecHelper.module_eval { undef_method(method_name) } rescue nil
59
+ end
60
+
61
+ result
62
+ end
63
+
64
+ end
65
+ end
@@ -0,0 +1,29 @@
1
+ # EDango - torrent ticket extractor.
2
+ # Copyright (C) 2010 Dmitrii Toksaitov
3
+ #
4
+ # This file is part of EDango.
5
+ #
6
+ # EDango is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # EDango is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with EDango. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ class String
20
+ def last(limit = 1)
21
+ if limit == 0
22
+ ''
23
+ elsif limit >= self.size
24
+ self
25
+ else
26
+ self[(-limit)..-1].to_s()
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,39 @@
1
+ # EDango - torrent ticket extractor.
2
+ # Copyright (C) 2010 Dmitrii Toksaitov
3
+ #
4
+ # This file is part of EDango.
5
+ #
6
+ # EDango is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # EDango is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with EDango. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ class Symbol
20
+ def to_instance_name
21
+ if self.to_s()[0] != ?@
22
+ "@#{self}".intern()
23
+ else
24
+ self
25
+ end
26
+ end
27
+
28
+ unless method_defined?(:to_proc)
29
+ define_method(:to_proc) do
30
+ proc { |object, *args| object.send(self, *args) }
31
+ end
32
+ end
33
+
34
+ unless method_defined?(:intern)
35
+ define_method(:intern) do
36
+ self.to_s().intern()
37
+ end
38
+ end
39
+ end