code-formatter 0.0.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 +7 -0
- data/bin/code_formatter +4 -0
- data/lib/code_formatter.rb +2 -0
- data/lib/src/cli.rb +17 -0
- data/lib/src/configuration.rb +42 -0
- data/lib/src/initializer.rb +21 -0
- data/lib/src/resources/sample_config.config +6 -0
- metadata +121 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d073f21ef467d1c15daf8df14c8101d1f1f86fc10a5d48b34d8c6e8cb1083f4e
|
4
|
+
data.tar.gz: b173a0c4824441c58c6638ce4cceab78d099c0f906a29ef34d00b0c72d3eaf7d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 014f52f8bca01e78a28a04989166bc618010d1cf36cccd4611802848c312fa7629a392b0d249c05c1a5d3d0fbbdff850ee123f970fa67ce465ee90d33e49200f
|
7
|
+
data.tar.gz: 6992e1abac564527d8d0c8133bc7c304d849e4363dd04b5412cf16f5409e16a56d4fcf95d6cf9535de99a33d6800779627619fbacaf24542951b093b4f02f203
|
data/bin/code_formatter
ADDED
data/lib/src/cli.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative 'initializer'
|
2
|
+
require 'thor'
|
3
|
+
|
4
|
+
module CodeFormatter
|
5
|
+
class CLI < Thor
|
6
|
+
desc 'init', 'create sample config'
|
7
|
+
def init
|
8
|
+
Initializer.init
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'format', 'description goes here'
|
12
|
+
option :config, default: Initializer.initialized_config, aliases: '-c', type: :string, desc: 'configuration file'
|
13
|
+
def format
|
14
|
+
puts 'Run Forrest! Ruuun!'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module CodeFormatter
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :included_files
|
4
|
+
attr_accessor :excluded_files
|
5
|
+
attr_accessor :included_dirs
|
6
|
+
attr_accessor :excluded_dirs
|
7
|
+
|
8
|
+
attr_reader :source_file
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
self.included_files = []
|
12
|
+
self.excluded_files = []
|
13
|
+
self.included_dirs = []
|
14
|
+
self.excluded_dirs = []
|
15
|
+
|
16
|
+
yield self if block_given?
|
17
|
+
end
|
18
|
+
|
19
|
+
# @param [String] file
|
20
|
+
# @return [Configuration]
|
21
|
+
def self.load_from(file)
|
22
|
+
return unless file || File.file?(file)
|
23
|
+
|
24
|
+
begin
|
25
|
+
config = eval(File.read(file), binding, 'config loading problem')
|
26
|
+
config.source_file = file
|
27
|
+
return config if config.is_a? Config
|
28
|
+
|
29
|
+
warn "[#{file}] isn't a CodeFormatter::Configuration, but #{config.class}."
|
30
|
+
rescue SyntaxError, StandardError => e
|
31
|
+
warn "Invalid configuration in [#{file}]: #{e}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def source_file=(file)
|
38
|
+
return unless file || File.file?(file)
|
39
|
+
@source_file = file
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module CodeFormatter
|
2
|
+
SAMPLE_CONFIG_DIR = './'.freeze
|
3
|
+
SAMPLE_CONFIG_FILE = 'code_formatter.config'.freeze
|
4
|
+
|
5
|
+
class Initializer
|
6
|
+
def self.init
|
7
|
+
config = File.read(File.expand_path('../resources/sample_config.config', __FILE__))
|
8
|
+
if File.file? SAMPLE_CONFIG_FILE
|
9
|
+
warn %(ERROR: Initialization failed. There is already exists some #{SAMPLE_CONFIG_FILE})
|
10
|
+
else
|
11
|
+
Dir.mkdir(SAMPLE_CONFIG_DIR) unless Dir.exist?(SAMPLE_CONFIG_DIR)
|
12
|
+
File.write(File.join(SAMPLE_CONFIG_DIR, SAMPLE_CONFIG_FILE), config)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.initialized_config
|
17
|
+
return SAMPLE_CONFIG_FILE if File.exist?(SAMPLE_CONFIG_FILE)
|
18
|
+
File.join(SAMPLE_CONFIG_DIR, SAMPLE_CONFIG_FILE)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: code-formatter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- sroik
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: test-unit
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: swift code formatter
|
84
|
+
email:
|
85
|
+
- vasili.kazhanouski@gmail.com
|
86
|
+
executables:
|
87
|
+
- code_formatter
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- bin/code_formatter
|
92
|
+
- lib/code_formatter.rb
|
93
|
+
- lib/src/cli.rb
|
94
|
+
- lib/src/configuration.rb
|
95
|
+
- lib/src/initializer.rb
|
96
|
+
- lib/src/resources/sample_config.config
|
97
|
+
homepage: https://github.com/app-craft/code-formatter
|
98
|
+
licenses:
|
99
|
+
- MIT
|
100
|
+
metadata: {}
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 2.7.3
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: src
|
121
|
+
test_files: []
|