qml 0.0.6 → 0.0.7

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
2
  SHA1:
3
- metadata.gz: 88ec8d13931b6285ad6961a33b0fb5dd0e30582b
4
- data.tar.gz: da96d985867d7ef034edcb60174cb4f64410783f
3
+ metadata.gz: 481b84b8d826ec6fd5a2f307d8edfe4f33ad3d8f
4
+ data.tar.gz: d4394d24401e9b9c4d244b240670d46ec063d28c
5
5
  SHA512:
6
- metadata.gz: 07886e4fd25d9f242bf9fd8e8eca6e4ed8a3bb7886fdac811b16d9ca0b699cc8269899fe2299e4fcb6d5ad51456e7749831cde2437f70cd4453bc971ee0cd488
7
- data.tar.gz: bde9ec75fa9b85c9e54d319f686a3d98a54ae6fd23af31f94e0bda49192903f818b04b0c47df34cc4b52621332dc4c54ce19a343563fdcdcec1e12a5a1b366e9
6
+ metadata.gz: 0b0219afde5a224d1018d1561571f5667da11aa4716f37720a3d85df8addbd52de3687924ff2c7fa3c508b7cb60e2f000928f600da3f8e983a72463436e99ed8
7
+ data.tar.gz: eec31c2af2ca479301637ea4b87cf6dd29e0968a80d2b2278e5dc6078a86e641e8d2f7e7ce68c4febbf24114a31a138b9470bef2a3469d2994c074138e51f606
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.2.0-rc1
3
4
  - 2.1.2
4
5
  - 2.0.0
5
6
  - 1.9.3
data/README.md CHANGED
@@ -456,7 +456,7 @@ end
456
456
  You can also use [em-synchrony](https://github.com/igrigorik/em-synchrony) to
457
457
  write callback-free asynchronous operation for ruby-qml.
458
458
 
459
- ```
459
+ ```ruby
460
460
  require 'qml'
461
461
  require 'eventmachine'
462
462
  require 'em-synchrony'
@@ -489,11 +489,42 @@ end
489
489
 
490
490
  ## Contributing
491
491
 
492
- Contributions are welcome. When you are contributing to ruby-qml:
492
+ ### Install dependencies
493
+
494
+ ```
495
+ $ bundle install
496
+ ```
497
+
498
+ ### Build native extension
499
+
500
+ Before running ruby-qml in development, the native extension of ruby-qml needs to have been built.
501
+ To build it, run the following commands:
502
+
503
+ ```
504
+ $ cd ext/qml
505
+ $ bundle exec ruby extconf.rb --with-qt-dir=/path/to/qt --with-libffi-dir=/path/to/libffi
506
+ $ make -j4
507
+ ```
508
+
509
+ ### Run tests
510
+
511
+ Tests for ruby-qml is written in RSpec. To run tests, do:
512
+
513
+ ```
514
+ $ bundle exec rspec
515
+ ```
516
+
517
+ ### Run examples
518
+
519
+ ```
520
+ $ bundle exec ruby examples/fizzbuzz/fizzbuzz.rb
521
+ ```
522
+
523
+ ### Send pull requests
493
524
 
494
525
  1. Fork it ( http://github.com/seanchas116/ruby-qml/fork )
495
526
  2. Create your feature branch (`git checkout -b my-new-feature`)
496
527
  3. Commit your changes (`git commit -am 'Add some feature'`)
497
- 4. Write some tests if possible
528
+ 4. Write some tests
498
529
  5. Push to the branch (`git push origin my-new-feature`)
499
530
  6. Create new Pull Request
data/changes.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.0.7 (2014-12-25)
2
+
3
+ * Support Ruby 2.2 (rc1) and Qt 5.4
4
+ * Add `Engine#add_import_path` and `Engine#import_paths` by @tokoro10g
5
+
1
6
  ## 0.0.6 (2014-08-19)
2
7
 
3
8
  * Fix problems when using Fiber with ruby-qml
@@ -21,7 +26,7 @@
21
26
  ## 0.0.2 (2014-07-21)
22
27
 
23
28
  * Improve list models
24
-
29
+
25
30
  * Add ArrayModel#replace
26
31
  * Add QueryModel for ORMs
27
32
  * Specify column names in ListModel#initialize
@@ -91,7 +91,10 @@ class Configurator
91
91
  end
92
92
  $CPPFLAGS += " -DHAVE_RUBY_THREAD_H" if have_header('ruby/thread.h')
93
93
 
94
- $CPPFLAGS += " -std=c++11 -Wall -Wextra -pipe"
94
+ have_func('rb_rational_num')
95
+ have_func('rb_rational_den')
96
+
97
+ $CPPFLAGS += " -std=c++11 -Wall -Wextra -pipe -Wno-reserved-user-defined-literal"
95
98
  if @debug_enabled
96
99
  $CPPFLAGS += " -O0 -ggdb3"
97
100
  else
@@ -1,6 +1,7 @@
1
1
  #include "engineextension.h"
2
2
  #include "imageprovider.h"
3
3
  #include <QQmlEngine>
4
+ #include <QStringList>
4
5
 
5
6
  namespace RubyQml {
6
7
 
@@ -19,6 +20,21 @@ void EngineExtension::addImageProvider(const QString &id, ImageProvider *provide
19
20
  mEngine->addImageProvider(id, provider);
20
21
  }
21
22
 
23
+ void EngineExtension::addImportPath(const QString &path)
24
+ {
25
+ mEngine->addImportPath(path);
26
+ }
27
+
28
+ QVariantList EngineExtension::importPaths() const
29
+ {
30
+ QStringList pathList = mEngine->importPathList();
31
+ QVariantList varList;
32
+ for(auto path : pathList){
33
+ varList << path;
34
+ }
35
+ return varList;
36
+ }
37
+
22
38
  void EngineExtension::collectGarbage()
23
39
  {
24
40
  mEngine->collectGarbage();
@@ -1,6 +1,7 @@
1
1
  #pragma once
2
2
 
3
3
  #include <QObject>
4
+ #include <QVariantList>
4
5
 
5
6
  class QQmlEngine;
6
7
  class QQmlContext;
@@ -19,6 +20,8 @@ public:
19
20
 
20
21
  public slots:
21
22
  void addImageProvider(const QString &id, RubyQml::ImageProvider *provider);
23
+ void addImportPath(const QString &path);
24
+ QVariantList importPaths() const;
22
25
  void collectGarbage();
23
26
 
24
27
  private:
@@ -7,6 +7,7 @@
7
7
  #include "accessobject.h"
8
8
  #include "listmodel.h"
9
9
  #include "ext_accesswrapperfactory.h"
10
+ #include "kernel.h"
10
11
  #include <ruby/intern.h>
11
12
  #define ONIG_ESCAPE_UCHAR_COLLISION
12
13
  #include <ruby/encoding.h>
@@ -14,6 +15,25 @@
14
15
  #include <QDateTime>
15
16
  #include <QRect>
16
17
  #include <QSet>
18
+ #include <QJSValue>
19
+
20
+ #ifndef HAVE_RB_RATIONAL_NUM
21
+
22
+ VALUE rb_rational_num(VALUE rat)
23
+ {
24
+ return RRATIONAL(rat)->num;
25
+ }
26
+
27
+ #endif
28
+
29
+ #ifndef HAVE_RB_RATIONAL_DEN
30
+
31
+ VALUE rb_rational_den(VALUE rat)
32
+ {
33
+ return RRATIONAL(rat)->den;
34
+ }
35
+
36
+ #endif
17
37
 
18
38
  namespace RubyQml {
19
39
 
@@ -71,6 +91,8 @@ struct ConverterHash
71
91
  add<QRect>();
72
92
  add<QRectF>();
73
93
 
94
+ add<QJSValue>();
95
+
74
96
  add<QObject *>();
75
97
  add<const QMetaObject *>();
76
98
 
@@ -148,7 +170,7 @@ template <> QDateTime Conversion<QDateTime>::from(RubyValue time)
148
170
  offset = time.send(RUBYQML_INTERN("gmt_offset")).to<int>();
149
171
  } else { // DateTime
150
172
  VALUE dayOffset = time.send(RUBYQML_INTERN("offset"));
151
- offset = RubyValue(RRATIONAL(dayOffset)->num).to<int>() * 24 * 60 * 60 / RubyValue(RRATIONAL(dayOffset)->den).to<int>();
173
+ offset = RubyValue(rb_rational_num(dayOffset)).to<int>() * 24 * 60 * 60 / RubyValue(rb_rational_den(dayOffset)).to<int>();
152
174
  time = time.send(RUBYQML_INTERN("to_time"));
153
175
  }
154
176
  timeval at = rb_time_timeval(time);
@@ -292,6 +314,16 @@ template <> RubyValue Conversion<const QMetaObject *>::to(const QMetaObject *met
292
314
  return Ext_MetaObject::fromMetaObject(metaobj);
293
315
  }
294
316
 
317
+ template <> QJSValue Conversion<QJSValue>::from(RubyValue x)
318
+ {
319
+ return Kernel::instance()->engine()->toScriptValue(x.to<QVariant>());
320
+ }
321
+
322
+ template <> RubyValue Conversion<QJSValue>::to(const QJSValue &jsValue)
323
+ {
324
+ return RubyValue::from(jsValue.toVariant());
325
+ }
326
+
295
327
  } // namespace detail
296
328
 
297
329
  Q_GLOBAL_STATIC(QSet<int>, enumeratorMetaTypes)
@@ -4,6 +4,7 @@
4
4
  #include <array>
5
5
 
6
6
  class QVariant;
7
+ class QJSValue;
7
8
 
8
9
  namespace RubyQml {
9
10
 
@@ -43,6 +43,21 @@ module QML
43
43
  @extension.add_image_provider(id, provider.qt_image_provider)
44
44
  provider
45
45
  end
46
+
47
+ # Adds a QML import path to the {Engine}.
48
+ # @param path [String]
49
+ # @see http://doc.qt.io/qt-5/qtqml-syntax-imports.html#qml-import-path
50
+ def add_import_path(path)
51
+ @extension.add_import_path(path)
52
+ end
53
+
54
+ # Gets an array of QML import paths.
55
+ # @see add_import_path
56
+ # @return [Array]
57
+ def import_paths()
58
+ @extension.import_paths()
59
+ end
60
+
46
61
  end
47
62
 
48
63
  # @return [Engine] the instance of {Engine}.
@@ -1,3 +1,3 @@
1
1
  module QML
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
@@ -0,0 +1,2 @@
1
+ module testmodule
2
+ Test 1.0 test.qml
@@ -0,0 +1,5 @@
1
+ import QtQuick 2.0
2
+
3
+ QtObject {
4
+ property string name: 'poyo'
5
+ }
@@ -11,7 +11,6 @@ describe QML::Dispatchable do
11
11
  foo = DispatchableFoo.new
12
12
  foo.later.value = 'hoge'
13
13
  QML.application.process_events # wait for event loop hook to be enabled
14
- expect(foo.value).to be_nil
15
14
  QML.application.process_events
16
15
  expect(foo.value).to eq 'hoge'
17
16
  end
@@ -64,7 +64,6 @@ describe QML do
64
64
  finished = true
65
65
  end
66
66
  QML.application.process_events # wait for event loop hook to be enabled
67
- expect(finished).to eq false
68
67
  QML.application.process_events
69
68
  expect(finished).to eq true
70
69
  end
@@ -6,6 +6,37 @@ describe QML::Engine do
6
6
  expect { QML::Engine.new }.to raise_error(QML::EngineError)
7
7
  end
8
8
  end
9
+
10
+ describe '#import_paths' do
11
+ it 'returns array' do
12
+ expect(QML.engine.import_paths()).to be_a(Array)
13
+ end
14
+ end
15
+
16
+ describe '#add_import_path' do
17
+ context 'with test module' do
18
+ let(:path) { (QML::ROOT_PATH + 'spec/assets').to_s }
19
+
20
+ it 'adds QML import path' do
21
+ QML.engine.add_import_path(path)
22
+ paths = QML.engine.import_paths()
23
+ expect(paths[0]).to eq path
24
+ end
25
+
26
+ let(:data) do
27
+ <<-EOS
28
+ import QtQuick 2.0
29
+ import testmodule 1.0
30
+ Test {}
31
+ EOS
32
+ end
33
+ let(:component) { QML::Component.new data: data }
34
+
35
+ it 'loads a module' do
36
+ expect(component.create.name).to eq 'poyo'
37
+ end
38
+ end
39
+ end
9
40
  end
10
41
 
11
42
  describe QML do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryohei Ikegami
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-19 00:00:00.000000000 Z
11
+ date: 2014-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -289,6 +289,8 @@ files:
289
289
  - lib/qml/wrappable.rb
290
290
  - qml.gemspec
291
291
  - spec/assets/test.png
292
+ - spec/assets/testmodule/qmldir
293
+ - spec/assets/testmodule/test.qml
292
294
  - spec/assets/testobj.qml
293
295
  - spec/qml/access_spec.rb
294
296
  - spec/qml/application_spec.rb
@@ -339,12 +341,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
339
341
  version: '0'
340
342
  requirements: []
341
343
  rubyforge_project:
342
- rubygems_version: 2.4.1
344
+ rubygems_version: 2.4.5
343
345
  signing_key:
344
346
  specification_version: 4
345
347
  summary: A QML / Qt Quick wrapper for Ruby
346
348
  test_files:
347
349
  - spec/assets/test.png
350
+ - spec/assets/testmodule/qmldir
351
+ - spec/assets/testmodule/test.qml
348
352
  - spec/assets/testobj.qml
349
353
  - spec/qml/access_spec.rb
350
354
  - spec/qml/application_spec.rb
@@ -375,4 +379,3 @@ test_files:
375
379
  - spec/shared/qml/data/list_model.rb
376
380
  - spec/shared/qml/reactive/object.rb
377
381
  - spec/spec_helper.rb
378
- has_rdoc: