thrifty 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,4 +39,12 @@ class Thrifty::Manager
39
39
  [thrift_file, built]
40
40
  end
41
41
  end
42
+
43
+ def include_path
44
+ @thrift_files.keys.map {|f| File.dirname(f)}.uniq
45
+ end
46
+
47
+ def require_path
48
+ @thrift_files.values.map(&:build_directory).uniq
49
+ end
42
50
  end
@@ -42,7 +42,7 @@ class Thrifty::ThriftFile
42
42
  orig_load_path = $:.dup
43
43
 
44
44
  begin
45
- $:[0..-1] = [build_directory, DUMMY_DIRECTORY]
45
+ $:[0..-1] = @manager.require_path + [DUMMY_DIRECTORY]
46
46
  log.info('Requiring', file: generated_file, idl: path, build_directory: build_directory)
47
47
  # Global require
48
48
  super(generated_file)
@@ -59,7 +59,8 @@ class Thrifty::ThriftFile
59
59
  e.message << ' (HINT: this probably means you forgot to precompile your Thrift file, or the relative path has changed between your build and deploy machines)'
60
60
  raise e
61
61
  end
62
- Rubysh('thrift', '--gen', 'rb', '-out', build_directory, path).check_call
62
+ includes = @manager.include_path.map {|x| ['-I', x]}.flatten
63
+ Rubysh('thrift', *includes, '--gen', 'rb', '-out', build_directory, path).check_call
63
64
  end
64
65
  end
65
66
 
@@ -1,3 +1,3 @@
1
1
  module Thrifty
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -0,0 +1,6 @@
1
+ namespace rb IncludeThriftyTest
2
+
3
+ include "user_service.thrift"
4
+
5
+ service IncludingService extends user_service.UserStorage {
6
+ }
@@ -14,8 +14,7 @@ class Thrifty::DynamicTest < Critic::Functional::Test
14
14
  it(description) do
15
15
  pid = fork do
16
16
  method.bind(self).call
17
- # This is very lurky, but a natural exit always seems to return 1
18
- exec('true')
17
+ exit!(true)
19
18
  end
20
19
  _, status = Process.waitpid2(pid)
21
20
  assert_equal(0, status.exitstatus)
@@ -24,7 +23,7 @@ class Thrifty::DynamicTest < Critic::Functional::Test
24
23
 
25
24
  describe 'without a build_root' do
26
25
  it_isolated 'can load the service' do
27
- Thrifty.register('_lib/thrift/service.thrift', relative_to: __FILE__)
26
+ Thrifty.register('_lib/thrift/user_service.thrift', relative_to: __FILE__)
28
27
  Thrifty.require('user_storage')
29
28
  ThriftyTest::UserStorage
30
29
  end
@@ -33,19 +32,27 @@ class Thrifty::DynamicTest < Critic::Functional::Test
33
32
  expected_root = File.expand_path('../_lib/thrift/build-thrifty', __FILE__)
34
33
  FileUtils.rm_rf(expected_root)
35
34
 
36
- Thrifty.register('_lib/thrift/service.thrift', relative_to: __FILE__)
35
+ Thrifty.register('_lib/thrift/user_service.thrift', relative_to: __FILE__)
37
36
  Thrifty.require('user_storage')
38
37
  ThriftyTest::UserStorage
39
38
 
40
39
  assert(File.exists?(expected_root))
41
40
  end
42
41
 
42
+ it_isolated 'can handle included thrift files' do
43
+ Thrifty.register('_lib/thrift/user_service.thrift', relative_to: __FILE__)
44
+ Thrifty.register('_lib/thrift-includes/including.thrift', relative_to: __FILE__)
45
+
46
+ Thrifty.require('including_service')
47
+ IncludeThriftyTest::IncludingService
48
+ end
49
+
43
50
  describe 'without relative_to' do
44
51
  it_isolated 'build_root defaults to Dir.tmpdir/thrifty' do
45
52
  expected_root = File.join(Dir.tmpdir, 'build-thrifty')
46
53
  FileUtils.rm_rf(expected_root)
47
54
 
48
- Thrifty.register(File.expand_path('../_lib/thrift/service.thrift', __FILE__))
55
+ Thrifty.register(File.expand_path('../_lib/thrift/user_service.thrift', __FILE__))
49
56
  Thrifty.require('user_storage')
50
57
  ThriftyTest::UserStorage
51
58
 
@@ -81,16 +88,16 @@ class Thrifty::DynamicTest < Critic::Functional::Test
81
88
  end
82
89
 
83
90
  it_isolated 'sets paths appropriately' do
84
- thrift_file = Thrifty.register('_lib/thrift/service.thrift',
91
+ thrift_file = Thrifty.register('_lib/thrift/user_service.thrift',
85
92
  relative_to: __FILE__,
86
93
  build_root: '_lib/thrift/thrifty')
87
- assert_equal(File.expand_path('../_lib/thrift/service.thrift', __FILE__),
94
+ assert_equal(File.expand_path('../_lib/thrift/user_service.thrift', __FILE__),
88
95
  thrift_file.path)
89
96
  assert_equal(File.expand_path('../_lib/thrift/thrifty', __FILE__), thrift_file.build_root)
90
97
  end
91
98
 
92
99
  it_isolated 'can load the service' do
93
- Thrifty.register('_lib/thrift/service.thrift',
100
+ Thrifty.register('_lib/thrift/user_service.thrift',
94
101
  relative_to: __FILE__,
95
102
  build_root: '_lib/thrift/thrifty')
96
103
  Thrifty.require('user_storage')
@@ -100,7 +107,7 @@ class Thrifty::DynamicTest < Critic::Functional::Test
100
107
  end
101
108
 
102
109
  it_isolated 'builds a given thrift file once' do
103
- Thrifty.register('_lib/thrift/service.thrift',
110
+ Thrifty.register('_lib/thrift/user_service.thrift',
104
111
  relative_to: __FILE__,
105
112
  build_root: '_lib/thrift/thrifty')
106
113
  results = Thrifty.compile_all
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thrifty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-30 00:00:00.000000000 Z
12
+ date: 2014-01-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -178,9 +178,10 @@ files:
178
178
  - lib/thrifty/version.rb
179
179
  - test/_lib.rb
180
180
  - test/functional/_lib.rb
181
+ - test/functional/_lib/thrift-includes/including.thrift
181
182
  - test/functional/_lib/thrift/.gitignore
182
183
  - test/functional/_lib/thrift/collision.thrift
183
- - test/functional/_lib/thrift/service.thrift
184
+ - test/functional/_lib/thrift/user_service.thrift
184
185
  - test/functional/thrifty.rb
185
186
  - test/integration/_lib.rb
186
187
  - test/meta/_lib.rb
@@ -200,7 +201,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
201
  version: '0'
201
202
  segments:
202
203
  - 0
203
- hash: 904017040795247836
204
+ hash: -2772158143117342826
204
205
  required_rubygems_version: !ruby/object:Gem::Requirement
205
206
  none: false
206
207
  requirements:
@@ -209,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
210
  version: '0'
210
211
  segments:
211
212
  - 0
212
- hash: 904017040795247836
213
+ hash: -2772158143117342826
213
214
  requirements: []
214
215
  rubyforge_project:
215
216
  rubygems_version: 1.8.23
@@ -220,9 +221,10 @@ summary: Begone manual compilation of Thrift definitions! Thrifty makes it easy
220
221
  test_files:
221
222
  - test/_lib.rb
222
223
  - test/functional/_lib.rb
224
+ - test/functional/_lib/thrift-includes/including.thrift
223
225
  - test/functional/_lib/thrift/.gitignore
224
226
  - test/functional/_lib/thrift/collision.thrift
225
- - test/functional/_lib/thrift/service.thrift
227
+ - test/functional/_lib/thrift/user_service.thrift
226
228
  - test/functional/thrifty.rb
227
229
  - test/integration/_lib.rb
228
230
  - test/meta/_lib.rb