xolti 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/docs/getting_started.rst +166 -0
- data/docs/index.rst +11 -0
- data/docs/installation.rst +50 -0
- data/docs/intro.rst +20 -0
- data/lib/default_comment_tokens.rb +0 -1
- data/lib/file_finder.rb +1 -1
- data/lib/version.rb +5 -0
- data/lib/xolti.rb +28 -0
- data/readme.md +2 -0
- data/xolti.gemspec +3 -1
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2149450fe72b054a8f677791feaa457def62598e
|
4
|
+
data.tar.gz: 6c513ac14f888b04fb05a1c0672b292d5c4d4837
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec1776900de5c30d513f1f2d9dc2272a4fad94aaac9de69c9a3fffd0898787049539e86b555c4dbce32b22c5e637f83f23f92ccb798493d5a42516b8812dd5ba
|
7
|
+
data.tar.gz: 9fe6b19b8f78acd4931f844669052daeb8f0f439b40ffa7ed3b48b6f2b9da50e15e4dfc3183d68ffe2661c243be7cb6af8d6ea61d92b2f0bdb015380ec2a308e
|
@@ -0,0 +1,166 @@
|
|
1
|
+
Getting started with a simple example
|
2
|
+
=====================================
|
3
|
+
|
4
|
+
Let's suppose you have a project, for example in NodeJS, with files organized like this :
|
5
|
+
|
6
|
+
.. code-block:: text
|
7
|
+
|
8
|
+
|- myAwesomeProject
|
9
|
+
|- app.js
|
10
|
+
|- package.json
|
11
|
+
|- node_modules
|
12
|
+
|- ...
|
13
|
+
|
14
|
+
Now, how do you use Xolti to manage your license ?
|
15
|
+
|
16
|
+
Installation
|
17
|
+
------------
|
18
|
+
|
19
|
+
If not done already, this is the time to install Xolti. You can find detailed explanations in the
|
20
|
+
installation section of this documentation, but running this command is probably sufficient:
|
21
|
+
|
22
|
+
.. code-block:: bash
|
23
|
+
|
24
|
+
gem install xolti
|
25
|
+
|
26
|
+
Initiating the project
|
27
|
+
----------------------
|
28
|
+
|
29
|
+
Then it's time to create the xolti configuration file, named ``xolti.yml``. This file will contain
|
30
|
+
information for Xolti such as the name of your project and the license you have chosen.
|
31
|
+
|
32
|
+
You can do this by running this command:
|
33
|
+
|
34
|
+
.. code-block:: bash
|
35
|
+
|
36
|
+
xolti init
|
37
|
+
|
38
|
+
This will trigger a command line utility asking you some information, and will create a ``xolti.yml``
|
39
|
+
for your project based on what you answered.
|
40
|
+
|
41
|
+
.. code-block:: bash
|
42
|
+
|
43
|
+
remi ~/myAwesomeProject]$ xolti init
|
44
|
+
Initiating xolti project
|
45
|
+
name (myAwesomeProject):
|
46
|
+
author: Rémi Even
|
47
|
+
license (GPL3.0):
|
48
|
+
|
49
|
+
Values between parenthesis will be selected if you do not type anything.
|
50
|
+
|
51
|
+
Creating a LICENSE file
|
52
|
+
-----------------------
|
53
|
+
|
54
|
+
Before adding license headers to your source file, you probably want to generate a ``LICENSE`` file,
|
55
|
+
which will be in the root of your project, and will contain the complete text of the license you have
|
56
|
+
chosen. To do so, use the following command :
|
57
|
+
|
58
|
+
.. code-block:: bash
|
59
|
+
|
60
|
+
remi ~/myAwesomeProject]$ xolti generate-license
|
61
|
+
Created the LICENSE file (GPL3.0)
|
62
|
+
|
63
|
+
Telling Xolti which files to modify (or not)
|
64
|
+
--------------------------------------------
|
65
|
+
|
66
|
+
Similarly to git and the ``.gitignore`` file, you can create a ``.xoltignore`` file to indicate
|
67
|
+
xolti files to ignore. The syntax is the same; for this project, the content of the xoltignore
|
68
|
+
would be :
|
69
|
+
|
70
|
+
.. code-block:: text
|
71
|
+
|
72
|
+
node_modules
|
73
|
+
package.json
|
74
|
+
|
75
|
+
.. tip::
|
76
|
+
|
77
|
+
You can invert a rule by prefixing it with ``!``. You can create one ``.xoltignore``
|
78
|
+
in each directory of your project. Globing (ie use of the ``*`` wildcard) is supported.
|
79
|
+
|
80
|
+
.. note::
|
81
|
+
|
82
|
+
Like in a ``.gitignore`` file, rules are read line by line, from top to bottom; lower rules
|
83
|
+
override higher ones, and rules from a deeper folder override rules from higher folders.
|
84
|
+
|
85
|
+
Checking which files are missing headers
|
86
|
+
----------------------------------------
|
87
|
+
|
88
|
+
Now that xolti knows which files to handle, we can ask it which ones are missing headers.
|
89
|
+
We can either use the dedicated command:
|
90
|
+
|
91
|
+
.. code-block:: bash
|
92
|
+
|
93
|
+
[22:14 remi ~/myAwesomeProject]$ xolti list-missing
|
94
|
+
Files missing (proper) header:
|
95
|
+
app.js
|
96
|
+
|
97
|
+
... or use ``xolti status``, which will tell you the state of each of your files.
|
98
|
+
|
99
|
+
.. code-block:: bash
|
100
|
+
|
101
|
+
xolti status
|
102
|
+
-- ./app.js
|
103
|
+
No header found.
|
104
|
+
|
105
|
+
Adding the header to your files
|
106
|
+
-------------------------------
|
107
|
+
|
108
|
+
Looks like ``app.js`` is missing a header. Xolti can create and insert one for you, with the
|
109
|
+
``add`` command:
|
110
|
+
|
111
|
+
.. code-block:: bash
|
112
|
+
|
113
|
+
xolti add app.js
|
114
|
+
|
115
|
+
.. tip::
|
116
|
+
|
117
|
+
We could have also used ``.`` instead of specifying ``app.js``; xolti would have add a
|
118
|
+
header in each file (recursively) from the current folder.
|
119
|
+
|
120
|
+
.. note::
|
121
|
+
|
122
|
+
Xolti detects, based on its extension, that the ``app.js`` file contains Javascript.
|
123
|
+
This allows Xolti to know how to create a comment in this file (in this case,
|
124
|
+
with ``/*``, ``*`` and ``*/``).
|
125
|
+
|
126
|
+
Verifying the result
|
127
|
+
--------------------
|
128
|
+
|
129
|
+
Of course, you can verify that Xolti have actually added the header by simply opening the
|
130
|
+
file, but you can also use the ``check`` command:
|
131
|
+
|
132
|
+
.. code-block:: bash
|
133
|
+
|
134
|
+
remi ~/myAwesomeProject]$ xolti check app.js
|
135
|
+
Correct header.
|
136
|
+
|
137
|
+
That's it ! Your project is correctly licensed :).
|
138
|
+
|
139
|
+
Detecting incorrect headers
|
140
|
+
---------------------------
|
141
|
+
|
142
|
+
Now that we think of it, ``myAwesomeProject`` is not such a good name. ``myFantasticProject``
|
143
|
+
is way better ! To let xolti know of our change of mind, we can edit the ``xolti.yml`` file,
|
144
|
+
and replace the value of the key ``project_name`` by ``myFantasticProject``.
|
145
|
+
|
146
|
+
If we ``check`` again the ``app.js`` file, xolti warns us about its now incorrect header:
|
147
|
+
|
148
|
+
.. code-block:: bash
|
149
|
+
|
150
|
+
xolti check app.js
|
151
|
+
Line 5: expected "myFantasticProject" but got "myAwesomeProject".
|
152
|
+
Line 7: expected "myFantasticProject" but got "myAwesomeProject".
|
153
|
+
Line 12: expected "myFantasticProject" but got "myAwesomeProject".
|
154
|
+
Line 18: expected "myFantasticProject" but got "myAwesomeProject".
|
155
|
+
|
156
|
+
You can then correct this outdated header.
|
157
|
+
|
158
|
+
Deleting the header in a file
|
159
|
+
-----------------------------
|
160
|
+
|
161
|
+
What if you decide that you no longer needs a header in your ``app.js`` ? Simply use the
|
162
|
+
``delete`` command:
|
163
|
+
|
164
|
+
.. code-block:: bash
|
165
|
+
|
166
|
+
xolti delete app.js
|
data/docs/index.rst
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
Installation
|
2
|
+
============
|
3
|
+
|
4
|
+
Xolti being available on `RubyGems.org`_ makes it fairly easy to be installed :
|
5
|
+
|
6
|
+
.. code-block:: bash
|
7
|
+
|
8
|
+
gem install xolti
|
9
|
+
|
10
|
+
Once the installation completes, ``xolti`` is added to your ``$PATH``, so you can access it from everywhere.
|
11
|
+
|
12
|
+
Requirements
|
13
|
+
------------
|
14
|
+
|
15
|
+
In order to properly work, Xolti requires Ruby to be installed. It has been tested with Ruby >= 2.1, but probably works with slightly older versions too.
|
16
|
+
In addition, and as stated in its GemFile, Xolti requires Thor, a ruby gem used to easily create command line interfaces.
|
17
|
+
|
18
|
+
Building from sources
|
19
|
+
---------------------
|
20
|
+
|
21
|
+
You can also create the gem from the source files, using the following commands (assuming you are in the project root):
|
22
|
+
|
23
|
+
.. code-block:: bash
|
24
|
+
|
25
|
+
gem build xolti.gemspec
|
26
|
+
|
27
|
+
You can then install it with :
|
28
|
+
|
29
|
+
.. code-block:: bash
|
30
|
+
|
31
|
+
gem install xolti-[VERSION].gem
|
32
|
+
|
33
|
+
where [VERSION] must be replaced by the current version of Xolti.
|
34
|
+
|
35
|
+
Running the tests
|
36
|
+
~~~~~~~~~~~~~~~~~
|
37
|
+
|
38
|
+
Running the tests requires the gem ``test-unit``, and can be achieved with the command :
|
39
|
+
|
40
|
+
.. code-block:: bash
|
41
|
+
|
42
|
+
ruby test/ts_suite.rb
|
43
|
+
|
44
|
+
Alternatively, if you have installed ``rake`` in addition to ``test-unit``, you can use the command :
|
45
|
+
|
46
|
+
.. code-block:: bash
|
47
|
+
|
48
|
+
rake test
|
49
|
+
|
50
|
+
.. _`RubyGems.org`: https://rubygems.org/gems/xolti
|
data/docs/intro.rst
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Introduction
|
2
|
+
============
|
3
|
+
|
4
|
+
Xolti is a tool assisting you to manage license headers in source files, powered by Ruby.
|
5
|
+
|
6
|
+
Xolti is licensed under the terms of the GNU-GPL3, meaning it's free software.
|
7
|
+
|
8
|
+
|
9
|
+
You can find the source code in the `Github repository`_
|
10
|
+
|
11
|
+
`Xolti is still in developer preview.`
|
12
|
+
|
13
|
+
Purpose
|
14
|
+
-------
|
15
|
+
|
16
|
+
If you ever had to manage the license of a project, you probably know how much a burden this task can become, especially if you try to keep it accurate among numerous files!
|
17
|
+
|
18
|
+
Xolti is a piece of software aiming to assist the management of license-related information in a project. Its main functionality is to add and maintain license headers at the top of source files. Moreover, Xolti can also generate ``LICENSE`` files.
|
19
|
+
|
20
|
+
.. _`Github repository`: https://github.com/RemiEven/xolti
|
data/lib/file_finder.rb
CHANGED
@@ -25,7 +25,7 @@ end
|
|
25
25
|
module FileFinder
|
26
26
|
def FileFinder.explore_folder(folder=Dir.pwd, ignoreRules=[])
|
27
27
|
fileAcc = []
|
28
|
-
ignoredPaths = [".", "..", ".git", ".xoltignore", "xolti.yml", "
|
28
|
+
ignoredPaths = [".", "..", ".git", ".xoltignore", "xolti.yml", "LICENSE"]
|
29
29
|
ignoreRules += parse_xoltignore(folder)
|
30
30
|
|
31
31
|
Dir.glob("#{folder}/{*,.*}")
|
data/lib/version.rb
ADDED
data/lib/xolti.rb
CHANGED
@@ -24,6 +24,7 @@ require_relative "core"
|
|
24
24
|
require_relative "config"
|
25
25
|
require_relative "file_finder"
|
26
26
|
require_relative "resources"
|
27
|
+
require_relative "version"
|
27
28
|
|
28
29
|
Signal.trap("INT") do
|
29
30
|
puts "\nCancelling..."
|
@@ -117,6 +118,25 @@ class XoltiCLI < Thor
|
|
117
118
|
end
|
118
119
|
end
|
119
120
|
|
121
|
+
map ["--version", "-v"] => :__print_version
|
122
|
+
|
123
|
+
desc "--version, -v", "Print version of xolti"
|
124
|
+
def __print_version()
|
125
|
+
puts XoltiVersion.get
|
126
|
+
end
|
127
|
+
|
128
|
+
map ["--license", "-l"] => :__print_license
|
129
|
+
|
130
|
+
desc "--license, -l", "Print licensing information of xolti"
|
131
|
+
def __print_license()
|
132
|
+
puts "Xolti version #{XoltiVersion.get}, Copyright (C) 2016 Rémi Even"
|
133
|
+
puts "Xolti comes with ABSOLUTELY NO WARRANTY."
|
134
|
+
puts "This is free software, and you are welcome to redistribute it"
|
135
|
+
puts "under the terms of the GPLv3."
|
136
|
+
puts "The complete license can be found at \"https://www.gnu.org/licenses/gpl.txt\"."
|
137
|
+
puts "The source code of xolti can be found at \"https://github.com/RemiEven/xolti\"."
|
138
|
+
end
|
139
|
+
|
120
140
|
no_commands {
|
121
141
|
def ask_for_name(config)
|
122
142
|
default_name = Pathname.getwd.basename.to_s
|
@@ -131,6 +151,13 @@ class XoltiCLI < Thor
|
|
131
151
|
config["project_info"]["author"] = typed_author
|
132
152
|
end
|
133
153
|
|
154
|
+
def ask_for_license(config)
|
155
|
+
default_license = "GPL3.0"
|
156
|
+
print "license (#{default_license}): "
|
157
|
+
typed_license = STDIN.gets.chomp
|
158
|
+
config["license"] = (typed_license == "") ? default_license : typed_license
|
159
|
+
end
|
160
|
+
|
134
161
|
def load_config()
|
135
162
|
begin
|
136
163
|
return XoltiConfig.load_config
|
@@ -148,6 +175,7 @@ class XoltiCLI < Thor
|
|
148
175
|
config = {"project_info" => {}}
|
149
176
|
self.ask_for_name(config)
|
150
177
|
self.ask_for_author(config)
|
178
|
+
self.ask_for_license(config)
|
151
179
|
File.write("xolti.yml", config.to_yaml)
|
152
180
|
end
|
153
181
|
end
|
data/readme.md
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
> Tool assisting developers to manage license headers in source files, powered by Ruby.
|
4
4
|
|
5
5
|
[](http://travis-ci.org/RemiEven/xolti)
|
6
|
+
[](https://badge.fury.io/rb/xolti)
|
7
|
+
[](http://xolti.readthedocs.io/en/latest/?badge=latest)
|
6
8
|
[](http://www.gnu.org/licenses/gpl-3.0.en.html)
|
7
9
|
|
8
10
|
## Purpose
|
data/xolti.gemspec
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
require_relative "lib/version"
|
2
|
+
|
1
3
|
Gem::Specification.new do |spec|
|
2
4
|
spec.name = "xolti"
|
3
|
-
spec.version =
|
5
|
+
spec.version = XoltiVersion.get
|
4
6
|
spec.summary = "A gem to manage license headers"
|
5
7
|
spec.description = "A gem to manage license headers, providing a simple CLI."
|
6
8
|
spec.authors = ["Rémi Even"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xolti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rémi Even
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -42,6 +42,10 @@ files:
|
|
42
42
|
- Gemfile
|
43
43
|
- LICENSE
|
44
44
|
- Rakefile
|
45
|
+
- docs/getting_started.rst
|
46
|
+
- docs/index.rst
|
47
|
+
- docs/installation.rst
|
48
|
+
- docs/intro.rst
|
45
49
|
- exe/xolti
|
46
50
|
- lib/comment.rb
|
47
51
|
- lib/config.rb
|
@@ -54,6 +58,7 @@ files:
|
|
54
58
|
- lib/header_validator.rb
|
55
59
|
- lib/resources.rb
|
56
60
|
- lib/template_utils.rb
|
61
|
+
- lib/version.rb
|
57
62
|
- lib/xolti.rb
|
58
63
|
- readme.md
|
59
64
|
- resources/headers/GPL3.0
|
@@ -85,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
90
|
version: '0'
|
86
91
|
requirements: []
|
87
92
|
rubyforge_project:
|
88
|
-
rubygems_version: 2.
|
93
|
+
rubygems_version: 2.5.1
|
89
94
|
signing_key:
|
90
95
|
specification_version: 4
|
91
96
|
summary: A gem to manage license headers
|