Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
25a87138
Commit
25a87138
authored
Nov 17, 2011
by
Enrique García Cota
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
started creating the licenses auto-updater
parent
77747418
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
licenses.rake
lib/tasks/licenses.rake
+44
-0
No files found.
lib/tasks/licenses.rake
0 → 100644
View file @
25a87138
def
create_license
(
name
,
identifier
,
url
,
version_identifier
,
date
,
version_url
)
license
=
License
.
new
(
:name
=>
name
,
:identifier
=>
identifier
,
:url
=>
url
)
version
=
license
.
versions
.
build
(
:identifier
=>
version_identifier
,
:date
=>
date
,
:url
=>
version_url
)
license
.
save
end
namespace
:licenses
do
desc
"creates default licenses, imports them, and removes the license custom field from ohwr"
task
:all
=>
[
:destroy_all
,
:create
]
desc
"destroys all licenses"
task
:destroy_all
=>
:environment
do
License
.
destroy_all
LicenseVersion
.
destroy_all
Project
.
all
.
each
do
|
p
|
p
.
license
=
nil
p
.
save
end
end
desc
"creates default licenses"
task
:create
=>
:environment
do
create_license
(
"GPL"
,
"gpl"
,
"http://www.gnu.org/copyleft/gpl.html"
,
"v3.0"
,
Date
.
new
(
2009
,
6
,
29
),
"http://www.gnu.org/copyleft/gpl.html"
)
create_license
(
"LGPL"
,
"lgpl"
,
"http://www.gnu.org/licenses/lgpl.html"
,
"v3.0"
,
Date
.
new
(
2009
,
6
,
29
),
"http://www.gnu.org/licenses/lgpl.html"
)
create_license
(
"TAPR OHL"
,
"tapr-ohl"
,
"http://www.tapr.org/OHL"
,
"v1.0"
,
Date
.
new
(
2007
,
5
,
25
),
"http://www.tapr.org/TAPR_Open_Hardware_License_v1.0.txt"
)
create_license
(
"CERN OHL"
,
"cern-ohl"
,
nil
,
"v1.1"
,
Date
.
new
(
2011
,
7
,
8
),
nil
)
end
desc
"associates projects to the licenses they belong to"
do
[
"GPL"
,
"LGPL"
,
"TAPR OHL"
,
"CERN OHL"
].
each
do
|
license_name
|
license
=
License
.
find_by_name
(
license_name
)
license_version
=
license
.
license_versions
.
first
Project
.
with_custom_fields
(
:License
=>
license_name
).
each
do
|
p
|
p
.
license
=
license
.
version
p
.
save
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment