dca 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/.document +5 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +48 -0
  4. data/Gemfile.lock +126 -0
  5. data/Guardfile +8 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.rdoc +19 -0
  8. data/Rakefile +48 -0
  9. data/VERSION +1 -0
  10. data/bin/dca +5 -0
  11. data/dca.gemspec +160 -0
  12. data/lib/dca.rb +64 -0
  13. data/lib/dca/cli.rb +32 -0
  14. data/lib/dca/commands/area.rb +133 -0
  15. data/lib/dca/commands/templates/area/analyzer.rb.erb +34 -0
  16. data/lib/dca/commands/templates/area/area.rb.erb +2 -0
  17. data/lib/dca/commands/templates/area/models.rb.erb +2 -0
  18. data/lib/dca/commands/templates/area/page.rb.erb +17 -0
  19. data/lib/dca/commands/templates/area/position.rb.erb +8 -0
  20. data/lib/dca/commands/templates/config.yml.erb +38 -0
  21. data/lib/dca/commands/templates/spec/analyzer_spec.rb.erb +15 -0
  22. data/lib/dca/commands/templates/spec/spec_helper.rb.erb +2 -0
  23. data/lib/dca/config.rb +20 -0
  24. data/lib/dca/helpers.rb +2 -0
  25. data/lib/dca/helpers/logger.rb +50 -0
  26. data/lib/dca/jobs.rb +3 -0
  27. data/lib/dca/jobs/analyzer_job.rb +119 -0
  28. data/lib/dca/jobs/job.rb +62 -0
  29. data/lib/dca/models.rb +5 -0
  30. data/lib/dca/models/base_model.rb +73 -0
  31. data/lib/dca/models/binder.rb +68 -0
  32. data/lib/dca/models/binder_helper.rb +48 -0
  33. data/lib/dca/models/nokogiri_binder.rb +43 -0
  34. data/lib/dca/models/position.rb +15 -0
  35. data/lib/dca/net.rb +1 -0
  36. data/lib/dca/net/browser_helper.rb +20 -0
  37. data/lib/dca/notifier.rb +2 -0
  38. data/lib/dca/notifier/notifier.rb +11 -0
  39. data/lib/dca/notifier/redis/models/analyze_notify.rb +12 -0
  40. data/lib/dca/notifier/redis/models/failure_notify.rb +8 -0
  41. data/lib/dca/notifier/redis/models/fetch_notify.rb +15 -0
  42. data/lib/dca/notifier/redis/models/session.rb +52 -0
  43. data/lib/dca/notifier/redis/notifier.rb +25 -0
  44. data/lib/dca/notifier/redis_notifier.rb +9 -0
  45. data/lib/dca/storage.rb +3 -0
  46. data/lib/dca/storage/elasticsearch_storage.rb +80 -0
  47. data/lib/dca/storage/mongo_storage.rb +51 -0
  48. data/lib/dca/storage/storage.rb +55 -0
  49. data/spec/analyzer_spec.rb +64 -0
  50. data/spec/area_task_spec.rb +45 -0
  51. data/spec/base_model_spec.rb +34 -0
  52. data/spec/binder_spec.rb +69 -0
  53. data/spec/config.yml +18 -0
  54. data/spec/elasticsearch_storage_spec.rb +28 -0
  55. data/spec/fixtures/page.html +12 -0
  56. data/spec/fixtures/positions.yml +13 -0
  57. data/spec/fixtures/positions_with_error.yml +14 -0
  58. data/spec/fixtures/states.yml +3 -0
  59. data/spec/job_spec.rb +31 -0
  60. data/spec/mock/analyzer_job.rb +30 -0
  61. data/spec/mock/file_storage.rb +28 -0
  62. data/spec/mock/notify_object.rb +13 -0
  63. data/spec/mock/page.rb +13 -0
  64. data/spec/mock/position.rb +40 -0
  65. data/spec/mock/web_notifier.rb +30 -0
  66. data/spec/mongo_storage_spec.rb +20 -0
  67. data/spec/redis_notifier_spec.rb +98 -0
  68. data/spec/spec_helper.rb +27 -0
  69. data/spec/support/storage_examples.rb +103 -0
  70. metadata +408 -0
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,48 @@
1
+ source 'http://rubygems.org'
2
+ # Add dependencies to develop your gem here.
3
+ # Include everything needed to run rake, tests, features, etc.
4
+ group :development do
5
+ gem 'mock_redis'
6
+ gem 'rspec'
7
+ gem 'yard'
8
+ gem 'rdoc'
9
+ gem 'bundler'
10
+ gem 'jeweler'
11
+
12
+ gem 'guard-rspec'
13
+ gem 'libnotify'
14
+ end
15
+
16
+ group :test do
17
+ gem 'simplecov', :require => false
18
+ end
19
+
20
+ # Use redis orm
21
+ gem 'ohm'
22
+
23
+ # Use rails active model
24
+ gem 'activemodel'
25
+
26
+ # Use background jobs
27
+ gem 'resque'
28
+
29
+ # Use for elasticsearch
30
+ gem 'yajl-ruby'
31
+
32
+ # Use elasticsearch for store and search data
33
+ gem 'tire'
34
+
35
+ # Use universally unique identifiers generator
36
+ gem 'uuid'
37
+
38
+ # Use commands line gem
39
+ gem 'thor'
40
+
41
+ # Use html parser
42
+ gem 'nokogiri'
43
+
44
+ # Use mongo
45
+ gem 'mongo'
46
+
47
+ # Use for mongo
48
+ gem 'bson_ext'
@@ -0,0 +1,126 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activemodel (3.2.6)
5
+ activesupport (= 3.2.6)
6
+ builder (~> 3.0.0)
7
+ activesupport (3.2.6)
8
+ i18n (~> 0.6)
9
+ multi_json (~> 1.0)
10
+ bson (1.6.4)
11
+ bson_ext (1.6.4)
12
+ bson (~> 1.6.4)
13
+ builder (3.0.0)
14
+ diff-lcs (1.1.3)
15
+ ffi (1.0.11)
16
+ git (1.2.5)
17
+ guard (1.2.3)
18
+ listen (>= 0.4.2)
19
+ thor (>= 0.14.6)
20
+ guard-rspec (1.2.0)
21
+ guard (>= 1.1)
22
+ hashr (0.0.21)
23
+ i18n (0.6.0)
24
+ jeweler (1.8.4)
25
+ bundler (~> 1.0)
26
+ git (>= 1.2.5)
27
+ rake
28
+ rdoc
29
+ json (1.7.3)
30
+ libnotify (0.7.4)
31
+ ffi (~> 1.0.11)
32
+ listen (0.4.7)
33
+ rb-fchange (~> 0.0.5)
34
+ rb-fsevent (~> 0.9.1)
35
+ rb-inotify (~> 0.8.8)
36
+ macaddr (1.6.1)
37
+ systemu (~> 2.5.0)
38
+ mime-types (1.19)
39
+ mock_redis (0.4.1)
40
+ mongo (1.6.4)
41
+ bson (~> 1.6.4)
42
+ multi_json (1.3.6)
43
+ nest (1.1.1)
44
+ redis
45
+ nokogiri (1.5.5)
46
+ ohm (1.0.2)
47
+ nest (~> 1.0)
48
+ redis (~> 2.2)
49
+ scrivener (~> 0.0.3)
50
+ rack (1.4.1)
51
+ rack-protection (1.2.0)
52
+ rack
53
+ rake (0.9.2.2)
54
+ rb-fchange (0.0.5)
55
+ ffi
56
+ rb-fsevent (0.9.1)
57
+ rb-inotify (0.8.8)
58
+ ffi (>= 0.5.0)
59
+ rdoc (3.12)
60
+ json (~> 1.4)
61
+ redis (2.2.2)
62
+ redis-namespace (1.1.0)
63
+ redis (< 3.0.0)
64
+ resque (1.21.0)
65
+ multi_json (~> 1.0)
66
+ redis-namespace (~> 1.0)
67
+ sinatra (>= 0.9.2)
68
+ vegas (~> 0.1.2)
69
+ rest-client (1.6.7)
70
+ mime-types (>= 1.16)
71
+ rspec (2.11.0)
72
+ rspec-core (~> 2.11.0)
73
+ rspec-expectations (~> 2.11.0)
74
+ rspec-mocks (~> 2.11.0)
75
+ rspec-core (2.11.0)
76
+ rspec-expectations (2.11.1)
77
+ diff-lcs (~> 1.1.3)
78
+ rspec-mocks (2.11.1)
79
+ scrivener (0.0.3)
80
+ simplecov (0.6.4)
81
+ multi_json (~> 1.0)
82
+ simplecov-html (~> 0.5.3)
83
+ simplecov-html (0.5.3)
84
+ sinatra (1.3.2)
85
+ rack (~> 1.3, >= 1.3.6)
86
+ rack-protection (~> 1.2)
87
+ tilt (~> 1.3, >= 1.3.3)
88
+ systemu (2.5.1)
89
+ thor (0.15.4)
90
+ tilt (1.3.3)
91
+ tire (0.4.2)
92
+ activemodel (>= 3.0)
93
+ hashr (~> 0.0.19)
94
+ multi_json (~> 1.0)
95
+ rake
96
+ rest-client (~> 1.6)
97
+ uuid (2.3.5)
98
+ macaddr (~> 1.0)
99
+ vegas (0.1.11)
100
+ rack (>= 1.0.0)
101
+ yajl-ruby (1.1.0)
102
+ yard (0.8.2.1)
103
+
104
+ PLATFORMS
105
+ ruby
106
+
107
+ DEPENDENCIES
108
+ activemodel
109
+ bson_ext
110
+ bundler
111
+ guard-rspec
112
+ jeweler
113
+ libnotify
114
+ mock_redis
115
+ mongo
116
+ nokogiri
117
+ ohm
118
+ rdoc
119
+ resque
120
+ rspec
121
+ simplecov
122
+ thor
123
+ tire
124
+ uuid
125
+ yajl-ruby
126
+ yard
@@ -0,0 +1,8 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2 do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Maxim Kazarin
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ = dca
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to dca
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2012 Maxim Kazarin. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,48 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+
6
+ begin
7
+ Bundler.setup(:default, :development)
8
+ rescue Bundler::BundlerError => e
9
+ $stderr.puts e.message
10
+ $stderr.puts "Run `bundle install` to install missing gems"
11
+ exit e.status_code
12
+ end
13
+ require 'rake'
14
+
15
+ require 'jeweler'
16
+ Jeweler::Tasks.new do |gem|
17
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
18
+ gem.name = "dca"
19
+ gem.homepage = "http://github.com/maxkazargm@gmail.com/dca"
20
+ gem.license = "MIT"
21
+ gem.summary = %Q{DCA}
22
+ gem.description = %Q{DCA}
23
+ gem.email = "maxkazargm@gmail.com"
24
+ gem.authors = ["Maxim Kazarin"]
25
+ # dependencies defined in Gemfile
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rspec/core'
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec) do |spec|
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
33
+ end
34
+
35
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
38
+ end
39
+
40
+ task :default => :spec
41
+
42
+ require 'yard'
43
+ YARD::Rake::YardocTask.new
44
+
45
+
46
+ SYS_ENV = 'development'
47
+ require './lib/dca'
48
+ require 'resque/tasks'
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/bin/dca ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path('../../lib/dca', __FILE__)
4
+
5
+ DCA::CLI.start
@@ -0,0 +1,160 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "dca"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Maxim Kazarin"]
12
+ s.date = "2012-07-28"
13
+ s.description = "DCA"
14
+ s.email = "maxkazargm@gmail.com"
15
+ s.executables = ["dca"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".rspec",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "Guardfile",
26
+ "LICENSE.txt",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "bin/dca",
31
+ "dca.gemspec",
32
+ "lib/dca.rb",
33
+ "lib/dca/cli.rb",
34
+ "lib/dca/commands/area.rb",
35
+ "lib/dca/commands/templates/area/analyzer.rb.erb",
36
+ "lib/dca/commands/templates/area/area.rb.erb",
37
+ "lib/dca/commands/templates/area/models.rb.erb",
38
+ "lib/dca/commands/templates/area/page.rb.erb",
39
+ "lib/dca/commands/templates/area/position.rb.erb",
40
+ "lib/dca/commands/templates/config.yml.erb",
41
+ "lib/dca/commands/templates/spec/analyzer_spec.rb.erb",
42
+ "lib/dca/commands/templates/spec/spec_helper.rb.erb",
43
+ "lib/dca/config.rb",
44
+ "lib/dca/helpers.rb",
45
+ "lib/dca/helpers/logger.rb",
46
+ "lib/dca/jobs.rb",
47
+ "lib/dca/jobs/analyzer_job.rb",
48
+ "lib/dca/jobs/job.rb",
49
+ "lib/dca/models.rb",
50
+ "lib/dca/models/base_model.rb",
51
+ "lib/dca/models/binder.rb",
52
+ "lib/dca/models/binder_helper.rb",
53
+ "lib/dca/models/nokogiri_binder.rb",
54
+ "lib/dca/models/position.rb",
55
+ "lib/dca/net.rb",
56
+ "lib/dca/net/browser_helper.rb",
57
+ "lib/dca/notifier.rb",
58
+ "lib/dca/notifier/notifier.rb",
59
+ "lib/dca/notifier/redis/models/analyze_notify.rb",
60
+ "lib/dca/notifier/redis/models/failure_notify.rb",
61
+ "lib/dca/notifier/redis/models/fetch_notify.rb",
62
+ "lib/dca/notifier/redis/models/session.rb",
63
+ "lib/dca/notifier/redis/notifier.rb",
64
+ "lib/dca/notifier/redis_notifier.rb",
65
+ "lib/dca/storage.rb",
66
+ "lib/dca/storage/elasticsearch_storage.rb",
67
+ "lib/dca/storage/mongo_storage.rb",
68
+ "lib/dca/storage/storage.rb",
69
+ "spec/analyzer_spec.rb",
70
+ "spec/area_task_spec.rb",
71
+ "spec/base_model_spec.rb",
72
+ "spec/binder_spec.rb",
73
+ "spec/config.yml",
74
+ "spec/elasticsearch_storage_spec.rb",
75
+ "spec/fixtures/page.html",
76
+ "spec/fixtures/positions.yml",
77
+ "spec/fixtures/positions_with_error.yml",
78
+ "spec/fixtures/states.yml",
79
+ "spec/job_spec.rb",
80
+ "spec/mock/analyzer_job.rb",
81
+ "spec/mock/file_storage.rb",
82
+ "spec/mock/notify_object.rb",
83
+ "spec/mock/page.rb",
84
+ "spec/mock/position.rb",
85
+ "spec/mock/web_notifier.rb",
86
+ "spec/mongo_storage_spec.rb",
87
+ "spec/redis_notifier_spec.rb",
88
+ "spec/spec_helper.rb",
89
+ "spec/support/storage_examples.rb"
90
+ ]
91
+ s.homepage = "http://github.com/maxkazargm@gmail.com/dca"
92
+ s.licenses = ["MIT"]
93
+ s.require_paths = ["lib"]
94
+ s.rubygems_version = "1.8.24"
95
+ s.summary = "DCA"
96
+
97
+ if s.respond_to? :specification_version then
98
+ s.specification_version = 3
99
+
100
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
101
+ s.add_runtime_dependency(%q<ohm>, [">= 0"])
102
+ s.add_runtime_dependency(%q<activemodel>, [">= 0"])
103
+ s.add_runtime_dependency(%q<resque>, [">= 0"])
104
+ s.add_runtime_dependency(%q<yajl-ruby>, [">= 0"])
105
+ s.add_runtime_dependency(%q<tire>, [">= 0"])
106
+ s.add_runtime_dependency(%q<uuid>, [">= 0"])
107
+ s.add_runtime_dependency(%q<thor>, [">= 0"])
108
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
109
+ s.add_runtime_dependency(%q<mongo>, [">= 0"])
110
+ s.add_runtime_dependency(%q<bson_ext>, [">= 0"])
111
+ s.add_development_dependency(%q<mock_redis>, [">= 0"])
112
+ s.add_development_dependency(%q<rspec>, [">= 0"])
113
+ s.add_development_dependency(%q<yard>, [">= 0"])
114
+ s.add_development_dependency(%q<rdoc>, [">= 0"])
115
+ s.add_development_dependency(%q<bundler>, [">= 0"])
116
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
117
+ s.add_development_dependency(%q<guard-rspec>, [">= 0"])
118
+ s.add_development_dependency(%q<libnotify>, [">= 0"])
119
+ else
120
+ s.add_dependency(%q<ohm>, [">= 0"])
121
+ s.add_dependency(%q<activemodel>, [">= 0"])
122
+ s.add_dependency(%q<resque>, [">= 0"])
123
+ s.add_dependency(%q<yajl-ruby>, [">= 0"])
124
+ s.add_dependency(%q<tire>, [">= 0"])
125
+ s.add_dependency(%q<uuid>, [">= 0"])
126
+ s.add_dependency(%q<thor>, [">= 0"])
127
+ s.add_dependency(%q<nokogiri>, [">= 0"])
128
+ s.add_dependency(%q<mongo>, [">= 0"])
129
+ s.add_dependency(%q<bson_ext>, [">= 0"])
130
+ s.add_dependency(%q<mock_redis>, [">= 0"])
131
+ s.add_dependency(%q<rspec>, [">= 0"])
132
+ s.add_dependency(%q<yard>, [">= 0"])
133
+ s.add_dependency(%q<rdoc>, [">= 0"])
134
+ s.add_dependency(%q<bundler>, [">= 0"])
135
+ s.add_dependency(%q<jeweler>, [">= 0"])
136
+ s.add_dependency(%q<guard-rspec>, [">= 0"])
137
+ s.add_dependency(%q<libnotify>, [">= 0"])
138
+ end
139
+ else
140
+ s.add_dependency(%q<ohm>, [">= 0"])
141
+ s.add_dependency(%q<activemodel>, [">= 0"])
142
+ s.add_dependency(%q<resque>, [">= 0"])
143
+ s.add_dependency(%q<yajl-ruby>, [">= 0"])
144
+ s.add_dependency(%q<tire>, [">= 0"])
145
+ s.add_dependency(%q<uuid>, [">= 0"])
146
+ s.add_dependency(%q<thor>, [">= 0"])
147
+ s.add_dependency(%q<nokogiri>, [">= 0"])
148
+ s.add_dependency(%q<mongo>, [">= 0"])
149
+ s.add_dependency(%q<bson_ext>, [">= 0"])
150
+ s.add_dependency(%q<mock_redis>, [">= 0"])
151
+ s.add_dependency(%q<rspec>, [">= 0"])
152
+ s.add_dependency(%q<yard>, [">= 0"])
153
+ s.add_dependency(%q<rdoc>, [">= 0"])
154
+ s.add_dependency(%q<bundler>, [">= 0"])
155
+ s.add_dependency(%q<jeweler>, [">= 0"])
156
+ s.add_dependency(%q<guard-rspec>, [">= 0"])
157
+ s.add_dependency(%q<libnotify>, [">= 0"])
158
+ end
159
+ end
160
+