0.02
No commit activity in last 3 years
No release in over 3 years
Parliament Utils gem.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0.1
~> 5.1
~> 10.0
~> 0.12
~> 1.3, < 1.4
~> 3.0
~> 2.3

Runtime

 Project Readme

Parliament::Utils

parliament-utils, created by the Parliamentary Digital Service, holds all reusable application configuration, test set up and generic helper methods. It is intended to be used across all applications making up the UK Parliament's website.

NOTE: This gem is in active development and is likely to change at short notice. It is not recommended that you use this in any production environment.

Requirements

parliament-utils requires the following:

Installation

Within your application, add this line to your application's Gemfile:

gem 'parliament-utils'

Once you add the gem to your Gemfile run:

bundle install

Usage

Follow installation instructions below to integrate the parliament-utils gem into an existing application

Now all application configuration, test set up and helper methods should be available within your application.

Instructions

The following steps can be followed to include this gem in your application:

Gemfile

  1. Add gem 'parliament-utils' to Gemfile, below parliament-grom-decorators
  2. Ensure latest version of pugin gem version tbc

config 3. Delete config/initializers folder 4. Delete config/puma.rb file 5. Add require 'parliament/utils' to config/application.rb file, below require 'pugin'

spec/spec_helper 5. Remove all contents from spec/spec_helper

spec/rails_helper 6. Remove VCR and RSpec configuration blocks 7. Remove the following code, if it exists

`require 'parliament/ntriple'`
`require 'vcr'`
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
  1. Add the following code:
require 'parliament/utils/test_helpers'
RSpec.configure do |config|
  Parliament::Utils::TestHelpers.included_modules.each do |m|
    m.load_rspec_config(config)
  end
end

spec/helpers

  1. Delete flag_helper_spec.rb file, if it exists

spec/controllers/concerns

  1. Delete postcode_helper_spec.rb file, if it exists

app/controllers/concerns

  1. Delete format_helper.rb, houses_helper.rb, parliament_helper.rb, postcode_helper.rb, request_helper.rb, v_card_helper.rb files, if they exist

app/controllers/application_controller 12. Remove the following references to Helpers, if they exist

require 'houses_helper'
require 'request_helper'
require 'parliament_helper'
require 'format_helper'
require 'v_card_helper'
include HousesHelper
include RequestHelper
include ParliamentHelper
include FormatHelper
include VCardHelper
  1. Add require 'parliament/utils'
  2. Add the following include statements to the ApplicationController class (ResourceHelper and VCardHelper may not be required in all apps)
include ResourceHelper
include Parliament::Utils::Helpers::ApplicationHelper
include Parliament::Utils::Helpers::VCardHelper
  1. Remove data_check, data_url, build_request, populate_alternates methods, if they exist

app/helpers

  1. Delete application_helper.rb, flag_helper.rb files, if they exist

Referencing new gem modules

  1. Find all instances of the Helpers mentioned below (in entire project) and replace/use as required:
Replace `ApplicationHelper` with `Parliament::Utils::Helpers::ApplicationHelper`
Replace `FlagHelper` with `Parliament::Utils::Helpers::FlagHelper`
Replace `FormatHelper` with `Parliament::Utils::Helpers::FormatHelper`
Replace `HousesHelper` with `Parliament::Utils::Helpers::HousesHelper`
Replace `ParliamentHelper` with `Parliament::Utils::Helpers::ParliamentHelper`
Replace `PostcodeHelper` with `Parliament::Utils::Helpers::PostcodeHelper`
Replace `RequestHelper` with `Parliament::Utils::Helpers::RequestHelper`
Replace `VCardHelper` with `Parliament::Utils::Helpers::VCardHelper`

Getting Started with Development

To clone the repository and set up the dependencies, run the following:

git clone https://github.com/ukparliament/parliament-utils.git
cd parliament-utils
bundle install

Running Tests

We use Rspec as our testing framework and tests can be run using:

bundle exec rake

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Ensure your changes are tested using Rspec
  6. Create a new Pull Request

License

parliament-utils is licensed under the Open Parliament Licence.