Permalink
Browse files

Add license field to package metadata

  • Loading branch information...
earlbread committed Aug 29, 2017
1 parent 73ea891 commit d060adc51b4044ce98ae8c3c8be7f3167b88a8da
View
@@ -43,6 +43,7 @@ is an example:
version = "1.0.0" # (required)
description = "Short description on the package"
license = "MIT"
[[authors]]
name = "John Doe" # (required)
@@ -57,6 +58,9 @@ It consists of the following fields (*emphasized fields* are required):
`description` (string)
: An optional short description of the package.
`license` (string)
: An optional license of the package.
`authors` (array of tables)
: The list of authors. Note that it can be empty, but `name` field is
required if any author is provided. Each author table consists of
@@ -6,6 +6,7 @@ module Nirum.Package.Metadata ( Author (Author, email, name, uri)
, target
, version
, description
, license
)
, MetadataError ( FieldError
, FieldTypeError
@@ -96,11 +97,12 @@ deriving instance (Ord t, Target t) => Ord (Package t)
deriving instance (Show t, Target t) => Show (Package t)
packageTarget :: Target t => Package t -> t
packageTarget Package { metadata = Metadata _ _ _ t } = t
packageTarget Package { metadata = Metadata _ _ _ _ t } = t
data Metadata t =
Metadata { version :: SV.Version
, description :: Maybe Text
, license :: Maybe Text
, authors :: [Author]
, target :: (Eq t, Ord t, Show t, Target t) => t
}
@@ -181,6 +183,7 @@ parseMetadata metadataPath' tomlText = do
version' <- versionField "version" table
authors' <- authorsField "authors" table
description' <- optional $ stringField "description" table
license' <- optional $ stringField "license" table
targets <- case tableField "targets" table of
Left (FieldError _) -> Right HM.empty
otherwise' -> otherwise'
@@ -194,6 +197,7 @@ parseMetadata metadataPath' tomlText = do
otherwise' -> otherwise'
return Metadata { version = version'
, description = description'
, license = license'
, authors = authors'
, target = target'
}
@@ -122,6 +122,7 @@ import Nirum.Package.Metadata ( Author (Author, name, email)
, target
, version
, description
, license
)
, MetadataError ( FieldError
, FieldTypeError
@@ -1192,6 +1193,7 @@ setup(
name='{pName}',
version='{pVersion}',
description=$pDescription,
license=$pLicense,
author=$author,
author_email=$authorEmail,
package_dir=\{'': SOURCE_ROOT},
@@ -1217,6 +1219,10 @@ setup(
pDescription = case description metadata' of
Just value -> stringLiteral value
Nothing -> "None"
pLicense :: Code
pLicense = case license metadata' of
Just value -> stringLiteral value
Nothing -> "None"
strings :: [Code] -> Code
strings values = T.intercalate ", " $ map stringLiteral (L.sort values)
author :: Code
@@ -39,6 +39,7 @@ package :: Package DummyTarget
package = Package { metadata = Metadata { version = SV.version 0 0 1 [] []
, authors = []
, description = Nothing
, license = Nothing
, target = DummyTarget
}
, modules = modules'
@@ -128,6 +128,13 @@ spec =
, "string"
, "integer (123)"
)
, ( [q|version = "1.2.3"
license = 123
|]
, "license"
, "string"
, "integer (123)"
)
] $ \ (toml, field, expected, actual) -> do
let Left e = parse toml
FieldTypeError field' expected' actual' = e
@@ -40,6 +40,7 @@ import Nirum.Package.Metadata ( Metadata ( Metadata
, target
, version
, description
, license
)
, MetadataError (FormatError)
, Target (targetName)
@@ -62,6 +63,7 @@ createValidPackage :: t -> Package t
createValidPackage t = createPackage Metadata { version = SV.initial
, authors = []
, description = Nothing
, license = Nothing
, target = t
} validModules
@@ -110,6 +112,7 @@ testPackage target' = do
metadata' = Metadata { version = SV.version 0 3 0 [] []
, authors = []
, description = Nothing
, license = Nothing
, target = target'
}
metadata package `shouldBe` metadata'
@@ -41,7 +41,8 @@ import Nirum.Package.Metadata ( Author (Author, email, name, uri)
, authors
, target
, version
, description)
, description
, license)
, Target (compilePackage)
)
import qualified Nirum.Package.ModuleSet as MS
@@ -100,6 +101,7 @@ makeDummySource' pathPrefix m renames =
}
]
, description = Just "Package description"
, license = Just "MIT"
, target = Python "sample-package" minimumRuntime renames
}
pkg :: Package Python
@@ -1,5 +1,6 @@
version = "0.3.0"
description = "Package description"
license = "MIT"
[[authors]]
name = "nirum"
@@ -22,3 +22,4 @@ def test_setup_metadata():
}
assert ['0.3.0'] == pkg['Version']
assert ['Package description'] == pkg['Summary']
assert ['MIT'] == pkg['License']

0 comments on commit d060adc

Please sign in to comment.