frc-frecon / frecon

An API for building scouting apps for FRC competitions
MIT License
3 stars 0 forks source link

Modularize the Configuration and Environment. #77

Closed rye closed 9 years ago

rye commented 9 years ago

How it is now

We have a raw Symbol being stored in lib/frecon/base/variables.rb that is used as our environment configuration. There are corresponding getter/setter methods, but nothing overly special. Furthermore, a completely separate configuration system is used for retrieving and comprehending configurations.

How It Should Be™

We should really have a single system, lib/frecon/environment.rb that is used to go out and do the hunting for configuration. A new Environment class will be created, and it will handle the business logic. It'll be Hash-like, but pre-filled and basically static. This Environment class will be used to (i) parse the various configurations around the place; (ii) handle any changes that are made by CLI arguments; and (iii) spit out stuff intelligently.

rye commented 9 years ago

We could also create a separate Version class to handle the version.

rye commented 9 years ago

@Sammidysam and I talked about this yesterday, and he agrees that having two separate things is fairly redundant.

rye commented 9 years ago

I would argue that Configuration is included with Environment; a system's environment should incorporate the configurations. So, my recommendation is that we introduce my new Environment class and replace the existing Configuration class with that.

This new Environment class would incorporate not only the business logic for reading and manipulating Configurations, but also switching between "execution environments" (e.g. :development, :production, :test).

We should probably rework the Configuration structure to make it a bit smarter and less redundant. Databases should probably just use the current "execution environment" as their session name. (This Session Name is currently one of the keys under the frecon.database.mongoid thing) Thus, we can reduce the database configuration down to the database' name and hosts values.

Probably, the best way about this will be to remove all of the existing stuff and just patch stuff in, since the spec is still lagging behind.

rye commented 9 years ago

We should also work hard on ensuring that the XDG Base Directory specification is heavily followed. Windows compatibility should probably be thought-about as well.