code_formatter 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0ac161ad1e1b7c26a4c31de6b15c40d7d6dfcde06ab76af659bbcd1b779f898b
4
+ data.tar.gz: bb29ac7bc77dc82f4da09e4f762c189cf7abcd826695f96ae0d3f3cbdb0aea66
5
+ SHA512:
6
+ metadata.gz: c9a322b2f008df623e44f3c7f7d283b581ab2b430926368adc32dbbc57ce428d1463915ccc2915db5934ab4d313cfb7d4029e8334d1f159bc88ec55d6ea09c21
7
+ data.tar.gz: 138fc10efe860886925aff11484e082211011efdf89bb0271a20bfa1279a0141eff16455fc65860ca516776897b254edc96908b5634ad7d94d9ffe5c25ba6a2a
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path('../../lib/code_formatter', __FILE__)
4
+ CodeFormatter::CLI.start(ARGV)
@@ -0,0 +1,2 @@
1
+ require_relative 'src/cli'
2
+ require_relative 'src/initializer'
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
@@ -0,0 +1,6 @@
1
+ CodeFormatter::Configuration.new do |c|
2
+ c.included_files = ['path/to/included/file.ext']
3
+ c.excluded_files = ['path/to/excluded/file.ext']
4
+ c.included_dirs = ['path/to/included/dir']
5
+ c.excluded_dirs = ['path/to/excluded/dir']
6
+ 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: []