imagen 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: dd2abfa3ac968c14a9bbfabbd1dfbbb53512e874
4
- data.tar.gz: d1f28df309ae470eb2ce03e48d66b1c7f70966b8
2
+ SHA256:
3
+ metadata.gz: 443d80c6018106540e94b1bae76b48a43a7cdd13792fcf2fc31ae7204897af21
4
+ data.tar.gz: 773aa4bb9a71f86f362a4574bc4c3977a84c549d86141a62058d62a7154e3862
5
5
  SHA512:
6
- metadata.gz: fa11acb0c204fb8377a9e418a184755092f7e81065e84a42dbfeea9963b1df946aa55796f4913a959bb9d8f3c2fbab51b1d672696972b75aa459df61cd4b04ae
7
- data.tar.gz: 7f078ca350a97cfe3b52505749c401554df2d5a1ed56893eb6ee5192a6d48f7ef25d33534eaa45c19521e6467fde1beb80ba8ee08e1042e1569eca3cad1b96b8
6
+ metadata.gz: e68b22fb629ca9f41018a709f12189b5e977e93b70d149af9f674781dfd1807f1fe179c52cbe60324f8c45b9218b08202a896a839f78e3157dc3188ef2a67482
7
+ data.tar.gz: ff4b24564b458be93b825bf168b4f10eff07e23b57b6e0f28e3e30e26d698ba09d6ad01e17572638efc5692502cce009b71b4ec5bd805c7e781f49f5e2adf9ca
@@ -0,0 +1,38 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.2.0] 2018-08-19
10
+ ### Added
11
+ - This `CHANGELOG.md`
12
+ - Configurable ruby syntax version with `Imagen.parser_version`
13
+
14
+ ## [0.1.4] - 2018-08-03
15
+ ### Fixed
16
+ - Handled invalid UTF-8 errors from `parser`
17
+
18
+ ## [0.1.3] - 2018-07-10
19
+ ### Fixed
20
+ - Avoid broken release of `parser 2.5.1.1` in gemspec
21
+
22
+ ## [0.1.2] - 2018-05-18
23
+ ### Removed
24
+ - `Gemfile.lock` removed from repo
25
+
26
+ ## [0.1.1] - 2018-05-17
27
+ ### Added
28
+ - bundler gem release tasks required in project
29
+
30
+ ## [0.1.0] - 2018-05-10
31
+ ### Added
32
+ - First release of `imagen` 🎉
33
+
34
+ [Unreleased]: https://github.com/grodowski/imagen_rb/compare/v0.1.4...HEAD
35
+ [0.1.4]: https://github.com/grodowski/imagen_rb/compare/v0.1.3...v0.1.4
36
+ [0.1.3]: https://github.com/grodowski/imagen_rb/compare/v0.1.2...v0.1.3
37
+ [0.1.2]: https://github.com/grodowski/imagen_rb/compare/v0.1.1...v0.1.2
38
+ [0.1.1]: https://github.com/grodowski/imagen_rb/compare/v0.1.0...v0.1.1
@@ -32,5 +32,6 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency 'pry'
33
33
  spec.add_development_dependency 'simplecov'
34
34
  spec.add_development_dependency 'simplecov-lcov'
35
+ spec.add_development_dependency 'simplecov-html'
35
36
  end
36
37
  # rubocop:enable all
@@ -19,3 +19,6 @@ module Imagen
19
19
  RemoteBuilder.new(repo_url).build
20
20
  end
21
21
  end
22
+
23
+ require 'imagen/ast/parser'
24
+ require 'imagen/ast/builder'
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'parser'
4
+ require 'parser/builders/default'
5
+
3
6
  module Imagen
4
7
  module AST
5
8
  # An AST Builder for ruby parser.
@@ -1,28 +1,73 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'parser/current'
4
- require 'imagen/ast/builder'
5
-
6
3
  module Imagen
4
+ @parser_version = 'current' # default to runtime ruby syntax
5
+
6
+ class << self
7
+ attr_accessor :parser_version
8
+ end
9
+
10
+ AVAILABLE_RUBY_VERSIONS = %w[
11
+ ruby18
12
+ ruby19
13
+ ruby20
14
+ ruby21
15
+ ruby22
16
+ ruby23
17
+ ruby24
18
+ ruby25
19
+ ruby26
20
+ current
21
+ ].freeze
22
+
7
23
  module AST
8
- module Parser
24
+ class Parser
9
25
  def self.parse_file(filename)
10
- parse(File.read(filename), filename)
26
+ new.parse_file(filename)
11
27
  end
12
28
 
13
29
  def self.parse(input, file = '(string)')
30
+ new.parse(input, file)
31
+ end
32
+
33
+ # @param parser_version [String] ruby syntax version
34
+ def initialize(parser_version = Imagen.parser_version)
35
+ validate_version(parser_version)
36
+
37
+ require "parser/#{parser_version}"
38
+
39
+ required_const = if parser_version == 'current'
40
+ 'CurrentRuby'
41
+ else
42
+ parser_version.capitalize
43
+ end
44
+ @parser_klass = ::Parser.const_get(required_const)
45
+ end
46
+
47
+ def parse_file(filename)
48
+ parse(File.read(filename), filename)
49
+ end
50
+
51
+ def parse(input, file = '(string)')
14
52
  buffer = ::Parser::Source::Buffer.new(file)
15
53
  buffer.source = input
16
- default_parser.parse(buffer)
54
+ parser.parse(buffer)
17
55
  end
18
56
 
19
- def self.default_parser
20
- ::Parser::CurrentRuby.new(AST::Builder.new).tap do |parser|
57
+ def parser
58
+ @parser_klass.new(AST::Builder.new).tap do |parser|
21
59
  diagnostics = parser.diagnostics
22
60
  diagnostics.all_errors_are_fatal = true
23
61
  diagnostics.ignore_warnings = true
24
62
  end
25
63
  end
64
+
65
+ private
66
+
67
+ def validate_version(parser_version)
68
+ return if AVAILABLE_RUBY_VERSIONS.include?(parser_version)
69
+ raise ArgumentError, "#{parser_version} is not supported by imagen"
70
+ end
26
71
  end
27
72
  end
28
73
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'parser/current'
4
3
  require 'imagen/ast/parser'
5
4
  require 'imagen/ast/builder'
6
5
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Imagen
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imagen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Grodowski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-03 00:00:00.000000000 Z
11
+ date: 2018-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -128,6 +128,20 @@ dependencies:
128
128
  - - ">="
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: simplecov-html
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
131
145
  description:
132
146
  email:
133
147
  - jgrodowski@gmail.com
@@ -140,6 +154,7 @@ files:
140
154
  - ".rspec"
141
155
  - ".rubocop.yml"
142
156
  - ".travis.yml"
157
+ - CHANGELOG.md
143
158
  - Dockerfile
144
159
  - Gemfile
145
160
  - LICENSE.txt
@@ -177,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
192
  version: '0'
178
193
  requirements: []
179
194
  rubyforge_project:
180
- rubygems_version: 2.6.14.1
195
+ rubygems_version: 2.7.6
181
196
  signing_key:
182
197
  specification_version: 4
183
198
  summary: Codebase as structure of locatable classes and methods based on the Ruby