Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.3:Update
ghc-app-settings
ghc-app-settings.spec
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ghc-app-settings.spec of Package ghc-app-settings
# # spec file for package ghc-app-settings # # Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ # %global pkg_name app-settings %bcond_with tests Name: ghc-%{pkg_name} Version: 0.2.0.11 Release: 0 Summary: A library to manage application settings (INI file-like) License: BSD-3-Clause Group: Development/Languages/Other Url: https://hackage.haskell.org/package/%{pkg_name} Source0: https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz BuildRequires: ghc-Cabal-devel BuildRequires: ghc-containers-devel BuildRequires: ghc-directory-devel BuildRequires: ghc-mtl-devel BuildRequires: ghc-parsec-devel BuildRequires: ghc-rpm-macros BuildRequires: ghc-text-devel BuildRoot: %{_tmppath}/%{name}-%{version}-build %if %{with tests} BuildRequires: ghc-HUnit-devel BuildRequires: ghc-hspec-devel %endif %description A library to deal with application settings. This library deals with read-write application settings. You will have to specify the settings that your application uses, their name, types and default values. Setting types must implement the 'Read' and 'Show' typeclasses. The settings are saved in a file in an INI-like key-value format (without sections). Reading and updating settings is done in pure code, the IO monad is only used to load settings and save them to disk. It is advised for the user to create a module in your project holding settings handling. You can then declare settings: > fontSize :: Setting Double > fontSize = Setting "fontSize" 14 > > dateFormat :: Setting String > dateFormat = Setting "dateFormat" "%{x}" > > backgroundColor :: Setting (Int, Int, Int) > backgroundColor = Setting "backcolor" (255, 0, 0) Optionally you can declare the list of all your settings, in that case the application will also save the default values in the configuration file, but commented out: > fontSize=16 > # dateFormat="%x" > # backcolor=(255,0,0) If you do not specify the list of settings, only the first line would be present in the configuration file. With an ordinary setting, one row in the configuration file means one setting. That setting may of course be a list for instance. This setup works very well for shorter lists like [1,2,3], however if you have a list of more complex items, you will get very long lines and a configuration file very difficult to edit by hand. For these special cases there is also the 'ListSetting' constructor: > testList :: Setting [String] > testList = ListSetting "testList" ["list1", "list2", "list3"] Now the configuration file looks like that: > testList_1="list1" > testList_2="list2" > testList_3="list3" Which is much more handy for big lists. An empty list is represented like so: > testList= There is also another technique that you can use if you have too long lines: you can put line breaks in the setting values if you start the following lines with a leading space, like so: > testList=["list1", > "list2", "list3"] In that case don't use the ListSetting option. Any character after the the leading space in the next lines will go in the setting value. Note that the library will automatically wrap setting values longer than 80 characters when saving. Once we declared the settings, we can read the configuration from disk (and your settings module should export your wrapper around the function offered by this library): > readResult <- try $ readSettings (AutoFromAppName "test") > case readResult of > Right (conf, GetSetting getSetting) -> do > let textSize = getSetting fontSize > saveSettings emptyDefaultConfig (AutoFromAppName "test") conf > Left (x :: SomeException) -> error "Error reading the config file!" 'AutoFromAppName' specifies where to save the configuration file. And we've already covered the getSetting in this snippet, see the 'readSettings' documentation for further information. You can also look at the tests of the library on the github project for sample use. %package devel Summary: Haskell %{pkg_name} library development files Group: Development/Libraries/Other Requires: %{name} = %{version}-%{release} Requires: ghc-compiler = %{ghc_version} Requires(post): ghc-compiler = %{ghc_version} Requires(postun): ghc-compiler = %{ghc_version} %description devel This package provides the Haskell %{pkg_name} library development files. %prep %setup -q -n %{pkg_name}-%{version} %build %ghc_lib_build %install %ghc_lib_install %check %cabal_test %post devel %ghc_pkg_recache %postun devel %ghc_pkg_recache %files -f %{name}.files %defattr(-,root,root,-) %doc LICENSE %files devel -f %{name}-devel.files %defattr(-,root,root,-) %changelog
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor