editorconfig 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.md +20 -0
- data/README.md +107 -0
- data/lib/editor_config/version.rb +1 -1
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9eba3573ace023282386f50a78895b2b637da4b
|
4
|
+
data.tar.gz: 662371a10f2bc6733a13687d19fd6694e9e52c3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93dbc0d4d3f8c583769d7f8d8bc411c41ed8f3ab6a9d9ab81a8ae647d9e75601caabec251c771eeb7a1f3cc328d9d990ca9d0bc494eb3a83af0e2a04f3cb9228
|
7
|
+
data.tar.gz: b49e1c35dc26ea071534e2d02403a003a0251515f9a79fc132fb7d72a543f7ad848109c0626ee163ce8b94217572e85ab064bbbc972d9ea4318d736d037ce830
|
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2015 GitHub, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
# EditorConfig Ruby Core
|
2
|
+
|
3
|
+
EditorConfig Ruby Core provides the same functionality as the [EditorConfig C Core](https://github.com/editorconfig/editorconfig-core-c) and [EditorConfig Python Core](https://github.com/editorconfig/editorconfig-core-py) libraries.
|
4
|
+
|
5
|
+
## EditorConfig Project
|
6
|
+
|
7
|
+
EditorConfig makes it easy to maintain the correct coding style when switching between different text editors and between different projects. The EditorConfig project maintains a file format and plugins for various text editors which allow this file format to be read and used by those editors. For information on the file format and supported text editors, see the [EditorConfig website](http://editorconfig.org>).
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
With RubyGems:
|
12
|
+
|
13
|
+
``` sh
|
14
|
+
$ gem install editorconfig
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
Loading library module.
|
20
|
+
|
21
|
+
``` ruby
|
22
|
+
require 'editor_config'
|
23
|
+
EditorConfig.parse(File.read(".editorconfig"))
|
24
|
+
```
|
25
|
+
|
26
|
+
A command line binary is also provided.
|
27
|
+
|
28
|
+
```
|
29
|
+
$ editorconfig main.c
|
30
|
+
charset=utf-8
|
31
|
+
insert_final_newline=true
|
32
|
+
end_of_line=lf
|
33
|
+
tab_width=8
|
34
|
+
```
|
35
|
+
|
36
|
+
### Load
|
37
|
+
|
38
|
+
**File System**
|
39
|
+
|
40
|
+
An flattened config can be loaded from the file system with:
|
41
|
+
|
42
|
+
``` ruby
|
43
|
+
filename = "~/Project/foo/lib/foo.rb"
|
44
|
+
config = EditorConfig.load_file(filename)
|
45
|
+
|
46
|
+
# config: hash of properties and values
|
47
|
+
{
|
48
|
+
"charset" => "utf-8",
|
49
|
+
"indent_style" => "space",
|
50
|
+
"end_of_line" => "lf",
|
51
|
+
"insert_final_newline" => "true"
|
52
|
+
}
|
53
|
+
```
|
54
|
+
|
55
|
+
This API walks up the directory hierarchy gathering all `.editorconfig` files until it reaches a config that defines `root = true`.
|
56
|
+
|
57
|
+
**Custom Loader**
|
58
|
+
|
59
|
+
A custom loader can be provided to read files from another source rather than the file system.
|
60
|
+
|
61
|
+
For an example, you might load files directly from a git repository.
|
62
|
+
|
63
|
+
``` ruby
|
64
|
+
tree_sha, filename = "348b1ea52f897f313d62c56c2ba785a41f654861", "lib/foo.rb"
|
65
|
+
|
66
|
+
config = EditorConfig.load(filename) do |config_path|
|
67
|
+
if blob_sha = `git ls-tree #{tree_sha} #{config_path}`.split(" ")[2]
|
68
|
+
`git cat-file blob #{blob_sha}`
|
69
|
+
end
|
70
|
+
end
|
71
|
+
```
|
72
|
+
|
73
|
+
### Parse
|
74
|
+
|
75
|
+
A low-level API for parsing an individual `.editorconfig` file.
|
76
|
+
|
77
|
+
A `[config, root]` tuple is returned. The `root` bit is set if a top-level `root = true` is seen. The `config` value is a two dimensional hash mapping section names to property names and values.
|
78
|
+
|
79
|
+
``` ruby
|
80
|
+
data = File.read(".editorconfig")
|
81
|
+
config, root = EditorConfig.parse(data)
|
82
|
+
|
83
|
+
# root: if top-most root = true flag is set
|
84
|
+
true
|
85
|
+
|
86
|
+
# config: hash of sections and properties
|
87
|
+
{
|
88
|
+
"*" => {
|
89
|
+
"end_of_line" => "lf",
|
90
|
+
"insert_final_newline" => "true"
|
91
|
+
},
|
92
|
+
"*.{js,py}" => {
|
93
|
+
"charset" => "utf-8"
|
94
|
+
}
|
95
|
+
}
|
96
|
+
```
|
97
|
+
|
98
|
+
|
99
|
+
## Testing
|
100
|
+
|
101
|
+
[Cmake](http://www.cmake.org) is required to run the test suite. On OSX, just `brew install cmake`.
|
102
|
+
|
103
|
+
Then run the tests with:
|
104
|
+
|
105
|
+
``` sh
|
106
|
+
$ rake test
|
107
|
+
```
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: editorconfig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '5.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '5.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
description:
|
@@ -47,6 +47,8 @@ files:
|
|
47
47
|
- lib/editor_config.rb
|
48
48
|
- lib/editor_config/version.rb
|
49
49
|
- lib/editorconfig.rb
|
50
|
+
- README.md
|
51
|
+
- LICENSE.md
|
50
52
|
homepage: https://github.com/editorconfig/editorconfig-core-ruby
|
51
53
|
licenses:
|
52
54
|
- MIT
|
@@ -57,17 +59,17 @@ require_paths:
|
|
57
59
|
- lib
|
58
60
|
required_ruby_version: !ruby/object:Gem::Requirement
|
59
61
|
requirements:
|
60
|
-
- -
|
62
|
+
- - '>='
|
61
63
|
- !ruby/object:Gem::Version
|
62
64
|
version: '0'
|
63
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
66
|
requirements:
|
65
|
-
- -
|
67
|
+
- - '>='
|
66
68
|
- !ruby/object:Gem::Version
|
67
69
|
version: '0'
|
68
70
|
requirements: []
|
69
71
|
rubyforge_project:
|
70
|
-
rubygems_version: 2.
|
72
|
+
rubygems_version: 2.0.14
|
71
73
|
signing_key:
|
72
74
|
specification_version: 4
|
73
75
|
summary: EditorConfig core library written in Ruby
|