Note to install the software below we recommend the following package managers:
- Mac OS X: Homebrew
- Linux/Unix: bundled package manager (e.g. apt-get, yum)
- Ruby
- Use of rbenv is recommended.
- Running
rbenv installin the project root will install the version you need. - If not using
rbenv, see the.ruby-versionfile in the project root to get the required version number. - Bundler is expected to be available. Run
gem install bundlerto install it.
- Node
- Use of nvm is recommended.
- Running
nvm installin the project root will install the version you need. - Note that
nvmdoes NOT shim Node executables sonvm useis required to load the right Node versions in each new shell session. - If not using
nvm, see the.nvmrcfile in the project root to get the required version number. - The
yarnNode module is expected to be installed globally. Runnpm install -g yarnto install it.
- Memcached 1.4+
- For development environments, caching is only needed if you are developing a feature that uses caching and want to test it.
- In this case, be sure to increase the default slab page size to 2 MB. This is done by passing
-I 2mto thememcachedcommand.
- PostgreSQL 10+
- Create empty databases for use by the app:
createdb nemo_development && createdb nemo_test
- Create empty databases for use by the app:
- ImageMagick 6.7+
- ImageMagick is used to resize uploaded images.
- It should be available through any of the package managers listed above. If not it can be built from source.
- Chrome (Browser) 60+
- Used for automated browser testing.
- Chromedriver 2.35+
- Handles running Chrome headlessly for feature specs.
- It should be available through any of the package managers listed above. If not it can be built from source.
- The Rails Gem that talks to Chromedriver is called
selenium-webdriver.
- GraphViz 2.36+
- GraphViz is used to visualize the relationships between data in the database.
Linters are strongly recommended for checking your code before opening a PR. The CI system will run linters as well and your PR won't be approved until all issues are resolved or cancelled by the reviewer.
The below assume you have installed the Ruby and Node versions specified in .ruby-version and .nvmrc files, respectively.
Once you have nvm and Node installed, the following lines should give you all the required linters:
nvm use
npm install -g coffeelint@2.1.0
npm install -g eslint@4.17.0
npm install -g eslint-plugin-react@7.7.0
gem install rubocop -v 0.52.0
gem install scss_lint -v 0.56.0
To lint your code, simply run:
bin/lint
This will examine any modified or untracked files in your working copy.
To instead examine any new or modified files in your branch (not including uncommitted changes), run:
bin/lint --branch
The latter should be run before opening a pull request.
As part of an effort to clean up old code, you should try to resolve any linter errors in files you touch, unless there are an overwhelming number of them. At bare minimum, the lines you touch should not have any lint.
Most code editors have plugins for linting. They will identify and let you click directly into problematic lines. You are encouraged to try one out!
For Atom, install the linter package which contains shared stuff, then:
linter-eslint- For this one, set your Global Node Installation Path and check the 'Use global ESLint installation' box.
linter-coffeelintlinter-rubocoplinter-scss-lint
git clone https://github.com/thecartercenter/nemo.git
cd nemo
If developing, it's best to work off the development branch:
git checkout develop
- Install the required gems by running
bundle installin the project directory. - Install the required Node modules by running
yarn installin the project directory. - Run
cp config/database.yml.example config/database.yml. - Run
cp config/settings.local.yml.example config/settings.local.ymland adjust settings as appropriate. - Run
cp config/initializers/local_config.rb.example config/initializers/local_config.rband adjust settings as appropriate. Note that the reCAPTCHA and Google Maps API Key must be valid keys for those services in order for tests to pass. - Setup the UUID postgres extension:
- On Linux:
sudo -u postgres psql nemo_development -c 'CREATE EXTENSION "uuid-ossp"' - On Mac with Homebrew:
psql nemo_development -c 'CREATE EXTENSION "uuid-ossp"'
- On Linux:
- Load the database schema:
bundle exec rake db:schema:load. - Pre-process the theme SCSS files:
bundle exec rake theme:preprocess - Create an admin account:
bundle exec rake db:create_admin. You should receive a message like this: "Admin user created with username admin, password hTyWc9Q6" (The password is random, copy it and use on your first login). - Optionally, you can create some fake data to get things rolling by running
bundle exec rake db:create_fake_data.
- Run
nvm useto ensure you have the right version of Node.js loaded. Do this once per console session. - Run
rspec. - All tests should pass. Running them takes about 10-15 minutes.
- If you have trouble debugging a feature spec, you can run it headed (so you can watch the browser go through the spec) by doing
HEADED=1 bundle exec rspec spec/features/your_spec.rb.
For a development setup, run nvm use && rails s.
You may want to run bundle exec rake db:create_fake_data to create a sample mission.
- Navigate to http://localhost:3000
- Login with username admin and use the random password that was generated when you ran
bundle exec rake db:create_admin(make sure to change the password after login). - Create a new Mission and get started making forms!
- Download the ODK application onto your Android phone or tablet
- Configure your rails development server so ODK can find it
- Run
rails s -p 8443 -b 0.0.0.0
- Run
- Create a user and password
- Publish your form in NEMO
- Point the ODK app to your development server
- In ODK, go to
General Settings > Platform Settings > URL - For the URL put:
http://YOURIP:8443/m/yourmission - Also put in your username and password
- In ODK, go to
- Retrieve Form
- In ODK, you should now be able to go to
Get Blank Formto download the forms from NEMO
- In ODK, you should now be able to go to