packspec 0.2.1 → 0.3.0

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -38
  3. data/lib/cli.rb +33 -16
  4. data/packspec.gemspec +7 -6
  5. metadata +38 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fdccff439b67f0c82bb09ae8df1e7a4530581a88
4
- data.tar.gz: a9cf00c46fbc8b171057e0494cbc7b0f2643fbbc
3
+ metadata.gz: a2aba51e819e1eb052b6698546465e83be059f89
4
+ data.tar.gz: c5bd3d4c23ec85531d2b84272a2829988f523a7a
5
5
  SHA512:
6
- metadata.gz: ce25e03506b5d43b8cdd33fc60e368d2cfa73732855053b140befa3e341cffbe03a3ef844a61a9dc7a2e78dcd732ff46435e60a38cfa0efad0e1462f430b94a1
7
- data.tar.gz: f722b541d83493877688570b81d9ee77826b74ce3b466a1fa8dc2a5bbe21f445120abdd613cc8d344bc3b25f27b115e8399e5e79c77b8960a3d715815b2c82c3
6
+ metadata.gz: 3c9e3d8bb2e4cdff190f7f0141da48f44665d1709634d07381d70e038a48643511afebdc2c209488a32df58f4c271a29a7c4e233016a92406e8a070aba177e09
7
+ data.tar.gz: 7b373a1d8ebf3b866d7e9a0a13cfb7dd66fba0dfcc00debcabec834390a76c0170a35a7cbbddeffb33908589c5c811693d33c11bb2b955a4ba4e81ae2445cdc0
data/README.md CHANGED
@@ -1,41 +1,9 @@
1
- # Packspec::Rb
1
+ # packspec-rb
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/packspec/rb`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ [![Travis](https://travis-ci.org/packspec/packspec-rb.svg?branch=master)](https://travis-ci.org/packspec/packspec-rb)
4
+ [![Coveralls](https://coveralls.io/repos/github/packspec/packspec-rb/badge.svg?branch=master)](https://coveralls.io/github/packspec/packspec-rb?branch=master)
5
+ [![Gem Version](http://img.shields.io/gem/v/packspec.svg)](https://rubygems.org/gems/packspec)
4
6
 
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'packspec'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install packspec
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/packspec-rb.
36
-
37
-
38
- ## License
39
-
40
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
7
+ Cross-language testings made easy: unified YML-based package specification and Python/JavaScript/Ruby/PHP test runners. Read more about the project:
41
8
 
9
+ - https://github.com/packspec/packspec
data/lib/cli.rb CHANGED
@@ -70,11 +70,16 @@ def parse_spec(path)
70
70
  scope = {}
71
71
  scope['$import'] = BuiltinFunctions.new().public_method(:builtin_import)
72
72
  if documents.length > 1 && documents[1]['rb']
73
- eval(documents[1]['rb'])
74
- hook_scope = Functions.new()
75
- for name in hook_scope.public_methods
76
- # TODO: filter ruby builtin methods
77
- scope["$#{name}"] = hook_scope.public_method(name)
73
+ eval("module UserScope\n" + documents[1]['rb'] + "\nend")
74
+ for name in UserScope.constants
75
+ scope["$#{name}"] = UserScope.const_get(name)
76
+ end
77
+ default = Class.new
78
+ methods = Class.new.extend(UserScope)
79
+ for name in methods.public_methods
80
+ if !default.respond_to?(name)
81
+ scope["$#{name}"] = methods.public_method(name)
82
+ end
78
83
  end
79
84
  end
80
85
 
@@ -109,7 +114,7 @@ def parse_feature(feature)
109
114
  match = /^(?:\((.*)\))?(\w.*)$/.match(feature)
110
115
  skip, comment = match[1], match[2]
111
116
  if !!skip
112
- skip = !skip.split(':').include?('rb')
117
+ skip = !skip.split('|').include?('rb')
113
118
  end
114
119
  return {'assign' => nil, 'comment' => comment, 'skip' => skip}
115
120
  end
@@ -120,7 +125,7 @@ def parse_feature(feature)
120
125
  match = /^(?:\((.*)\))?(?:([^=]*)=)?([^=].*)?$/.match(left)
121
126
  skip, assign, property = match[1], match[2], match[3]
122
127
  if !!skip
123
- skip = !skip.split(':').include?('rb')
128
+ skip = !skip.split('|').include?('rb')
124
129
  end
125
130
  if !assign && !property
126
131
  raise Exception.new('Non-valid feature')
@@ -190,7 +195,7 @@ def parse_feature(feature)
190
195
  end
191
196
 
192
197
 
193
- def test_specs(specs)
198
+ def test_specs(specs, exit_first=false)
194
199
 
195
200
  # Message
196
201
  message = "\n # Ruby\n".bold
@@ -199,7 +204,7 @@ def test_specs(specs)
199
204
  # Test specs
200
205
  success = true
201
206
  for spec in specs
202
- spec_success = test_spec(spec)
207
+ spec_success = test_spec(spec, exit_first)
203
208
  success = success && spec_success
204
209
  end
205
210
 
@@ -208,7 +213,7 @@ def test_specs(specs)
208
213
  end
209
214
 
210
215
 
211
- def test_spec(spec)
216
+ def test_spec(spec, exit_first=false)
212
217
 
213
218
  # Message
214
219
  message = Emoji.find_by_alias('heavy_minus_sign').raw * 3 + "\n\n"
@@ -217,7 +222,7 @@ def test_spec(spec)
217
222
  # Test spec
218
223
  passed = 0
219
224
  for feature in spec['features']
220
- result = test_feature(feature, spec['scope'])
225
+ result = test_feature(feature, spec['scope'], exit_first)
221
226
  if result
222
227
  passed += 1
223
228
  end
@@ -239,7 +244,7 @@ def test_spec(spec)
239
244
  end
240
245
 
241
246
 
242
- def test_feature(feature, scope)
247
+ def test_feature(feature, scope, exit_first=false)
243
248
 
244
249
  # Comment
245
250
  if !!feature['comment']
@@ -257,7 +262,6 @@ def test_feature(feature, scope)
257
262
  end
258
263
 
259
264
  # Dereference
260
- # TODO: deepcopy feature
261
265
  if !!feature['call']
262
266
  feature['args'] = dereference_value(feature['args'], scope)
263
267
  feature['kwargs'] = dereference_value(feature['kwargs'], scope)
@@ -302,7 +306,6 @@ def test_feature(feature, scope)
302
306
  for name in names[0..-2]
303
307
  owner = get_property(owner, name)
304
308
  end
305
- # TODO: ensure constants are immutable
306
309
  set_property(owner, names[-1], result)
307
310
  end
308
311
 
@@ -330,6 +333,17 @@ def test_feature(feature, scope)
330
333
  message += "Assertion: #{result_text} != #{JSON.generate(feature['result'])}".red.bold
331
334
  end
332
335
  puts(message)
336
+ if exit_first
337
+ puts('---')
338
+ puts('Scope (current execution scope):')
339
+ puts("[#{scope.keys.join(', ')}]")
340
+ if exception
341
+ puts('---')
342
+ raise exception
343
+ else
344
+ exit(1)
345
+ end
346
+ end
333
347
  end
334
348
 
335
349
  return success
@@ -391,8 +405,10 @@ def get_property(owner, name)
391
405
  return owner[name]
392
406
  elsif owner.class == Array
393
407
  return owner[name.to_i]
408
+ elsif owner.is_a?(Class)
409
+ return owner.method(name)
394
410
  end
395
- return owner.method(name)
411
+ return owner.public_method(name)
396
412
  end
397
413
 
398
414
 
@@ -411,8 +427,9 @@ end
411
427
  # Main program
412
428
 
413
429
  path = ARGV[0] || nil
430
+ exit_first = ARGV.include?('-x') || ARGV.include?('--exit-first')
414
431
  specs = parse_specs(path)
415
- success = test_specs(specs)
432
+ success = test_specs(specs, exit_first)
416
433
  if !success
417
434
  exit(1)
418
435
  end
@@ -4,12 +4,12 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "packspec"
7
- spec.version = "0.2.1"
7
+ spec.version = "0.3.0"
8
8
  spec.authors = ["Evgeny Karev\n"]
9
9
  spec.email = ["eskarev@gmail.com"]
10
10
 
11
- spec.summary = %q{packspec}
12
- spec.description = %q{packspec}
11
+ spec.summary = "Cross-language testings made easy: unified YML-based package specification and Python/JavaScript/Ruby/PHP test runners"
12
+ spec.description = "Cross-language testings made easy: unified YML-based package specification and Python/JavaScript/Ruby/PHP test runners"
13
13
  spec.homepage = "https://github.com/packspec/packspec-rb"
14
14
  spec.license = "MIT"
15
15
 
@@ -21,10 +21,11 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = ["packspec-rb"]
22
22
  spec.require_paths = ["lib"]
23
23
 
24
+ spec.add_dependency "colorize", "~> 0.8"
25
+ spec.add_dependency "gemoji", "~> 3.0"
26
+
24
27
  spec.add_development_dependency "bundler", "~> 1.14"
25
28
  spec.add_development_dependency "rake", "~> 10.0"
26
29
  spec.add_development_dependency "rspec", "~> 3.0"
27
-
28
- spec.add_dependency "colorize", "~> 0.8"
29
- spec.add_dependency "gemoji", "~> 3.0"
30
+ spec.add_development_dependency "coveralls", "~> 0.8.13"
30
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: packspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - |
@@ -9,79 +9,94 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-08-28 00:00:00.000000000 Z
12
+ date: 2017-10-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: bundler
15
+ name: colorize
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '1.14'
21
- type: :development
20
+ version: '0.8'
21
+ type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '1.14'
27
+ version: '0.8'
28
28
  - !ruby/object:Gem::Dependency
29
- name: rake
29
+ name: gemoji
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '10.0'
35
- type: :development
34
+ version: '3.0'
35
+ type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '10.0'
41
+ version: '3.0'
42
42
  - !ruby/object:Gem::Dependency
43
- name: rspec
43
+ name: bundler
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '3.0'
48
+ version: '1.14'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '3.0'
55
+ version: '1.14'
56
56
  - !ruby/object:Gem::Dependency
57
- name: colorize
57
+ name: rake
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '0.8'
63
- type: :runtime
62
+ version: '10.0'
63
+ type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '0.8'
69
+ version: '10.0'
70
70
  - !ruby/object:Gem::Dependency
71
- name: gemoji
71
+ name: rspec
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
76
  version: '3.0'
77
- type: :runtime
77
+ type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
83
  version: '3.0'
84
- description: packspec
84
+ - !ruby/object:Gem::Dependency
85
+ name: coveralls
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: 0.8.13
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: 0.8.13
98
+ description: 'Cross-language testings made easy: unified YML-based package specification
99
+ and Python/JavaScript/Ruby/PHP test runners'
85
100
  email:
86
101
  - eskarev@gmail.com
87
102
  executables:
@@ -121,8 +136,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
136
  version: '0'
122
137
  requirements: []
123
138
  rubyforge_project:
124
- rubygems_version: 2.4.5
139
+ rubygems_version: 2.6.14
125
140
  signing_key:
126
141
  specification_version: 4
127
- summary: packspec
142
+ summary: 'Cross-language testings made easy: unified YML-based package specification
143
+ and Python/JavaScript/Ruby/PHP test runners'
128
144
  test_files: []