zapata 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -8
- data/README.md +23 -3
- data/lib/zapata/diver.rb +22 -15
- data/lib/zapata/primitive/arg.rb +1 -1
- data/lib/zapata/primitive/array.rb +1 -1
- data/lib/zapata/primitive/base.rb +2 -2
- data/lib/zapata/primitive/send.rb +2 -1
- data/lib/zapata/version.rb +1 -1
- data/spec/spec_helper.rb +7 -1
- data/spec/support/rails_test_app/Gemfile +1 -1
- data/spec/support/rails_test_app/Gemfile.lock +14 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a623cb9783f185bae4d4111b99219ce93a83539d
|
4
|
+
data.tar.gz: a0222512c8e1ca6c334641245a0bf82cab4adca5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08172f430be1bdad603cb4200e8e8443e459b174e2b4b2958d514c4bca876837994264cbf11329a8e2b595f482c24621f94da4833c212c1da2c569c748db5504
|
7
|
+
data.tar.gz: 4f943051fd300cffcef499f29bcfd7936186dde850b5e130132f5418c06275c4ba8dd9e333b24fbfc0c1d96242aa991126c79dd504905e8e4f72c51439bfd0da
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
[![Code Climate](https://codeclimate.com/github/Nedomas/zapata/badges/gpa.svg)](https://codeclimate.com/github/Nedomas/zapata)
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/zapata.svg)](http://badge.fury.io/rb/zapata)
|
3
|
+
[![Build Status](https://travis-ci.org/Nedomas/zapata.svg?branch=master)](https://travis-ci.org/Nedomas/zapata)
|
2
4
|
|
3
5
|
# Zapata
|
4
6
|
|
@@ -118,6 +120,11 @@ __To be more specific:__
|
|
118
120
|
For more things it can currently do check
|
119
121
|
https://github.com/Nedomas/zapata/tree/master/spec
|
120
122
|
|
123
|
+
## Requirements
|
124
|
+
|
125
|
+
- Ruby 2.0+
|
126
|
+
- Rails 3.0+
|
127
|
+
|
121
128
|
## Installation
|
122
129
|
|
123
130
|
It should be as easy as
|
@@ -131,16 +138,29 @@ or
|
|
131
138
|
gem 'zapata', groups: %w(development test)
|
132
139
|
```
|
133
140
|
|
141
|
+
## Usage
|
142
|
+
|
134
143
|
To use run
|
135
144
|
```sh
|
136
145
|
zapata generate app/models/model_name.rb
|
137
146
|
```
|
138
147
|
|
148
|
+
To ignore other files and analyze a single model you want to generate a spec for:
|
149
|
+
```sh
|
150
|
+
zapata generate app/models/model_name.rb --single
|
151
|
+
```
|
152
|
+
|
139
153
|
## Collaboration :heart:
|
140
154
|
|
141
|
-
|
142
|
-
|
143
|
-
|
155
|
+
It is encouraged by somehow managing to bring a cake to your house. I promise,
|
156
|
+
I will really try.
|
157
|
+
|
158
|
+
This is a great project to understand language architecture in general. A
|
159
|
+
project to let your free and expressionistic side shine through by leaving meta
|
160
|
+
hacks and rainbows everywhere.
|
161
|
+
|
162
|
+
Thank you to everyone who do. I strongly believe that this can make the
|
163
|
+
developer job less robotic and more creative.
|
144
164
|
|
145
165
|
To install, run:
|
146
166
|
```sh
|
data/lib/zapata/diver.rb
CHANGED
@@ -44,28 +44,33 @@ module Zapata
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def dive(code)
|
47
|
-
unless code
|
48
|
-
|
47
|
+
return Primitive::Nil.new unless code
|
48
|
+
return Primitive::Raw.new(:missing, :hard_type) if HARD_TYPES.include?(code.type)
|
49
|
+
|
50
|
+
if (klass = primitive_klass(code))
|
51
|
+
result = klass.new(code)
|
52
|
+
DB.create(result) if search_for_types.include?(code.type)
|
49
53
|
end
|
50
54
|
|
51
|
-
|
52
|
-
return Primitive::Raw.new(:missing, :hard_type) if HARD_TYPES.include?(current_type)
|
55
|
+
deeper_dives(code)
|
53
56
|
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
+
result || Primitive::Raw.new(:super, nil)
|
58
|
+
end
|
57
59
|
|
58
|
-
|
59
|
-
|
60
|
-
|
60
|
+
def primitive_klass(code)
|
61
|
+
primitive_type = find_primitive_type(code)
|
62
|
+
return unless primitive_type
|
61
63
|
|
62
|
-
|
63
|
-
|
64
|
-
end
|
64
|
+
"Zapata::Primitive::#{primitive_type}".constantize
|
65
|
+
end
|
65
66
|
|
66
|
-
|
67
|
+
def find_primitive_type(code)
|
68
|
+
klass_pair = PRIMITIVE_TYPES.detect do |_, types|
|
69
|
+
types.include?(code.type)
|
70
|
+
end
|
71
|
+
return unless klass_pair
|
67
72
|
|
68
|
-
|
73
|
+
klass_pair.first
|
69
74
|
end
|
70
75
|
|
71
76
|
def search_for_types
|
@@ -73,6 +78,8 @@ module Zapata
|
|
73
78
|
end
|
74
79
|
|
75
80
|
def deeper_dives(code)
|
81
|
+
return unless DIVE_TYPES.include?(code.type)
|
82
|
+
|
76
83
|
code.to_a.compact.each do |part|
|
77
84
|
dive(part)
|
78
85
|
end
|
data/lib/zapata/primitive/arg.rb
CHANGED
@@ -23,8 +23,8 @@ module Zapata
|
|
23
23
|
Diver.dive(node.body).to_raw
|
24
24
|
end
|
25
25
|
|
26
|
-
def return_with_super_as_missing(raw,
|
27
|
-
raw.type == :super ? Missing.new(name).to_raw : raw
|
26
|
+
def return_with_super_as_missing(raw, primitive)
|
27
|
+
raw.type == :super ? Missing.new(primitive.name).to_raw : raw
|
28
28
|
end
|
29
29
|
|
30
30
|
def return_with_missing_as_super(raw, name)
|
@@ -33,7 +33,8 @@ module Zapata
|
|
33
33
|
ConstSend.new(raw_receiver, node.name, node.args).to_raw
|
34
34
|
else
|
35
35
|
raw = Predictor::Value.new(node.name, self).choose.to_raw
|
36
|
-
|
36
|
+
missing_name = raw.type == :super ? Unparser.unparse(code) : node.name
|
37
|
+
Missing.new(missing_name).to_raw
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|
data/lib/zapata/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -101,7 +101,13 @@ def exec_generation(generate_for)
|
|
101
101
|
end
|
102
102
|
|
103
103
|
output = stdout.readlines
|
104
|
-
|
104
|
+
begin
|
105
|
+
generated_filename = output.last.match(/File\ (.+)\ was/)[1]
|
106
|
+
rescue
|
107
|
+
raise "Did not get the message that file was generated. Got this instead:
|
108
|
+
STDOUT: #{output}
|
109
|
+
STDERR: #{stderr.readlines}"
|
110
|
+
end
|
105
111
|
spec_path = "#{RAILS_TEST_APP_DIR}/#{generated_filename}"
|
106
112
|
|
107
113
|
clean(
|
@@ -30,7 +30,7 @@ end
|
|
30
30
|
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
31
31
|
gem 'spring', group: :development
|
32
32
|
|
33
|
-
gem 'zapata'
|
33
|
+
gem 'zapata'
|
34
34
|
|
35
35
|
# Use ActiveModel has_secure_password
|
36
36
|
# gem 'bcrypt', '~> 3.1.7'
|
@@ -1,20 +1,3 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ~/Developer/zapata
|
3
|
-
specs:
|
4
|
-
zapata (0.0.2)
|
5
|
-
andand (~> 1.3)
|
6
|
-
file-temp (~> 1.2)
|
7
|
-
memoist
|
8
|
-
parser (~> 2.1)
|
9
|
-
pry (~> 0.9)
|
10
|
-
pry-stack_explorer (~> 0.4)
|
11
|
-
rails (>= 3.0.0)
|
12
|
-
require_all (~> 1.3)
|
13
|
-
rspec
|
14
|
-
rspec-rails
|
15
|
-
slop (~> 3.4)
|
16
|
-
unparser (~> 0.1)
|
17
|
-
|
18
1
|
GEM
|
19
2
|
remote: https://rubygems.org/
|
20
3
|
specs:
|
@@ -188,6 +171,19 @@ GEM
|
|
188
171
|
equalizer (~> 0.0.9)
|
189
172
|
parser (~> 2.1)
|
190
173
|
procto (~> 0.0.2)
|
174
|
+
zapata (0.0.2)
|
175
|
+
andand (~> 1.3)
|
176
|
+
file-temp (~> 1.2)
|
177
|
+
memoist
|
178
|
+
parser (~> 2.1)
|
179
|
+
pry (~> 0.9)
|
180
|
+
pry-stack_explorer (~> 0.4)
|
181
|
+
rails (>= 3.0.0)
|
182
|
+
require_all (~> 1.3)
|
183
|
+
rspec
|
184
|
+
rspec-rails
|
185
|
+
slop (~> 3.4)
|
186
|
+
unparser (~> 0.1)
|
191
187
|
|
192
188
|
PLATFORMS
|
193
189
|
ruby
|
@@ -204,4 +200,4 @@ DEPENDENCIES
|
|
204
200
|
sqlite3
|
205
201
|
turbolinks
|
206
202
|
uglifier (>= 1.3.0)
|
207
|
-
zapata
|
203
|
+
zapata
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zapata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Domas Bitvinskas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|