frecon 1.3.1 → 1.3.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a7fb4e7fd0591958e05533a08df54016514d378b
4
- data.tar.gz: 548fabecbb1a71fcfd243e50550e6ce52114cee3
3
+ metadata.gz: ca8d8f19739e084e910a26abb0aced06a7d9d27b
4
+ data.tar.gz: fe2a74382f77dcc3c2b22b9c86b33ae41f521e63
5
5
  SHA512:
6
- metadata.gz: 74e902cd66162a0e4fbcf5840e47c5dcc45e8ab7d40f169ff50f2cb419f03edf179d32440c61419f73b2df7bb7477566295856c83c026b72cf86073ed7c554a6
7
- data.tar.gz: bc8cebbe5f5c3324707f9788c359646bfe09884f95c28385d32054cbc834da1aa502b48e7863bc283bdd975ed3f194cc7411abacdf406d664074dce7ccc528c2
6
+ metadata.gz: 7b63c78b3b9994ed34d297d73b8aa7608da1394d9b96a0876c6f6f87b26d8f061beb7f0885c91da46a1c56f26348dffd9b620f424418d71fd50b38a3b7d92ee8
7
+ data.tar.gz: e06dea7ca098a75ef22c12b6ad0982e02f6575a83e46da6cf2cb387a2c46f47e4a642b3a2ad95b2a576f9a3afb32981e98ea431c1e6dc6027a6ea7c3bff41cef
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Dependencies loaded from frecon.gemspec
4
4
  gemspec
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- require "yard"
1
+ require 'yard'
2
2
 
3
3
  YARD::Config.load_plugin('tomdoc')
4
4
  YARD::Config.load_plugin('mongoid')
@@ -14,7 +14,7 @@ namespace :docs do
14
14
  end
15
15
  end
16
16
 
17
- require "rspec/core/rake_task"
17
+ require 'rspec/core/rake_task'
18
18
 
19
19
  RSpec::Core::RakeTask.new(:spec)
20
20
 
@@ -7,7 +7,7 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "mongoid"
10
+ require 'mongoid'
11
11
 
12
12
  # Public: An extension for the BSON module.
13
13
  module BSON
@@ -1,4 +1,4 @@
1
- require "yaml"
1
+ require 'yaml'
2
2
 
3
3
  module FReCon
4
4
 
@@ -8,7 +8,7 @@ module FReCon
8
8
 
9
9
  # Public: The configuration Hash for the server-related configuration.
10
10
  #
11
- # Keys will typically include "port", "host", etc.
11
+ # Keys will typically include 'port', 'host', etc.
12
12
  attr_accessor :server
13
13
 
14
14
  # Public: The configuration Hash for the console-related configuration.
@@ -16,7 +16,7 @@ module FReCon
16
16
 
17
17
  # Public: The configuration Hash for the database-related configuration.
18
18
  #
19
- # Keys will typically include "mongoid", which should be a Hash
19
+ # Keys will typically include 'mongoid', which should be a Hash
20
20
  # representation of a valid mongoid.yml file.
21
21
  attr_accessor :database
22
22
 
@@ -68,11 +68,11 @@ module FReCon
68
68
  configuration.merge(system || {})
69
69
  configuration.merge(user || {})
70
70
 
71
- # Grab out the "server", "console", and "database" values from the
71
+ # Grab out the 'server', 'console', and 'database' values from the
72
72
  # configuration and store those in the appropriate instance variables.
73
- @server = configuration["server"] || {}
74
- @console = configuration["console"] || {}
75
- @database = configuration["database"] || {}
73
+ @server = configuration['server'] || {}
74
+ @console = configuration['console'] || {}
75
+ @database = configuration['database'] || {}
76
76
 
77
77
  configuration
78
78
  end
@@ -110,7 +110,7 @@ module FReCon
110
110
 
111
111
  # Public: Generate the filename for the defaults configuration file.
112
112
  def default_configuration_filename
113
- File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "config", "default.yml"))
113
+ File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'config', 'default.yml'))
114
114
  end
115
115
 
116
116
  # Public: Generate the filename for the system configuration file.
@@ -139,7 +139,7 @@ module FReCon
139
139
  end
140
140
 
141
141
  # Public: Validate a value for @variable.
142
- #
142
+ #
143
143
  # Checks the value for @variable against a list of valid environments.
144
144
  def validate_symbol(symbol)
145
145
  raise ArgumentError, "Environment variable is not one of #{self.valid_environments}" unless
@@ -155,7 +155,7 @@ module FReCon
155
155
 
156
156
  # Public: Return a Hash representing the default server settings.
157
157
  def server_defaults
158
- {"host" => "localhost", "port" => 4567}
158
+ {'host' => 'localhost', 'port' => 4567}
159
159
  end
160
160
 
161
161
  # Public: Return a Hash representing the default console settings.
@@ -7,12 +7,12 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "frecon/base/environment"
10
+ require 'frecon/base/environment'
11
11
 
12
12
  # Public: The FReCon API module.
13
13
  module FReCon
14
14
  # Public: A String representing the current version of FReCon.
15
- VERSION = "1.3.1"
15
+ VERSION = '1.3.2'
16
16
 
17
17
  # Public: An Environment representing the system execution environment.
18
18
  ENVIRONMENT = Environment.new(:development)
data/lib/frecon/base.rb CHANGED
@@ -7,7 +7,7 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "frecon/base/bson"
11
- require "frecon/base/object"
12
- require "frecon/base/environment"
13
- require "frecon/base/variables"
10
+ require 'frecon/base/bson'
11
+ require 'frecon/base/object'
12
+ require 'frecon/base/environment'
13
+ require 'frecon/base/variables'
@@ -7,9 +7,9 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "frecon/base/variables"
11
- require "frecon/database"
12
- require "frecon/server"
10
+ require 'frecon/base/variables'
11
+ require 'frecon/database'
12
+ require 'frecon/server'
13
13
 
14
14
  module FReCon
15
15
  # Public: The wrapper system for a pry console.
@@ -20,7 +20,7 @@ module FReCon
20
20
  def self.start
21
21
  Database.setup!
22
22
 
23
- require "pry"
23
+ require 'pry'
24
24
 
25
25
  FReCon.pry
26
26
  end
@@ -7,7 +7,7 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "frecon/base"
10
+ require 'frecon/base'
11
11
 
12
12
  module FReCon
13
13
  # Public: A base class to represent a controller.
@@ -16,18 +16,18 @@ module FReCon
16
16
  #
17
17
  # Returns a Symbol that is the Model name.
18
18
  def self.model_name
19
- # Removes the namespace "FReCon::" and "Controller" from
19
+ # Removes the namespace 'FReCon::' and 'Controller' from
20
20
  # the class name, then singularizes the result.
21
- self.name.gsub(/FReCon::|Controller\Z/, "").singularize
21
+ self.name.gsub(/FReCon::|Controller\Z/, '').singularize
22
22
  end
23
23
 
24
24
  # Public: Converts the class's name to a Model.
25
25
  #
26
26
  # Returns the Model's class.
27
27
  def self.model
28
- # Removes the trailing "Controller" from the class name,
28
+ # Removes the trailing 'Controller' from the class name,
29
29
  # singularizes the result, and turns it into the class.
30
- self.name.gsub(/Controller\Z/, "").singularize.constantize
30
+ self.name.gsub(/Controller\Z/, '').singularize.constantize
31
31
  end
32
32
 
33
33
  # Public: Find a model.
@@ -37,7 +37,7 @@ module FReCon
37
37
  #
38
38
  # Returns either the found model value or nil.
39
39
  def self.find_model(params)
40
- model.find params.delete("id")
40
+ model.find params.delete('id')
41
41
  end
42
42
 
43
43
  # Public: Generate a could-not-find message.
@@ -47,7 +47,7 @@ module FReCon
47
47
  # model - The model that the search was performed upon.
48
48
  #
49
49
  # Returns a String containing the error message.
50
- def self.could_not_find(value, attribute = "id", model = model_name.downcase)
50
+ def self.could_not_find(value, attribute = 'id', model = model_name.downcase)
51
51
  "Could not find #{model} of #{attribute} #{value}!"
52
52
  end
53
53
 
@@ -220,8 +220,8 @@ module FReCon
220
220
  if params.empty?
221
221
  @models = model.all
222
222
  else
223
- params.delete("splat")
224
- params.delete("captures")
223
+ params.delete('splat')
224
+ params.delete('captures')
225
225
 
226
226
  @models = model.all.psv_filter(params)
227
227
  end
@@ -7,8 +7,8 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "json"
11
- require "frecon/models/competition"
10
+ require 'json'
11
+ require 'frecon/models/competition'
12
12
 
13
13
  module FReCon
14
14
  # Public: The Competitions controller.
@@ -7,8 +7,8 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "json"
11
- require "frecon/models"
10
+ require 'json'
11
+ require 'frecon/models'
12
12
 
13
13
  module FReCon
14
14
  # Public: The Dump controller.
@@ -21,7 +21,7 @@ module FReCon
21
21
 
22
22
  ordered_descendants = Model.descendants.sort_by do |model|
23
23
  id_fields = model.fields.keys.select do |attribute|
24
- attribute.ends_with?("_id") && attribute != "_id"
24
+ attribute.ends_with?('_id') && attribute != '_id'
25
25
  end
26
26
 
27
27
  [id_fields.count, dump_compliant_name(model)]
@@ -39,11 +39,11 @@ module FReCon
39
39
  # Examples
40
40
  #
41
41
  # DumpController.dump_compliant_name(FReCon::Team)
42
- # # => "teams"
42
+ # # => 'teams'
43
43
  #
44
44
  # Returns a dump-compliant string.
45
45
  def self.dump_compliant_name(model)
46
- model.name.gsub(/FReCon::/, "").downcase.pluralize
46
+ model.name.gsub(/FReCon::/, '').downcase.pluralize
47
47
  end
48
48
  end
49
49
  end
@@ -7,8 +7,8 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "json"
11
- require "frecon/models/match"
10
+ require 'json'
11
+ require 'frecon/models/match'
12
12
 
13
13
  module FReCon
14
14
  # Public: The Matches controller.
@@ -7,8 +7,8 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "json"
11
- require "frecon/models/participation"
10
+ require 'json'
11
+ require 'frecon/models/participation'
12
12
 
13
13
  module FReCon
14
14
  # Public: The Participations controller.
@@ -7,8 +7,8 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "json"
11
- require "frecon/models/record"
10
+ require 'json'
11
+ require 'frecon/models/record'
12
12
 
13
13
  module FReCon
14
14
  # Public: The Records controller.
@@ -7,8 +7,8 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "json"
11
- require "frecon/models/robot"
10
+ require 'json'
11
+ require 'frecon/models/robot'
12
12
 
13
13
  module FReCon
14
14
  # Public: The Robots controller.
@@ -7,8 +7,8 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "json"
11
- require "frecon/models/team"
10
+ require 'json'
11
+ require 'frecon/models/team'
12
12
 
13
13
  module FReCon
14
14
  # Public: The Teams controller.
@@ -7,15 +7,15 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "json"
11
- require "frecon/request_error"
10
+ require 'json'
11
+ require 'frecon/request_error'
12
12
 
13
- require "frecon/controller"
13
+ require 'frecon/controller'
14
14
 
15
- require "frecon/controllers/competitions_controller"
16
- require "frecon/controllers/dump_controller"
17
- require "frecon/controllers/matches_controller"
18
- require "frecon/controllers/participations_controller"
19
- require "frecon/controllers/records_controller"
20
- require "frecon/controllers/robots_controller"
21
- require "frecon/controllers/teams_controller"
15
+ require 'frecon/controllers/competitions_controller'
16
+ require 'frecon/controllers/dump_controller'
17
+ require 'frecon/controllers/matches_controller'
18
+ require 'frecon/controllers/participations_controller'
19
+ require 'frecon/controllers/records_controller'
20
+ require 'frecon/controllers/robots_controller'
21
+ require 'frecon/controllers/teams_controller'
@@ -7,26 +7,26 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "logger"
10
+ require 'logger'
11
11
 
12
- require "frecon/base/variables"
12
+ require 'frecon/base/variables'
13
13
 
14
- require "mongoid"
15
- require "frecon/mongoid/criteria"
14
+ require 'mongoid'
15
+ require 'frecon/mongoid/criteria'
16
16
 
17
- require "tempfile"
18
- require "yaml"
17
+ require 'tempfile'
18
+ require 'yaml'
19
19
 
20
- require "frecon/models"
20
+ require 'frecon/models'
21
21
 
22
22
  module FReCon
23
23
  # Public: A system to set up the database.
24
24
  class Database
25
25
  # Public: Set up the database.
26
26
  def self.setup!
27
- Mongoid.load!(File.join(File.dirname(__FILE__), "mongoid.yml"), FReCon::ENVIRONMENT.variable)
27
+ Mongoid.load!(File.join(File.dirname(__FILE__), 'mongoid.yml'), FReCon::ENVIRONMENT.variable)
28
28
 
29
- if FReCon::ENVIRONMENT.console["level"]
29
+ if FReCon::ENVIRONMENT.console['level']
30
30
  Mongoid.logger.level = Logger::DEBUG
31
31
  Mongoid.logger = Logger.new($stdout)
32
32
 
@@ -7,7 +7,7 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "frecon/base"
10
+ require 'frecon/base'
11
11
 
12
12
  module FReCon
13
13
  # Public: A wrapper to handle converting match numbers and storing them.
@@ -111,17 +111,17 @@ module FReCon
111
111
  # Match `args' against the regular expression, described below.
112
112
  #
113
113
  # This regular expression matches all values where the first group of
114
- # characters is one of either [ "p", "q", "qf", "sf", "f" ], which is
115
- # parsed as the "type" of the match. This is followed by an "m" and a
116
- # group of digits, which is parsed as the "number" of the match.
114
+ # characters is one of either [ 'p', 'q', 'qf', 'sf', 'f' ], which is
115
+ # parsed as the 'type' of the match. This is followed by an 'm' and a
116
+ # group of digits, which is parsed as the 'number' of the match.
117
117
  #
118
- # In addition, one can specify a "round number" following the first group
118
+ # In addition, one can specify a 'round number' following the first group
119
119
  # of characters such as in eliminations and finals. Often times, there
120
- # are multiple so-called "rounds" in eliminations, and so the system will
120
+ # are multiple so-called 'rounds' in eliminations, and so the system will
121
121
  # optionally capture that round.
122
122
  #
123
- # Also, one can specify a "replay number" following the match number.
124
- # this is done by appending "r" and a group of digits which is the replay
123
+ # Also, one can specify a 'replay number' following the match number.
124
+ # this is done by appending 'r' and a group of digits which is the replay
125
125
  # number.
126
126
  #
127
127
  # Below are listed the match groups and what they are:
@@ -136,44 +136,44 @@ module FReCon
136
136
  match_data = args.match(/(p|q|qf|sf|f)([\d]+)?m([\d]+)(r)?([\d]+)?/i)
137
137
 
138
138
  # Whine if we don't have a match (string is incorrectly formatted)
139
- raise ArgumentError, "string is improperly formatted" unless match_data
139
+ raise ArgumentError, 'string is improperly formatted' unless match_data
140
140
 
141
141
  # Check and set required stuff first, everything else later.
142
142
 
143
143
  # Whine if we don't have a match type
144
- raise ArgumentError, "match type must be supplied" unless match_data[1]
144
+ raise ArgumentError, 'match type must be supplied' unless match_data[1]
145
145
 
146
146
  # Parse the match type string
147
147
  @type = case match_data[1].downcase
148
- when "p"
148
+ when 'p'
149
149
  :practice
150
- when "q"
150
+ when 'q'
151
151
  :qualification
152
- when "qf"
152
+ when 'qf'
153
153
  :quarterfinal
154
- when "sf"
154
+ when 'sf'
155
155
  :semifinal
156
- when "f"
156
+ when 'f'
157
157
  :final
158
158
  else
159
- raise ArgumentError, "match type must be in [\"p\", \"q\", \"qf\", \"sf\", \"f\"]"
159
+ raise ArgumentError, 'match type must be in [\'p\', \'q\', \'qf\', \'sf\', \'f\']'
160
160
  end
161
161
 
162
162
  # Whine if we don't have a match number
163
- raise ArgumentError, "match number must be supplied" unless match_data[3]
163
+ raise ArgumentError, 'match number must be supplied' unless match_data[3]
164
164
 
165
165
  # Parse the match number
166
166
  @number = match_data[3].to_i
167
- raise ArgumentError, "match number must be greater than 0" unless @number > 0
167
+ raise ArgumentError, 'match number must be greater than 0' unless @number > 0
168
168
 
169
169
  # Parse the round number, if it is present
170
170
  if match_data[2]
171
171
  @round = match_data[2].to_i
172
- raise ArgumentError, "round number must be greater than 0" unless @round > 0
172
+ raise ArgumentError, 'round number must be greater than 0' unless @round > 0
173
173
  end
174
174
 
175
175
  # Parse replay match group, store replay number if present.
176
- @replay_number = match_data[5].to_i if match_data[4] == "r"
176
+ @replay_number = match_data[5].to_i if match_data[4] == 'r'
177
177
  elsif args.is_a?(Hash)
178
178
  # type (Symbol or String)
179
179
  # number (Integer)
@@ -183,31 +183,31 @@ module FReCon
183
183
  # Convert keys to symbols if needed.
184
184
  args = Hash[args.map { |key, value| [key.to_sym, value] }]
185
185
 
186
- raise TypeError, "type must be a Symbol or String" unless args[:type].is_a?(Symbol) || args[:type].is_a?(String)
186
+ raise TypeError, 'type must be a Symbol or String' unless args[:type].is_a?(Symbol) || args[:type].is_a?(String)
187
187
  raise ArgumentError, "type must be in #{POSSIBLE_TYPES.inspect}" unless POSSIBLE_TYPES.include?(args[:type].to_sym)
188
188
 
189
189
  @type = args[:type].to_sym
190
190
 
191
- raise TypeError, "match number must be an Integer" unless args[:number].is_an?(Integer)
192
- raise ArgumentError, "match number must be greater than 0" unless args[:number] > 0
191
+ raise TypeError, 'match number must be an Integer' unless args[:number].is_an?(Integer)
192
+ raise ArgumentError, 'match number must be greater than 0' unless args[:number] > 0
193
193
 
194
194
  @number = args[:number]
195
195
 
196
196
  if args[:round]
197
- raise TypeError, "round number must be an Integer" unless args[:round].is_an?(Integer)
198
- raise ArgumentError, "round number must be greater than 0" unless args[:round] > 0
197
+ raise TypeError, 'round number must be an Integer' unless args[:round].is_an?(Integer)
198
+ raise ArgumentError, 'round number must be greater than 0' unless args[:round] > 0
199
199
 
200
200
  @round = args[:round]
201
201
  end
202
202
 
203
203
  if args[:replay_number]
204
- raise TypeError, "replay number must be an Integer" unless args[:replay_number].is_an?(Integer)
205
- raise ArgumentError, "replay number must be greater than 0" unless args[:replay_number] > 0
204
+ raise TypeError, 'replay number must be an Integer' unless args[:replay_number].is_an?(Integer)
205
+ raise ArgumentError, 'replay number must be greater than 0' unless args[:replay_number] > 0
206
206
 
207
207
  @replay_number = args[:replay_number]
208
208
  end
209
209
  else
210
- raise TypeError, "argument must be a String or Hash"
210
+ raise TypeError, 'argument must be a String or Hash'
211
211
  end
212
212
  end
213
213
 
@@ -217,15 +217,15 @@ module FReCon
217
217
  def to_s
218
218
  type_string = case @type
219
219
  when :practice
220
- "p"
220
+ 'p'
221
221
  when :qualification
222
- "q"
222
+ 'q'
223
223
  when :quarterfinal
224
- "qf"
224
+ 'qf'
225
225
  when :semifinal
226
- "sf"
226
+ 'sf'
227
227
  when :final
228
- "f"
228
+ 'f'
229
229
  end
230
230
  match_string = "m#{@number}"
231
231
  replay_string = "r#{@replay_number}" if replay?
data/lib/frecon/model.rb CHANGED
@@ -7,8 +7,8 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "mongoid"
11
- require "frecon/mongoid/criteria"
10
+ require 'mongoid'
11
+ require 'frecon/mongoid/criteria'
12
12
 
13
13
  module FReCon
14
14
  # Public: A base class designed to assist with creating MongoDB Models
@@ -45,7 +45,7 @@ module FReCon
45
45
  # Examples
46
46
  #
47
47
  # # (Taken from the Team model)
48
- # register_routable_relation :matches, "matches"
48
+ # register_routable_relation :matches, 'matches'
49
49
  #
50
50
  # Returns the result of pushing an object to class's attributes
51
51
  # class variable.
@@ -82,18 +82,18 @@ module FReCon
82
82
  #
83
83
  # Returns the associated Controller if it exists, else nil.
84
84
  def self.controller
85
- (self.name.pluralize + "Controller").constantize
85
+ (self.name.pluralize + 'Controller').constantize
86
86
  end
87
87
 
88
88
  # Public: Validate that no invalid relations exist within this Model
89
89
  def no_invalid_relations
90
- # Get all of the belongs_to fields (ends with "_id" and not "_id" because that is the id).
90
+ # Get all of the belongs_to fields (ends with '_id' and not '_id' because that is the id).
91
91
  attributes.keys.select do |attribute|
92
- attribute.end_with?("_id") && attribute != "_id"
92
+ attribute.end_with?('_id') && attribute != '_id'
93
93
  end.each do |relation|
94
94
  # Get the model for the belongs_to association.
95
- model = "FReCon::".concat(relation.gsub(/_id\Z/, "").capitalize).constantize
96
- errors.add(relation.to_sym, "is invalid") if relation_invalid?(model, send(relation))
95
+ model = 'FReCon::'.concat(relation.gsub(/_id\Z/, '').capitalize).constantize
96
+ errors.add(relation.to_sym, 'is invalid') if relation_invalid?(model, send(relation))
97
97
  end
98
98
  end
99
99
 
@@ -7,7 +7,7 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "frecon/model"
10
+ require 'frecon/model'
11
11
 
12
12
  module FReCon
13
13
  # Public: The Competition model.
@@ -36,10 +36,10 @@ module FReCon
36
36
  Team.in id: robots.map(&:team_id)
37
37
  end
38
38
 
39
- register_routable_relation :matches, "matches"
40
- register_routable_relation :participations, "participations"
41
- register_routable_relation :records, "records"
42
- register_routable_relation :robots, "robots"
43
- register_routable_relation :teams, "teams"
39
+ register_routable_relation :matches, 'matches'
40
+ register_routable_relation :participations, 'participations'
41
+ register_routable_relation :records, 'records'
42
+ register_routable_relation :robots, 'robots'
43
+ register_routable_relation :teams, 'teams'
44
44
  end
45
45
  end
@@ -7,8 +7,8 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "frecon/model"
11
- require "frecon/match_number"
10
+ require 'frecon/model'
11
+ require 'frecon/match_number'
12
12
 
13
13
  module FReCon
14
14
  # Public: The Match model.
@@ -38,10 +38,10 @@ module FReCon
38
38
  Team.in id: robots.map(&:team_id)
39
39
  end
40
40
 
41
- register_routable_relation :competition, "competition"
42
- register_routable_relation :records, "records"
43
- register_routable_relation :participations, "participations"
44
- register_routable_relation :robots, "robots"
45
- register_routable_relation :teams, "teams"
41
+ register_routable_relation :competition, 'competition'
42
+ register_routable_relation :records, 'records'
43
+ register_routable_relation :participations, 'participations'
44
+ register_routable_relation :robots, 'robots'
45
+ register_routable_relation :teams, 'teams'
46
46
  end
47
47
  end
@@ -7,7 +7,7 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "frecon/model"
10
+ require 'frecon/model'
11
11
 
12
12
  module FReCon
13
13
  # Public: The Participation model.
@@ -28,10 +28,10 @@ module FReCon
28
28
  competition.matches
29
29
  end
30
30
 
31
- register_routable_relation :robot, "robot"
32
- register_routable_relation :team, "team"
33
- register_routable_relation :competition, "competition"
34
- register_routable_relation :matches, "matches"
35
- register_routable_relation :records, "records"
31
+ register_routable_relation :robot, 'robot'
32
+ register_routable_relation :team, 'team'
33
+ register_routable_relation :competition, 'competition'
34
+ register_routable_relation :matches, 'matches'
35
+ register_routable_relation :records, 'records'
36
36
  end
37
37
  end
@@ -7,8 +7,8 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "frecon/model"
11
- require "frecon/position"
10
+ require 'frecon/model'
11
+ require 'frecon/position'
12
12
 
13
13
  module FReCon
14
14
  # Public: The Record model.
@@ -36,10 +36,10 @@ module FReCon
36
36
  participation.robot.team
37
37
  end
38
38
 
39
- register_routable_relation :match, "match"
40
- register_routable_relation :competition, "competition"
41
- register_routable_relation :participation, "participation"
42
- register_routable_relation :robot, "robot"
43
- register_routable_relation :team, "team"
39
+ register_routable_relation :match, 'match'
40
+ register_routable_relation :competition, 'competition'
41
+ register_routable_relation :participation, 'participation'
42
+ register_routable_relation :robot, 'robot'
43
+ register_routable_relation :team, 'team'
44
44
  end
45
45
  end
@@ -7,7 +7,7 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "frecon/model"
10
+ require 'frecon/model'
11
11
 
12
12
  module FReCon
13
13
  # Public: The Robot model.
@@ -35,10 +35,10 @@ module FReCon
35
35
  Match.in id: records.map(&:match_id).uniq
36
36
  end
37
37
 
38
- register_routable_relation :team, "team"
39
- register_routable_relation :participations, "participations"
40
- register_routable_relation :competitions, "competitions"
41
- register_routable_relation :records, "records"
42
- register_routable_relation :matches, "matches"
38
+ register_routable_relation :team, 'team'
39
+ register_routable_relation :participations, 'participations'
40
+ register_routable_relation :competitions, 'competitions'
41
+ register_routable_relation :records, 'records'
42
+ register_routable_relation :matches, 'matches'
43
43
  end
44
44
  end
@@ -7,7 +7,7 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "frecon/model"
10
+ require 'frecon/model'
11
11
 
12
12
  module FReCon
13
13
  # Public: The Team model.
@@ -51,11 +51,11 @@ module FReCon
51
51
  Match.in competition_id: competitions.map(&:id)
52
52
  end
53
53
 
54
- register_routable_relation :robots, "robots"
55
- register_routable_relation :participations, "participations"
56
- register_routable_relation :competitions, "competitions"
57
- register_routable_relation :records, "records"
58
- register_routable_relation :matches, "matches"
54
+ register_routable_relation :robots, 'robots'
55
+ register_routable_relation :participations, 'participations'
56
+ register_routable_relation :competitions, 'competitions'
57
+ register_routable_relation :records, 'records'
58
+ register_routable_relation :matches, 'matches'
59
59
 
60
60
  # alias_method works by default solely on instance
61
61
  # methods, so change context to the metaclass of
data/lib/frecon/models.rb CHANGED
@@ -7,9 +7,9 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "frecon/models/competition"
11
- require "frecon/models/match"
12
- require "frecon/models/participation"
13
- require "frecon/models/record"
14
- require "frecon/models/robot"
15
- require "frecon/models/team"
10
+ require 'frecon/models/competition'
11
+ require 'frecon/models/match'
12
+ require 'frecon/models/participation'
13
+ require 'frecon/models/record'
14
+ require 'frecon/models/robot'
15
+ require 'frecon/models/team'
@@ -7,7 +7,7 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "mongoid"
10
+ require 'mongoid'
11
11
 
12
12
  # Public: An extension for the Mongoid module.
13
13
  module Mongoid
@@ -17,7 +17,7 @@ module Mongoid
17
17
  # Public: Filter by given PSV parameters.
18
18
  #
19
19
  # PSV is an introduced system that can be used within query strings to
20
- # narrow a query. Since HTTP query strings can use "+" to act as spaces
20
+ # narrow a query. Since HTTP query strings can use '+' to act as spaces
21
21
  # within a key-value pair, one can use these pluses to define nested
22
22
  # query parameters when querying the database as in an indexing or
23
23
  # showing request.
@@ -26,12 +26,12 @@ module Mongoid
26
26
  #
27
27
  # Examples
28
28
  #
29
- # Record.all.psv_filter({"participation robot team number" => "2503"})
29
+ # Record.all.psv_filter({'participation robot team number' => '2503'})
30
30
  # => #<Mongoid::Criteria ...>
31
31
  #
32
32
  # # Since each instance of Record has a :team shortcut method,
33
33
  # # we can just filter it like so.
34
- # Record.all.psv_filter({"team number" => "2503"})
34
+ # Record.all.psv_filter({'team number' => '2503'})
35
35
  # => #<Mongoid::Criteria ...>
36
36
  #
37
37
  # Returns a filtered version of self.
@@ -55,20 +55,20 @@ module Mongoid
55
55
 
56
56
  # Create a comparison hash to be used to compare <attribute> to
57
57
  # <expected value>.
58
- if comparison_value.length == 0 || comparison_value == "__nil__"
58
+ if comparison_value.length == 0 || comparison_value == '__nil__'
59
59
  comparison_hash = {comparison_key => nil}
60
60
  else
61
61
  comparison_hash = {comparison_key => comparison_value}
62
62
  end
63
63
 
64
64
  # Each of the subsequent keys should be a model name. Generate a string
65
- # corresponding to the "<model>" + "_id" for use as the comparison key,
65
+ # corresponding to the '<model>' + '_id' for use as the comparison key,
66
66
  # and find the model class by generating a constant.
67
67
  #
68
68
  # Then, nest a comparison around the current comparison hash.
69
69
  psv_keys.each do |model|
70
70
  model_id = (model.to_s + '_id').to_sym
71
- model_class = ("FReCon::" + model.to_s.capitalize).constantize
71
+ model_class = ('FReCon::' + model.to_s.capitalize).constantize
72
72
 
73
73
  comparison_hash = {model_id => model_class.in(comparison_hash).map(&:id)}
74
74
  end
@@ -7,7 +7,7 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "frecon/base"
10
+ require 'frecon/base'
11
11
 
12
12
  module FReCon
13
13
  # Public: A wrapper to handle converting team positions and storing them.
@@ -102,7 +102,7 @@ module FReCon
102
102
  # Match `string' against the regular expression, described below.
103
103
  #
104
104
  # This regular expression matches all values for `string' where
105
- # the first letter is either "r" or "b" (case-insensitive due to /i
105
+ # the first letter is either 'r' or 'b' (case-insensitive due to /i
106
106
  # at the end of the regular expression) and the last one-or-more
107
107
  # characters in the string are digits 0-9. Anything between those two
108
108
  # that is either a letter or an underscore is not retained, but
@@ -110,8 +110,8 @@ module FReCon
110
110
  # will not match.
111
111
  #
112
112
  # You can use any words you like if you have more than just
113
- # "r<n>" or "b<n>", for example "red_2" matches just the same
114
- # as "r2", or, just for fun, just the same as "royal______2".
113
+ # 'r<n>' or 'b<n>', for example 'red_2' matches just the same
114
+ # as 'r2', or, just for fun, just the same as 'royal______2'.
115
115
  #
116
116
  # This behavior may change in the future.
117
117
  match_data = args[0].match(/^([rb])[a-z\_]*([0-9]+)/i)
@@ -120,29 +120,29 @@ module FReCon
120
120
  # string that was matched, hence the indices that start
121
121
  # at one.
122
122
 
123
- raise ArgumentError, "string is improperly formatted" unless match_data
123
+ raise ArgumentError, 'string is improperly formatted' unless match_data
124
124
 
125
125
  @alliance = case match_data[1].downcase
126
- when "b"
126
+ when 'b'
127
127
  :blue
128
- when "r"
128
+ when 'r'
129
129
  :red
130
130
  else
131
- raise ArgumentError, "alliance character must be in [\"b\", \"r\"]"
131
+ raise ArgumentError, "alliance character must be in ['b', 'r']"
132
132
  end
133
133
 
134
134
  position_number = match_data[2].to_i
135
- raise ArgumentError, "position number must be in [1, 2, 3]" unless [1, 2, 3].include?(position_number)
135
+ raise ArgumentError, 'position number must be in [1, 2, 3]' unless [1, 2, 3].include?(position_number)
136
136
 
137
137
  @number = position_number
138
138
  elsif args.length == 2
139
- raise TypeError, "alliance must be a Symbol or String" unless args[0].is_a?(Symbol) || args[0].is_a?(String)
140
- raise ArgumentError, "alliance must be in [:blue, :red]" unless [:blue, :red].include?(args[0].to_sym)
139
+ raise TypeError, 'alliance must be a Symbol or String' unless args[0].is_a?(Symbol) || args[0].is_a?(String)
140
+ raise ArgumentError, 'alliance must be in [:blue, :red]' unless [:blue, :red].include?(args[0].to_sym)
141
141
 
142
142
  @alliance = args[0].to_sym
143
143
 
144
- raise TypeError, "second argument must be an Integer" unless args[1].is_an?(Integer)
145
- raise ArgumentError, "second argument must be in [1, 2, 3]" unless [1, 2, 3].include?(args[1])
144
+ raise TypeError, 'second argument must be an Integer' unless args[1].is_an?(Integer)
145
+ raise ArgumentError, 'second argument must be in [1, 2, 3]' unless [1, 2, 3].include?(args[1])
146
146
 
147
147
  @number = args[1]
148
148
  else
@@ -7,7 +7,7 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "json"
10
+ require 'json'
11
11
 
12
12
  # Public: A class representing errors that emanate from request handling.
13
13
  class RequestError < StandardError
data/lib/frecon/routes.rb CHANGED
@@ -7,7 +7,7 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "frecon/controllers"
10
+ require 'frecon/controllers'
11
11
 
12
12
  module FReCon
13
13
  # Public: A module containing all of the routes.
@@ -74,13 +74,13 @@ module FReCon
74
74
  begin
75
75
  @model = controller.find_model(params)
76
76
 
77
- params.delete("id")
77
+ params.delete('id')
78
78
 
79
79
  result = @model.method(model_attribute_method[:method]).call
80
80
 
81
81
  if result.is_a? Mongoid::Criteria
82
- params.delete("splat")
83
- params.delete("captures")
82
+ params.delete('splat')
83
+ params.delete('captures')
84
84
 
85
85
  result.psv_filter(params).to_json
86
86
  else
@@ -97,25 +97,25 @@ module FReCon
97
97
  #
98
98
  # base - The child that included this module (should be a Sinatra App)
99
99
  def self.included(base)
100
- resource_routes base, "teams", TeamsController
101
- resource_routes base, "competitions", CompetitionsController
102
- resource_routes base, "matches", MatchesController
103
- resource_routes base, "records", RecordsController
104
- resource_routes base, "robots", RobotsController
105
- resource_routes base, "participations", ParticipationsController
106
-
107
- attribute_routes base, "teams", TeamsController
108
- attribute_routes base, "competitions", CompetitionsController
109
- attribute_routes base, "matches", MatchesController
110
- attribute_routes base, "records", RecordsController
111
- attribute_routes base, "robots", RobotsController
112
- attribute_routes base, "participations", ParticipationsController
100
+ resource_routes base, 'teams', TeamsController
101
+ resource_routes base, 'competitions', CompetitionsController
102
+ resource_routes base, 'matches', MatchesController
103
+ resource_routes base, 'records', RecordsController
104
+ resource_routes base, 'robots', RobotsController
105
+ resource_routes base, 'participations', ParticipationsController
106
+
107
+ attribute_routes base, 'teams', TeamsController
108
+ attribute_routes base, 'competitions', CompetitionsController
109
+ attribute_routes base, 'matches', MatchesController
110
+ attribute_routes base, 'records', RecordsController
111
+ attribute_routes base, 'robots', RobotsController
112
+ attribute_routes base, 'participations', ParticipationsController
113
113
 
114
114
  base.before do
115
- params.delete("_")
115
+ params.delete('_')
116
116
  end
117
117
 
118
- base.get "/dump" do
118
+ base.get '/dump' do
119
119
  begin
120
120
  DumpController.full params
121
121
  rescue RequestError => e
@@ -123,7 +123,7 @@ module FReCon
123
123
  end
124
124
  end
125
125
 
126
- if ENV["PRINT_ROUTES"]
126
+ if ENV['PRINT_ROUTES']
127
127
  base.routes.each do |verb, routes|
128
128
  puts "#{verb}:"
129
129
 
@@ -7,7 +7,7 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "httparty"
10
+ require 'httparty'
11
11
 
12
12
  module FReCon
13
13
  # The default scraper scrapes other FReCon instances.
@@ -24,9 +24,9 @@ module FReCon
24
24
  data = JSON.parse(data)
25
25
 
26
26
  if context[:type] == :single && data.empty?
27
- return [404, "Could not find a model with that query."]
27
+ return [404, 'Could not find a model with that query.']
28
28
  elsif
29
- puts "Just a heads up: you are importing an empty array of data."
29
+ puts 'Just a heads up: you are importing an empty array of data.'
30
30
  end
31
31
 
32
32
  # Here we want `context` to tell us what model we are making.
@@ -38,7 +38,7 @@ module FReCon
38
38
  statuses = data.map do |key, value|
39
39
  begin
40
40
  unless value.empty?
41
- model = ("FReCon::" + key.singularize.capitalize).constantize
41
+ model = ('FReCon::' + key.singularize.capitalize).constantize
42
42
  result = model.controller.create(nil, nil, value)
43
43
  result.first == 201 ? result.first : JSON.parse(result.last)
44
44
  end
@@ -56,12 +56,12 @@ module FReCon
56
56
  # If two arguments are passed, will import the models that match
57
57
  # the query params.
58
58
  def get(model = nil, query = {})
59
- # Turns something like "team" into Team.
60
- model = ("FReCon::" + model.capitalize).constantize if model.is_a?(String)
59
+ # Turns something like 'team' into Team.
60
+ model = ('FReCon::' + model.capitalize).constantize if model.is_a?(String)
61
61
 
62
62
  # The route name for the model branch.
63
- route_name = model.name.gsub(/FReCon::/, "").downcase.pluralize if model
64
-
63
+ route_name = model.name.gsub(/FReCon::/, '').downcase.pluralize if model
64
+
65
65
  if !model && query.empty?
66
66
  type = :dump
67
67
  data = HTTParty.get("http://#{@base_uri}/dump")
@@ -7,4 +7,4 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "frecon/scraper"
10
+ require 'frecon/scraper'
data/lib/frecon/server.rb CHANGED
@@ -7,12 +7,12 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "sinatra/base"
10
+ require 'sinatra/base'
11
11
 
12
- require "frecon/base/variables"
13
- require "frecon/database"
14
- require "frecon/routes"
15
- require "frecon/controllers"
12
+ require 'frecon/base/variables'
13
+ require 'frecon/database'
14
+ require 'frecon/routes'
15
+ require 'frecon/controllers'
16
16
 
17
17
  module FReCon
18
18
  # Public: The Sinatra web server.
@@ -20,7 +20,7 @@ module FReCon
20
20
  include Routes
21
21
 
22
22
  before do
23
- content_type "application/json"
23
+ content_type 'application/json'
24
24
  end
25
25
 
26
26
  # Public: Start the Server.
@@ -40,8 +40,8 @@ module FReCon
40
40
  def self.setup!
41
41
  # Set the Thin and Sinatra options.
42
42
  set :server, %w[thin HTTP webrick]
43
- set :bind, FReCon::ENVIRONMENT.server["host"]
44
- set :port, FReCon::ENVIRONMENT.server["port"]
43
+ set :bind, FReCon::ENVIRONMENT.server['host']
44
+ set :port, FReCon::ENVIRONMENT.server['port']
45
45
  set :environment, FReCon::ENVIRONMENT.variable.to_s
46
46
 
47
47
  # Set up the database.
data/lib/frecon.rb CHANGED
@@ -7,22 +7,22 @@
7
7
  # license with this program. If not, please see
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
- require "mongoid"
10
+ require 'mongoid'
11
11
 
12
- require "frecon/base"
12
+ require 'frecon/base'
13
13
 
14
- require "frecon/controller"
15
- require "frecon/controllers"
16
- require "frecon/model"
17
- require "frecon/models"
18
- require "frecon/scraper"
19
- require "frecon/scrapers"
14
+ require 'frecon/controller'
15
+ require 'frecon/controllers'
16
+ require 'frecon/model'
17
+ require 'frecon/models'
18
+ require 'frecon/scraper'
19
+ require 'frecon/scrapers'
20
20
 
21
- require "frecon/match_number"
22
- require "frecon/position"
23
- require "frecon/request_error"
24
- require "frecon/routes"
21
+ require 'frecon/match_number'
22
+ require 'frecon/position'
23
+ require 'frecon/request_error'
24
+ require 'frecon/routes'
25
25
 
26
- require "frecon/database"
27
- require "frecon/server"
28
- require "frecon/console"
26
+ require 'frecon/database'
27
+ require 'frecon/server'
28
+ require 'frecon/console'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frecon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Craig
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2015-12-05 00:00:00.000000000 Z
16
+ date: 2015-12-08 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: sinatra