corrector 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.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +67 -0
  3. data/CHANGELOG.rdoc +13 -0
  4. data/LICENSE.rdoc +21 -0
  5. data/README.rdoc +81 -0
  6. data/Rakefile +43 -0
  7. data/app/models/corrector/base.rb +36 -0
  8. data/app/models/corrector/phrase.rb +9 -0
  9. data/app/models/corrector/prefix.rb +30 -0
  10. data/app/models/corrector/word.rb +10 -0
  11. data/app/services/corrector/cyrillic.rb +36 -0
  12. data/app/services/corrector/parse.rb +66 -0
  13. data/app/services/corrector/words.rb +71 -0
  14. data/db/migrate/20141014223624_create_corrector_bases.rb +13 -0
  15. data/lib/corrector/engine.rb +12 -0
  16. data/lib/corrector/version.rb +6 -0
  17. data/lib/corrector.rb +6 -0
  18. data/lib/tasks/corrector_tasks.rake +7 -0
  19. data/spec/dummy/README.rdoc +28 -0
  20. data/spec/dummy/Rakefile +6 -0
  21. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  22. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  23. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  24. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  25. data/spec/dummy/app/views/layouts/application.html.erb +13 -0
  26. data/spec/dummy/bin/bundle +3 -0
  27. data/spec/dummy/bin/rails +4 -0
  28. data/spec/dummy/bin/rake +4 -0
  29. data/spec/dummy/config/application.rb +29 -0
  30. data/spec/dummy/config/boot.rb +5 -0
  31. data/spec/dummy/config/database.yml +25 -0
  32. data/spec/dummy/config/environment.rb +5 -0
  33. data/spec/dummy/config/environments/development.rb +37 -0
  34. data/spec/dummy/config/environments/production.rb +78 -0
  35. data/spec/dummy/config/environments/test.rb +39 -0
  36. data/spec/dummy/config/initializers/assets.rb +8 -0
  37. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  38. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  39. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  40. data/spec/dummy/config/initializers/inflections.rb +16 -0
  41. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  42. data/spec/dummy/config/initializers/session_store.rb +3 -0
  43. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  44. data/spec/dummy/config/locales/en.yml +23 -0
  45. data/spec/dummy/config/routes.rb +4 -0
  46. data/spec/dummy/config/secrets.yml +22 -0
  47. data/spec/dummy/config.ru +4 -0
  48. data/spec/dummy/db/schema.rb +26 -0
  49. data/spec/dummy/db/test.sqlite3 +0 -0
  50. data/spec/dummy/log/development.log +0 -0
  51. data/spec/dummy/log/test.log +25007 -0
  52. data/spec/dummy/public/404.html +67 -0
  53. data/spec/dummy/public/422.html +67 -0
  54. data/spec/dummy/public/500.html +66 -0
  55. data/spec/dummy/public/favicon.ico +0 -0
  56. data/spec/dummy/tmp/cache/206/7F1/UNITS%2F%D0%9A%D0%98%D0%9B%D0%9E%D0%9C%D0%95%D0%A2%D0%A0%D0%90+%D0%92+%D0%A7%D0%90%D0%A1 +1 -0
  57. data/spec/dummy/tmp/cache/262/AB1/UNITS%2F%D0%9A%D0%98%D0%9B%D0%9E%D0%9C%D0%95%D0%A2%D0%A0%D0%9E%D0%92%2F%D0%A7%D0%90%D0%A1 +1 -0
  58. data/spec/dummy/tmp/cache/D58/820/UNITS%2F3+%D0%9A%D0%98%D0%9B%D0%9E%D0%9C%D0%95%D0%A2%D0%A0%D0%90 +1 -0
  59. data/spec/dummy/tmp/cache/E42/C10/UNITS%2F100+%D0%9C%D0%95%D0%A2%D0%A0%D0%9E%D0%92%2F%D0%A7%D0%90%D0%A1 +1 -0
  60. data/spec/factories/bases.rb +7 -0
  61. data/spec/factories/phrases.rb +7 -0
  62. data/spec/factories/prefixes.rb +7 -0
  63. data/spec/factories/words.rb +7 -0
  64. data/spec/models/corrector/base_spec.rb +90 -0
  65. data/spec/models/corrector/phrase_spec.rb +11 -0
  66. data/spec/models/corrector/prefix_spec.rb +35 -0
  67. data/spec/models/corrector/word_spec.rb +22 -0
  68. data/spec/services/corrector/cyrillic_spec.rb +26 -0
  69. data/spec/services/corrector/parse_spec.rb +58 -0
  70. data/spec/services/corrector/words_spec.rb +62 -0
  71. data/spec/spec_helper.rb +9 -0
  72. data/spec/support/initializers/caching.rb +12 -0
  73. data/spec/support/initializers/coveralls.rb +4 -0
  74. data/spec/support/initializers/database_cleaner.rb +24 -0
  75. data/spec/support/initializers/factory_girl_rails.rb +5 -0
  76. data/spec/support/initializers/focus.rb +5 -0
  77. data/spec/support/initializers/garbage_collection.rb +11 -0
  78. data/spec/support/initializers/i18n.rb +1 -0
  79. data/spec/support/initializers/migrations.rb +3 -0
  80. data/spec/support/initializers/rails.rb +6 -0
  81. data/spec/support/initializers/random_order.rb +4 -0
  82. data/spec/support/initializers/rspec.rb +10 -0
  83. metadata +306 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4b840557d16354f3fe065e83e369989379096a7e
4
+ data.tar.gz: 6807ca775443e5c58ecc2fb739b36e80a6f9c860
5
+ SHA512:
6
+ metadata.gz: 7c545c92bc3405f417bcc31035fd3aa5e93c3448017d3bb30bcda96583fd01b114bedd519bece232c344c163d4581e01a4d233ceb75b1a35f85a90610b1263e7
7
+ data.tar.gz: 6cbd1701c9419b6bbe5d6661a98e59ba13c46ea9f897d7b17df03cb165fe90afbd7cc139fc58f4b3b8519395521748113c12caa520aeeac68629983ca70222a7
data/.rubocop.yml ADDED
@@ -0,0 +1,67 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'spec/dummy/**/*'
4
+ - 'Rakefile'
5
+
6
+ Lint/HandleExceptions:
7
+ Exclude:
8
+ - 'spec/**/*'
9
+
10
+ Lint/RescueException:
11
+ Exclude:
12
+ - 'spec/**/*'
13
+
14
+ Metrics/MethodLength:
15
+ Exclude:
16
+ - 'db/**/*'
17
+
18
+ Style/AccessorMethodName:
19
+ Exclude:
20
+ - 'spec/**/*'
21
+
22
+ Style/AsciiComments:
23
+ Enabled: false
24
+
25
+ Style/ClassAndModuleChildren:
26
+ Exclude:
27
+ - 'spec/**/*'
28
+
29
+ Style/Documentation:
30
+ Exclude:
31
+ - 'spec/**/*'
32
+ - 'db/**/*'
33
+
34
+ Style/EmptyLinesAroundBody:
35
+ Enabled: false
36
+
37
+ Style/EmptyLineBetweenDefs:
38
+ Exclude:
39
+ - 'spec/**/*'
40
+
41
+ Style/PredicateName:
42
+ Enabled: false
43
+
44
+ Style/RaiseArgs:
45
+ EnforcedStyle: compact
46
+
47
+ Style/SingleLineBlockParams:
48
+ Enabled: false
49
+
50
+ Style/SingleLineMethods:
51
+ Exclude:
52
+ - 'spec/**/*'
53
+
54
+ Style/SpecialGlobalVars:
55
+ Exclude:
56
+ - 'Gemfile'
57
+ - '*.gemspec'
58
+
59
+ Style/StringLiterals:
60
+ EnforcedStyle: double_quotes
61
+
62
+ Style/SingleSpaceBeforeFirstArg:
63
+ Enabled: false
64
+
65
+ Style/TrivialAccessors:
66
+ Exclude:
67
+ - 'spec/**/*'
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,13 @@
1
+ = CHANGELOG
2
+
3
+ == 2014-10-15 0.0.1-alpha
4
+
5
+ === Added
6
+
7
+ === Deleted
8
+
9
+ === Fixed
10
+
11
+ === Deprecated
12
+
13
+ === Security
data/LICENSE.rdoc ADDED
@@ -0,0 +1,21 @@
1
+ = The MIT License
2
+
3
+ Copyright (c) 2014 Andrew Kozin, https://github.com/nepalez
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,81 @@
1
+ = Corrector
2
+
3
+ {<img src="http://img.shields.io/gem/v/corrector.svg?style=flat" alt="Gem Version" />}[https://rubygems.org/gems/corrector]
4
+ {<img src="http://img.shields.io/travis/nepalez/corrector.svg?style=flat" alt="Bild Status" />}[https://travis-ci.org/nepalez/corrector]
5
+ {<img src="http://img.shields.io/codeclimate/github/nepalez/corrector.svg?style=flat" alt="Code Metrics" />}[https://codeclimate.com/github/nepalez/corrector]
6
+ {<img src="http://img.shields.io/gemnasium/nepalez/corrector.svg?style=flat" alt="Dependency Status" />}[https://gemnasium.com/nepalez/corrector]
7
+ {<img src="http://img.shields.io/coveralls/nepalez/corrector.svg?style=flat" alt="Coverage Status" />}[https://coveralls.io/r/nepalez/corrector]
8
+ {<img src="http://img.shields.io/badge/license-MIT-blue.svg?style=flat" alt="License" />}[https://github.com/nepalez/corrector/blob/master/LICENSE.rdoc]
9
+
10
+ == About
11
+
12
+ Rails plugin for cyrillic texts correction using words and phrases dictionary.
13
+
14
+ It defines two dictionaries:
15
+
16
+ +Word+:: A dictionary of words
17
+ +Prefix+:: A dictionary of word prefixes
18
+ +Phrase+:: A dictionary of phrases
19
+
20
+ and a service +Parse+ that:
21
+
22
+ * converts a source text to uppercase cyrillic one;
23
+ * breaks it to words;
24
+ * corrects any single word using +Prefix+ and +Word+ dictionaries;
25
+ * puts corrected words back to sentence;
26
+ * corrects the sentence using the +Phrase+ dictionary;
27
+ * returns the result.
28
+
29
+ The model is expected to be used as a part of various classificators - to allow
30
+ searching items by words in Russian.
31
+
32
+ === Example
33
+
34
+ After adding some words and phrases:
35
+
36
+ Prefix.create! from: "КИЛО", to: "К", source: "UNITS"
37
+ Word.create! from: "МЕТРОВ", to: "М", source: "UNITS"
38
+ Word.create! from: "СЕКУНДУ", to: "С", source: "UNITS"
39
+ Phrase.create! from: "КМ В С", to: "ТЫС М/С", source: "UNITS"
40
+
41
+ the phrase can be corrected properly:
42
+
43
+ Parse.new "килоmетров в секyndу", source: "UNITS" # => "ТЫС М/С"
44
+
45
+ == Installation
46
+
47
+ Add this line to your application's Gemfile:
48
+
49
+ gem "corrector"
50
+
51
+ And then execute:
52
+
53
+ $ bundle
54
+
55
+ Or install it yourself as:
56
+
57
+ $ gem install corrector
58
+
59
+ == Initialization
60
+
61
+ You should copy db migrations to your project and then run the migrations.
62
+
63
+ === in a Rails application
64
+
65
+ $ rake corrector:install
66
+
67
+ === in a Rails mountable engine
68
+
69
+ $ rake app:corrector:install
70
+
71
+ == Contributing
72
+
73
+ 1. Fork it ( https://github.com/nepalez/corrector/fork )
74
+ 2. Create your feature branch (<tt>git checkout -b my-new-feature</tt>)
75
+ 3. Commit your changes (<tt>git commit -am 'Add some feature'</tt>)
76
+ 4. Push to the branch (<tt>git push origin my-new-feature</tt>)
77
+ 5. Create a new Pull Request
78
+
79
+ == License
80
+
81
+ The plugin is distributed under {MIT license}[https://github.com/nepalez/corrector/blob/master/LICENSE.rdoc]
data/Rakefile ADDED
@@ -0,0 +1,43 @@
1
+ begin
2
+ require "bundler/setup"
3
+ rescue LoadError
4
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
5
+ end
6
+
7
+ begin
8
+ require "rdoc/task"
9
+ rescue LoadError
10
+ require "rdoc/rdoc"
11
+ require "rake/rdoctask"
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = "rdoc"
17
+ rdoc.title = "Corrector"
18
+ rdoc.options << "--line-numbers"
19
+ rdoc.rdoc_files.include "README.rdoc"
20
+ rdoc.rdoc_files.include "lib/**/*.rb"
21
+ end
22
+
23
+ Bundler::GemHelper.install_tasks
24
+
25
+ APP_RAKEFILE = File.expand_path "../spec/dummy/Rakefile", __FILE__
26
+ load "rails/tasks/engine.rake"
27
+
28
+ require "bundler/gem_tasks"
29
+ require "rspec/core/rake_task"
30
+
31
+ RSpec::Core::RakeTask.new :spec
32
+ task :default do
33
+ sh "bundle exec rake db:migrate RAILS_ENV=test"
34
+ sh "bundle exec rspec spec"
35
+ end
36
+
37
+ task :full do
38
+ sh "coveralls report"
39
+ sh "rubocop"
40
+ sh "metric_fu"
41
+ sh "rails_best_practices"
42
+ sh "inch --pedantic"
43
+ end
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+
3
+ module Corrector
4
+
5
+ # Stores a list of translations (words or phrases).
6
+ class Base < ActiveRecord::Base
7
+
8
+ validates :from, :to, :scope, presence: true
9
+ validates :from, uniqueness: { scope: :scope }, allow_nil: true
10
+
11
+ # Selects records in a requested scope.
12
+ #
13
+ # @example
14
+ # Base.by_scope "UNITS" # Returns all units translations
15
+ #
16
+ # Params:
17
+ # +value+:: the scope to select records in
18
+ #
19
+ # Returns an <tt>ActiveRecord::Association</tt> object.
20
+ scope :by_scope, ->(value) { where scope: value }
21
+
22
+ # Scans the dictionary for source string translation.
23
+ # Returns the source if no translation found.
24
+ #
25
+ # @example
26
+ # Base.scan "КИЛОМЕТР" # => "КМ"
27
+ #
28
+ # Params:
29
+ # +value+:: a string to be scanned
30
+ #
31
+ # Returns a translation or the source itself if no translation found.
32
+ def self.scan(value)
33
+ where(from: value).first.try(:to) || value
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+ require_relative "base"
3
+
4
+ module Corrector
5
+
6
+ # Stores phrases translations.
7
+ class Phrase < Base
8
+ end
9
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+ require_relative "base"
3
+
4
+ module Corrector
5
+
6
+ # Stores words translations.
7
+ class Prefix < Base
8
+ validates :from, format: { without: /\s/ }, allow_nil: false
9
+
10
+ # Separates all prefixes in a scanned string.
11
+ #
12
+ # @example:
13
+ # Prefix.scan "КИЛОМЕТР" # => ["КИЛО", "^", "МЕТР"]
14
+ #
15
+ # Params:
16
+ # +value+: a word to be scanned for prefixes and splitted
17
+ #
18
+ # Returns an array of recognized word's parts.
19
+ def self.scan(value)
20
+ all.reduce(value.dup) { |str, prefix| prefix.send :scan, str }.split(" ")
21
+ end
22
+
23
+ private
24
+
25
+ # Separates a prefix in a scanned value.
26
+ def scan(value)
27
+ value.gsub Regexp.new("^#{ from }"), "#{ to } ^ "
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+ require_relative "base"
3
+
4
+ module Corrector
5
+
6
+ # Stores words translations.
7
+ class Word < Base
8
+ validates :from, format: { without: /\s/ }, allow_nil: false
9
+ end
10
+ end
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+
3
+ module Corrector
4
+
5
+ # Converts string to uppercase and its latin letters to cyrillic ones.
6
+ class Cyrillic < String
7
+
8
+ # The source line for conversion.
9
+ #
10
+ # @example
11
+ # str = Cyrillic.new "mapc" # => "МАРС"
12
+ # str.source # => "mapc"
13
+ #
14
+ attr_reader :source
15
+
16
+ # Converts letters in the source string to uppercase cyrillic ones.
17
+ #
18
+ # @example
19
+ # Cyrillic.new "mapka" # => "МАРКА"
20
+ #
21
+ # Params:
22
+ # +value+:: The source string to be converted.
23
+ #
24
+ # Returns a converted string.
25
+ def initialize(value)
26
+ @source = value
27
+ super line
28
+ end
29
+
30
+ private
31
+
32
+ def line
33
+ source.to_s.mb_chars.upcase.tr("ABCDEHKMNOPTXY", "АВСДЕНКМ№ОРТХУ")
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,66 @@
1
+ # encoding: utf-8
2
+
3
+ module Corrector
4
+
5
+ # Converts a source to string using stored prefixes, words and phrases
6
+ class Parse < String
7
+
8
+ # Returns the source string having been parsed.
9
+ #
10
+ # @example
11
+ # str = Parse.new "километра в час", scope: "UNITS" # => "КМ/Ч"
12
+ # str.source # => "километра в час"
13
+ #
14
+ attr_reader :source
15
+
16
+ # Parses given string, caches and returns the result of parsing.
17
+ #
18
+ # @example
19
+ # Parse.new "километра в час", scope: "UNITS" # => "КМ/Ч"
20
+ #
21
+ # Params:
22
+ # +value+:: a string to be parsed
23
+ # +scope+:: a scope (dictionary) for translations
24
+ #
25
+ # Returns a converted string with a +source+ method containing the source
26
+ # string and +scope+ containing the scope for translation.
27
+ def initialize(value = "", scope:)
28
+ @source, @scope = value.to_s, scope
29
+ super phrase
30
+ end
31
+
32
+ private
33
+
34
+ attr_reader :scope
35
+
36
+ def cyrillic
37
+ @cyrillic ||= Cyrillic.new source
38
+ end
39
+
40
+ def words
41
+ @words ||= Words.new(cyrillic)
42
+ end
43
+
44
+ def parts
45
+ @parts ||= words.map do |word|
46
+ Prefix.by_scope(scope).scan(word) || word
47
+ end
48
+ end
49
+
50
+ def line
51
+ @line ||= parts.map do |part|
52
+ Word.by_scope(scope).scan(part) || part
53
+ end.to_s
54
+ end
55
+
56
+ def cache_key
57
+ @cache ||= [scope, cyrillic]
58
+ end
59
+
60
+ def phrase
61
+ Rails.cache.fetch cache_key do
62
+ Phrase.by_scope(scope).scan(line) || line
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,71 @@
1
+ # encoding: utf-8
2
+
3
+ module Corrector
4
+
5
+ # Breaks source string to words.
6
+ class Words < Array
7
+
8
+ # The source array or string for the current words list.
9
+ #
10
+ # @example:
11
+ # words = Words.new "М В С2" # => #< Words ["М", "В", "С", "2"]>
12
+ # words.source # => "М В С2"
13
+ #
14
+ # words = Wrods.new ["М", "В", "С2"] # => #< Words ["М", "В", "С2"]>
15
+ # words.source # => ["М", "В", "С2"]
16
+ #
17
+ # Returns either array or string.
18
+ attr_reader :source
19
+
20
+ # Initializes the array containing words from the source array or string.
21
+ #
22
+ # @example
23
+ # Words.new # => #<Words []>
24
+ # Words.new "М В С2" # => #<Words ["М", "В", "С", "2"]>
25
+ # Words.new ["М", "В", "С2"] # => #<Words ["М", "В", "С2"]>
26
+ #
27
+ # Params:
28
+ # +value+:: An array of words or a string to be splitted to words.
29
+ # Default value: <tt>[]</tt>.
30
+ #
31
+ # Returns the array of recognized words from the initial string.
32
+ # Both the +map+ and +to_s+ methods of the array are redefined.
33
+ def initialize(value = [])
34
+ @source = value
35
+ value.is_a?(Array) ? super(value) : super(words)
36
+ end
37
+
38
+ # Maps +Words+ class object.
39
+ #
40
+ # @example
41
+ # words = Words.new(%w(РАЗ ДВА)).map { |i| i }
42
+ # words.is_a? Words # => true
43
+ #
44
+ # Returns the mapped +Words+ object.
45
+ def map
46
+ Words.new super.flatten
47
+ end
48
+
49
+ # Converts words list to a string. Joins words divided by the +^+ symbol
50
+ # and removes spaces around the slash.
51
+ #
52
+ # @example
53
+ # words = Words.new %w(К ^ М / C ^ 2)
54
+ # words.to_s # => "КМ/С2"
55
+ #
56
+ # Returns a converted string with +source+ method to check the source.
57
+ def to_s
58
+ map(&:strip).join(" ").gsub(/\s*\^\s*/, "").gsub(/\s*\/\s*/, "/")
59
+ end
60
+
61
+ private
62
+
63
+ def line
64
+ @line ||= source.to_s.gsub(/\,/, ".").gsub(/\|/, "/")
65
+ end
66
+
67
+ def words
68
+ line.scan(/[А-ЯA-Z]+|\d+\.\d+|\d+|№|\/|%|\$|\^/)
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,13 @@
1
+ class CreateCorrectorBases < ActiveRecord::Migration
2
+ def change
3
+ create_table :corrector_bases do |t|
4
+ t.string :type, limit: 6
5
+ t.string :from, null: false
6
+ t.string :to, null: false
7
+ t.string :scope
8
+ end
9
+
10
+ add_index :corrector_bases, [:scope, :from], unique: true
11
+ add_index :corrector_bases, :type
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ module Corrector
2
+
3
+ # Rails Engine settings
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace Corrector
6
+
7
+ config.generators do |generator|
8
+ generator.test_framework :rspec, fixture: true, view_specs: true
9
+ generator.fixture_replacement :factory_girl, dir: "spec/factories"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ # Namespace for the corrector module
2
+ module Corrector
3
+
4
+ # Current release
5
+ VERSION = "0.0.1"
6
+ end
data/lib/corrector.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "rails"
2
+ require "corrector/engine"
3
+
4
+ # Namespace for the corrector module
5
+ module Corrector
6
+ end
@@ -0,0 +1,7 @@
1
+ namespace :corrector do
2
+
3
+ desc "Installs the corrector"
4
+ task install: %w(install:migrations) do
5
+ sh "rake db:migrate SCOPE=corrector"
6
+ end
7
+ end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all' %>
6
+ <%= csrf_meta_tags %>
7
+ </head>
8
+ <body>
9
+
10
+ <%= yield %>
11
+
12
+ </body>
13
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run