castic 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/lib/castic.rb +43 -0
  3. data/lib/extends/parser.rb +12 -0
  4. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 802ec01397ff02f562d4f962018aa246549b6cbc
4
+ data.tar.gz: 61d64a07cc33dda23eb69d621cf3e2de404bb737
5
+ SHA512:
6
+ metadata.gz: 80b0e4a52ffd0b531e2f9368280b1e5d065002421fb80df3a3f5964220cb0e2be806b1453a621a955fd4631b9604462895fa6b97c90dae8306aec923877f6c14
7
+ data.tar.gz: 18089ba17418af4a5057a8027bc951baae417e134dff02ef59fcf5c975db33aa82c63af1e614bc4ee219e1e223ea4df032bc41dbccae245b77822611c5370ab3
@@ -0,0 +1,43 @@
1
+ require 'parser/ruby18'
2
+ require_relative 'extends/parser'
3
+
4
+ class Castic
5
+ def initialize(cask)
6
+ @file = cask
7
+ @source = IO.read cask
8
+ @parsed = Parser::Ruby18.parse @source
9
+ @tree = @parsed.to_tree
10
+ end
11
+
12
+ attr_reader :tree
13
+
14
+ def expected_name
15
+ @file.to_s
16
+ .split('/')
17
+ .last
18
+ .split('-')
19
+ .map(&:capitalize)
20
+ .join
21
+ .sub /\.rb$/, ''
22
+ end
23
+
24
+ def name
25
+ k = @tree.index [nil, :Cask]
26
+ @tree[k-1][1].to_s
27
+ end
28
+
29
+ def props(key = nil)
30
+ k = @tree.index [nil, :Cask]
31
+ body = @tree[k+1]
32
+ if key
33
+ body.select { |n|
34
+ n[1] == key.to_sym
35
+ }
36
+ else
37
+ body
38
+ end.map { |n|
39
+ n.last n.length - 1
40
+ }
41
+ end
42
+ end
43
+
@@ -0,0 +1,12 @@
1
+ class Parser::AST::Node
2
+ def to_tree
3
+ self.to_a.map { |n|
4
+ if n.is_a? Parser::AST::Node
5
+ n.to_tree
6
+ else
7
+ n
8
+ end
9
+ }
10
+ end
11
+ end
12
+
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: castic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Felix Saparelli
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Static parser for Homebrew Cask formulae
14
+ email: me@passcod.name
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/extends/parser.rb
20
+ - lib/castic.rb
21
+ homepage: https://github.com/passcod/castic
22
+ licenses: []
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.0.0
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Static parser for Homebrew Cask formulae
44
+ test_files: []