sigma 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/init.rb ADDED
@@ -0,0 +1,11 @@
1
+ begin
2
+ require File.join(File.dirname(__FILE__), 'lib', 'sigma')
3
+ rescue LoadError
4
+ begin
5
+ require 'sigma'
6
+ rescue LoadError => e
7
+ raise e unless defined?(Rake) &&
8
+ (Rake.application.top_level_tasks.include?('gems') ||
9
+ Rake.application.top_level_tasks.include?('gems:install'))
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+ module GeneratorInstructions
3
+ def instructions
4
+ puts <<-EOS
5
+
6
+ =======================================================
7
+
8
+ Sigma successfully installed.
9
+
10
+ For usage and more infomation go to the documentation:
11
+ http://joaomdmoura.github.com/sigma/
12
+
13
+ By João Moura (a.k.a joaomdmoura)
14
+
15
+ =======================================================
16
+
17
+ EOS
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ module MigrationGenerator
2
+ def generate_migrations
3
+ generate("migration", "add_skill_to_#{@model_name.pluralize} skill:float")
4
+ generate("migration", "add_doubt_to_#{@model_name.pluralize} doubt:float")
5
+ generate("migration", "add_wins_to_#{@model_name.pluralize} wins:integer")
6
+ generate("migration", "add_losses_to_#{@model_name.pluralize} losses:integer")
7
+ generate("migration", "add_draws_to_#{@model_name.pluralize} draws:integer")
8
+ end
9
+
10
+ def set_default_values
11
+ migrations = Dir.entries("db/migrate")
12
+ migrations.each do |m|
13
+ name = m.split(/^[0-9]+_/)[1]
14
+ if name == "add_skill_to_#{@model_name.pluralize}.rb"
15
+ puts 'passed'
16
+ inject_into_file "db/migrate/#{m}",
17
+ ", :default => #{@scale/2}",
18
+ :after => ":float"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ require "generators/sigma/migration_generator"
2
+ require "generators/sigma/generator_instructions"
3
+
4
+ class Sigma
5
+ class SetupGenerator < Rails::Generators::Base
6
+ include MigrationGenerator
7
+ include GeneratorInstructions
8
+
9
+ source_root File.expand_path("../../templates", __FILE__)
10
+
11
+ desc "Setup Sigma for some resource"
12
+
13
+ def execute
14
+ @model_name = ask("What is your resource model? (eg. user)")
15
+ @scale = ask("What will be the scale? (eg. 50)").to_i
16
+ generate_migrations
17
+ set_default_values
18
+ instructions
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ class Sigma
2
+ require "sigma/core"
3
+ end
@@ -0,0 +1,5 @@
1
+ class Sigma
2
+ class Core
3
+ #TODO
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sigma
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - João Moura
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-06 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: ''
15
+ email: joaomdmoura@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/sigma.rb
21
+ - lib/generators/sigma/generator_instructions.rb
22
+ - lib/generators/sigma/migration_generator.rb
23
+ - lib/generators/sigma/setup_generator.rb
24
+ - lib/sigma/core.rb
25
+ - init.rb
26
+ homepage: http://joaomdmoura.github.com/sigma/
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:
46
+ rubygems_version: 1.8.18
47
+ signing_key:
48
+ specification_version: 3
49
+ summary: A ranking algorithm implementation for Ruby on Rails applications.
50
+ test_files: []