ashikawa-core 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/.gitignore +11 -9
  2. data/.rspec +4 -0
  3. data/.travis.yml +8 -3
  4. data/CONTRIBUTING.md +5 -5
  5. data/Gemfile +5 -1
  6. data/Gemfile.devtools +65 -0
  7. data/Guardfile +1 -11
  8. data/README.md +14 -8
  9. data/Rakefile +5 -103
  10. data/ashikawa-core.gemspec +3 -29
  11. data/config/flay.yml +3 -0
  12. data/config/flog.yml +2 -0
  13. data/config/mutant.yml +3 -0
  14. data/config/roodi.yml +18 -0
  15. data/config/site.reek +95 -0
  16. data/config/yardstick.yml +2 -0
  17. data/lib/ashikawa-core/collection.rb +138 -178
  18. data/lib/ashikawa-core/connection.rb +74 -26
  19. data/lib/ashikawa-core/cursor.rb +30 -9
  20. data/lib/ashikawa-core/database.rb +23 -19
  21. data/lib/ashikawa-core/document.rb +33 -8
  22. data/lib/ashikawa-core/exceptions/collection_not_found.rb +15 -0
  23. data/lib/ashikawa-core/exceptions/document_not_found.rb +4 -0
  24. data/lib/ashikawa-core/exceptions/index_not_found.rb +15 -0
  25. data/lib/ashikawa-core/exceptions/no_collection_provided.rb +4 -0
  26. data/lib/ashikawa-core/exceptions/unknown_path.rb +15 -0
  27. data/lib/ashikawa-core/figure.rb +73 -0
  28. data/lib/ashikawa-core/index.rb +25 -7
  29. data/lib/ashikawa-core/query.rb +68 -55
  30. data/lib/ashikawa-core/status.rb +77 -0
  31. data/lib/ashikawa-core/version.rb +1 -1
  32. data/spec/acceptance/basic_spec.rb +14 -18
  33. data/spec/acceptance/index_spec.rb +4 -2
  34. data/spec/acceptance/query_spec.rb +18 -19
  35. data/spec/acceptance_auth/auth_spec.rb +2 -2
  36. data/spec/setup/arangodb.sh +34 -39
  37. data/spec/spec_helper.rb +27 -0
  38. data/spec/unit/collection_spec.rb +25 -73
  39. data/spec/unit/connection_spec.rb +46 -15
  40. data/spec/unit/cursor_spec.rb +3 -3
  41. data/spec/unit/database_spec.rb +8 -7
  42. data/spec/unit/document_spec.rb +2 -2
  43. data/spec/unit/exception_spec.rb +21 -0
  44. data/spec/unit/figure_spec.rb +28 -0
  45. data/spec/unit/index_spec.rb +1 -1
  46. data/spec/unit/query_spec.rb +25 -25
  47. data/spec/unit/spec_helper.rb +6 -4
  48. data/spec/unit/status_spec.rb +51 -0
  49. data/tasks/adjustments.rake +46 -0
  50. metadata +31 -203
data/.gitignore CHANGED
@@ -1,10 +1,12 @@
1
1
  .DS_Store
2
- .yardoc
3
- doc
4
- *.gem
5
- .bundle
6
- Gemfile.lock
7
- pkg/*
8
- report/*
9
- coverage
10
- .rbx
2
+ /.yardoc
3
+ /doc
4
+ /*.gem
5
+ /.bundle
6
+ /Gemfile.lock
7
+ /pkg/*
8
+ /report/*
9
+ /measurements/*
10
+ /coverage
11
+ /.rbx
12
+ /tmp
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --color
2
+ --format progress
3
+ --profile
4
+ --order random
data/.travis.yml CHANGED
@@ -2,14 +2,19 @@ language: ruby
2
2
  before_script:
3
3
  - ./spec/setup/arangodb.sh
4
4
  rvm:
5
+ - 1.8.7
5
6
  - 1.9.2
6
7
  - 1.9.3
7
- - rbx-19mode
8
+ - 2.0.0
9
+ - jruby-18mode
8
10
  - jruby-19mode
9
- - ruby-head
10
11
  - jruby-head
12
+ - rbx-18mode
13
+ - rbx-19mode
14
+ - ree
15
+ - ruby-head
11
16
  matrix:
12
17
  allow_failures:
13
18
  - rvm: ruby-head
14
19
  - rvm: jruby-head
15
- script: "rake ci"
20
+ script: "bundle exec rake ci"
data/CONTRIBUTING.md CHANGED
@@ -7,7 +7,7 @@ When you want to write code for the project, please follow these guidelines:
7
7
  3. Write an acceptance test: Describe what you want to do (our integration tests touch the database)
8
8
  4. Implement it: Write a unit test, check that it fails, make the test pass – repeat (our unit tests don't touch the database)
9
9
  5. Write documentation for it.
10
- 6. Check with `rake` that everything is fine and send the pull request to the `development` branch :)
10
+ 6. Check with `bundle exec rake` that everything is fine and send the pull request to the `development` branch :)
11
11
 
12
12
  ## How to get started developing
13
13
 
@@ -17,7 +17,7 @@ Getting started is easy, just follow these steps.
17
17
 
18
18
  * Clone the project.
19
19
  * `cd` into the folder and run `bundle`
20
- * `rake` and see all tests passing (you need to have ArangoDB installed for that)
20
+ * `bundle exec rake` and see all tests passing (you need to have ArangoDB installed for that)
21
21
  * Happy coding!
22
22
 
23
23
  ### Detailed description
@@ -28,13 +28,13 @@ We encourage you to use [rvm](https://rvm.io/). If you do so, a gemset for the p
28
28
 
29
29
  Change into the project directory. Run `bundle` to get all dependencies (do a `gem install bundler` before if you don't have bundler installed).
30
30
 
31
- Now you can run `rake` to see all tests passing (hopefully). Happy coding!
31
+ Now you can run `bundle exec rake` to see all tests passing (hopefully). Happy coding!
32
32
 
33
- You can also start up yard for documentation: `rake yard:server`
33
+ You can also start up yard for documentation: `bundle exec rake yard:server`
34
34
 
35
35
  ### Guard
36
36
 
37
- Guard is a tool for comfortable development. If you want to use it for development, you have to first start an instance of ArangoDB and then start guard with `guard`. This will:
37
+ Guard is a tool for comfortable development. If you want to use it for development, you have to first start an instance of ArangoDB and then start guard with `bundle exec guard`. This will:
38
38
 
39
39
  * Run a documentation server on `http://localhost:8808`
40
40
  * Run `bundle` whenever you change the dependencies
data/Gemfile CHANGED
@@ -1,4 +1,8 @@
1
- source "http://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in ashikawa-core.gemspec
4
4
  gemspec
5
+
6
+ gem 'devtools', :git => 'https://github.com/datamapper/devtools.git'
7
+
8
+ eval File.read('Gemfile.devtools')
data/Gemfile.devtools ADDED
@@ -0,0 +1,65 @@
1
+ # encoding: utf-8
2
+
3
+ group :development do
4
+ gem 'rake', '~> 10.0.3'
5
+ gem 'rspec', '~> 2.12.0'
6
+ gem 'yard', '~> 0.8.4.1'
7
+ end
8
+
9
+ group :yard do
10
+ gem 'redcarpet', '~> 2.2.2', :platforms => [ :mri, :rbx ]
11
+ end
12
+
13
+ group :guard do
14
+ gem 'guard', '~> 1.6.2'
15
+ gem 'guard-bundler', '~> 1.0.0'
16
+ gem 'guard-rspec', '~> 2.3.3'
17
+
18
+ # file system change event handling
19
+ gem 'rb-fchange', '~> 0.0.6', :require => false
20
+ gem 'rb-fsevent', '~> 0.9.3', :require => false
21
+ gem 'rb-inotify', '~> 0.9.0', :require => false
22
+
23
+ # Remove this one https://github.com/guard/listen/pull/78 is released
24
+ gem 'listen', '~> 0.7.2', :git => 'https://github.com/guard/listen.git'
25
+
26
+ # notification handling
27
+ gem 'libnotify', '~> 0.8.0', :require => false
28
+ gem 'rb-notifu', '~> 0.0.4', :require => false
29
+ gem 'terminal-notifier-guard', '~> 1.5.3', :require => false
30
+ end
31
+
32
+ group :metrics do
33
+ gem 'flay', '~> 1.4.3'
34
+ gem 'flog', '~> 2.5.3'
35
+ gem 'reek', '~> 1.2.13', :git => 'https://github.com/troessner/reek.git', :ref => 'ef77fcecaa21c9ebcbe4d9a79d41b0e70196bf18'
36
+ gem 'roodi', '~> 2.2.0'
37
+ gem 'yardstick', '~> 0.9.2'
38
+
39
+ platforms :ruby_18, :ruby_19 do
40
+ # this indirectly depends on ffi which does not build on ruby-head
41
+ gem 'yard-spellcheck', '~> 0.1.5'
42
+ end
43
+
44
+ platforms :mri_19, :rbx do
45
+ # gem 'mutant', '~> 0.2.16'
46
+ end
47
+
48
+ platforms :mri_19 do
49
+ gem 'simplecov', '~> 0.7.1'
50
+ end
51
+
52
+ platforms :rbx do
53
+ gem 'pelusa', '~> 0.2.2'
54
+ end
55
+ end
56
+
57
+ group :benchmarks do
58
+ gem 'rbench', '~> 0.2.3'
59
+ end
60
+
61
+ platform :jruby do
62
+ group :jruby do
63
+ gem 'jruby-openssl', '~> 0.8.2'
64
+ end
65
+ end
data/Guardfile CHANGED
@@ -2,17 +2,7 @@ guard 'bundler' do
2
2
  watch(/^.+\.gemspec/)
3
3
  end
4
4
 
5
- guard 'yard' do
6
- watch(%r{lib/.+\.rb})
7
- end
8
-
9
5
  guard 'rspec', :spec_paths => "spec/unit" do
10
- watch(%r{lib/.+\.rb})
11
- watch(%r{spec/.+\.rb})
12
- end
13
-
14
- guard 'rspec', :spec_paths => "spec/acceptance" do
15
- watch(%r{lib/.+\.rb})
16
6
  watch(%r{spec/.+\.rb})
7
+ watch(%r{lib/ashikawa-core/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" }
17
8
  end
18
-
data/README.md CHANGED
@@ -1,20 +1,22 @@
1
1
  # Ashikawa Core
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/ashikawa-core.png)](http://badge.fury.io/rb/ashikawa-core)
3
4
  [![Build Status](https://secure.travis-ci.org/triAGENS/ashikawa-core.png?branch=master)](http://travis-ci.org/triAGENS/ashikawa-core)
4
- [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/triAGENS/ashikawa-core)
5
5
  [![Dependency Status](https://gemnasium.com/triAGENS/ashikawa-core.png)](https://gemnasium.com/triAGENS/ashikawa-core)
6
+ [![Code Climate](https://codeclimate.com/github/triAGENS/ashikawa-core.png)](https://codeclimate.com/github/triAGENS/ashikawa-core)
6
7
 
7
- Ashikawa Core is a Wrapper around the ArangoDB Rest API. It provides low level access and will be used in different ArangoDB ODMs.
8
+ Ashikawa Core is a Wrapper around the ArangoDB Rest API. It provides low level access and will be used in different ArangoDB ODMs and other projects related to the database. It is always working with the stable version of ArangoDB, this is currently version **1.1.2**.
8
9
 
9
10
  All tests run on Travis CI for the following versions of Ruby:
10
11
 
11
- * MRI 1.9.2 and 1.9.3
12
- * Rubinius 1.9 mode
13
- * JRuby 1.9 mode
12
+ * MRI 1.8.7, 1.9.2 and 1.9.3
13
+ * Rubinius 1.8 and 1.9 mode
14
+ * JRuby 1.8 and 1.9 mode
15
+ * REE
14
16
 
15
- We also run on JRuby and MRI Head. MRI-head is currently not passing, because some dependencies are not compatible.
17
+ We also run on JRuby and MRI Head, but they are allowed failures (Please see [Travis](http://travis-ci.org/triAGENS/ashikawa-core) for their build status).
16
18
 
17
- Please note that the `master` branch is always the stable version released on Ruby Gems (*This is actually a lie, but we are currently converting to this model ;) The next release will implement this*). If you want the most recent version, please refer to the `development` branch.
19
+ Please note that the `master` branch is always the stable version released on Ruby Gems and documented on RDoc. If you want the most recent version, please refer to the `development` branch.
18
20
 
19
21
  ## How to use it
20
22
 
@@ -34,4 +36,8 @@ If you find a bug in this gem, please report it on [our tracker](https://github.
34
36
 
35
37
  # Contributing
36
38
 
37
- If you want to contribute to the project, see CONTRIBUTING.md for details. It contains information on our process and how to set up everything.
39
+ If you want to contribute to the project, see CONTRIBUTING.md for details. It contains information on our process and how to set up everything. The following people have contributed to this project:
40
+
41
+ * Lucas Dohmen (@moonglum): Developer
42
+ * Tobias Eilert (@EinLama): Contributor
43
+ * Markus Schirp (@mbj): Contributor
data/Rakefile CHANGED
@@ -1,106 +1,8 @@
1
1
  #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
3
- require "rspec"
4
- require "rspec/core/rake_task"
5
- require "roodi"
6
- require "roodi_task"
7
- # require 'yardstick/rake/measurement'
8
- # require 'yardstick/rake/verify'
2
+ require 'devtools'
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
9
5
 
6
+ Devtools.init
10
7
 
11
- namespace :spec do
12
- desc "Run the acceptance tests. Requires ArangoDB to be running."
13
- RSpec::Core::RakeTask.new(:acceptance_with_running_arangodb) do |spec|
14
- spec.pattern = "spec/acceptance/*_spec.rb"
15
- end
16
-
17
- desc "Run the acceptance tests. Requires ArangoDB."
18
- RSpec::Core::RakeTask.new(:acceptance) do |spec|
19
- spec.rspec_opts = "--require acceptance/arango_helper.rb"
20
- spec.pattern = "spec/acceptance/*_spec.rb"
21
- end
22
-
23
- desc "Run the authentication acceptance tests. Requires ArangoDB."
24
- RSpec::Core::RakeTask.new(:acceptance_auth) do |spec|
25
- spec.rspec_opts = "--require acceptance_auth/arango_helper.rb"
26
- spec.pattern = "spec/acceptance_auth/*_spec.rb"
27
- end
28
-
29
- desc "Run the unit tests"
30
- RSpec::Core::RakeTask.new(:unit) do |spec|
31
- spec.pattern = "spec/unit/*_spec.rb"
32
- end
33
-
34
- desc "Run all tests. Requires ArangoDB"
35
- task :all => [:acceptance, :unit]
36
- end
37
-
38
- desc "check if gems are up to date"
39
- task :dependencies do
40
- dependency_status = `bundle outdated`
41
- if dependency_status.include? "up to date"
42
- puts "Dependencies up to date."
43
- else
44
- puts dependency_status
45
- exit(1)
46
- end
47
- end
48
-
49
- namespace :yard do
50
- # Yardstick::Rake::Measurement.new(:report) do |measurement|
51
- # measurement.output = 'report/measurement.txt'
52
- # end
53
-
54
- # Yardstick::Rake::Verify.new(:verify) do |verify|
55
- # verify.threshold = 100
56
- # end
57
-
58
- desc "generate the documentation"
59
- task :generate do
60
- `yard`
61
- end
62
-
63
- desc "start the documentation server on port 8808"
64
- task :server do
65
- `yard server --reload`
66
- end
67
-
68
- desc "get statistics on the yard documentation"
69
- task :stats do
70
- `yard stats`
71
- end
72
- end
73
-
74
- namespace :metrics do
75
- metric_tasks = []
76
-
77
- begin
78
- require 'cane/rake_task'
79
-
80
- desc "Run cane to check quality metrics"
81
- Cane::RakeTask.new(:cane) do |cane|
82
- cane.abc_max = 10
83
- cane.style_measure = 140
84
- cane.style_glob = "{app,lib}/**/*.rb"
85
- end
86
-
87
- metric_tasks << :cane
88
- rescue LoadError
89
- warn "cane not available, quality task not provided."
90
- end
91
-
92
- RoodiTask.new do |roodi|
93
- roodi.patterns = %w(lib/**/*.rb spec/**/*.rb)
94
- end
95
- metric_tasks << :roodi
96
-
97
- task :all => metric_tasks
98
- end
99
-
100
- desc "Run Unit Tests - no ArangoDB required"
101
- # task :ci => ["spec:unit", "yard:verify"]
102
- task :ci => ["spec:unit", "spec:acceptance_with_running_arangodb", "metrics:all"]
103
-
104
- desc "Run all tests and verify documentation - ArangoDB required"
105
- # task :default => ["spec:all", "yard:verify"]
106
- task :default => ["spec:all", "metrics:all"]
8
+ import("./tasks/adjustments.rake")
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
12
12
  gem.description = "Ashikawa Core is a wrapper around the ArangoDB REST API. It provides low level access and will be used in different ArangoDB ODMs."
13
13
 
14
14
  gem.required_ruby_version = '>= 1.9.2'
15
- gem.requirements << "ArangoDB, v1.0 alpha or greater"
15
+ gem.requirements << "ArangoDB, v1.1.2"
16
16
 
17
17
  gem.rubyforge_project = "ashikawa-core"
18
18
 
@@ -23,34 +23,8 @@ Gem::Specification.new do |gem|
23
23
 
24
24
  # Runtime Dependencies
25
25
  gem.add_dependency "rest-client", "~> 1.6.7"
26
-
27
- # Runtime Dependencies (JRuby only)
28
- if defined? PLATFORM and PLATFORM == 'java'
29
- gem.add_dependency "json", "~> 1.7.5"
30
- gem.add_dependency "jruby-openssl", "~> 0.7.7"
31
- else
32
- # RedCarpet is not compatible with JRuby
33
- # It is only needed to generate the YARD Documentation
34
- gem.add_development_dependency "redcarpet", "~> 2.2.2"
35
- end
26
+ gem.add_dependency "json", "~> 1.7.7"
36
27
 
37
28
  # Development Dependencies
38
- gem.add_development_dependency "rake", "~> 0.9.2.2"
39
- gem.add_development_dependency "rspec", "~> 2.11.0"
40
- gem.add_development_dependency "yard", "~> 0.8.3"
41
- gem.add_development_dependency "webmock", "~> 1.9.0"
42
- # gem.add_development_dependency "yardstick", "~> 0.6.0"
43
- gem.add_development_dependency "simplecov", "~> 0.7.1"
44
- gem.add_development_dependency "cane", "~> 2.4.0"
45
- gem.add_development_dependency "roodi1.9", "~> 2.0.1"
46
-
47
- # Do not update to version 3, it is currently not compatible with roodi1.9
48
- # see grsmv/roodi1.9#1
49
- gem.add_development_dependency "ruby_parser", "~> 2.3.1"
50
-
51
- gem.add_development_dependency "guard", "~> 1.5.3"
52
- gem.add_development_dependency "guard-rspec", "~> 2.1.1"
53
- gem.add_development_dependency "guard-bundler", "~> 1.0.0"
54
- gem.add_development_dependency "guard-yard", "~> 2.0.1"
55
- gem.add_development_dependency "rb-fsevent", "~> 0.9.2"
29
+ gem.add_development_dependency "webmock", "~> 1.9.3"
56
30
  end
data/config/flay.yml ADDED
@@ -0,0 +1,3 @@
1
+ ---
2
+ threshold: 18
3
+ total_score: 250
data/config/flog.yml ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ threshold: 23.0
data/config/mutant.yml ADDED
@@ -0,0 +1,3 @@
1
+ ---
2
+ name: ashikawa-core
3
+ namespace: Ashikawa::Core
data/config/roodi.yml ADDED
@@ -0,0 +1,18 @@
1
+ AbcMetricMethodCheck: { score: 15.0 }
2
+ AssignmentInConditionalCheck: { }
3
+ CaseMissingElseCheck: { }
4
+ ClassLineCountCheck: { line_count: 500 }
5
+ ClassNameCheck:
6
+ pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/
7
+ ClassVariableCheck: { }
8
+ CyclomaticComplexityBlockCheck: { complexity: 1 }
9
+ CyclomaticComplexityMethodCheck: { complexity: 5 }
10
+ EmptyRescueBodyCheck: { }
11
+ ForLoopCheck: { }
12
+ MethodLineCountCheck: { line_count: 10 }
13
+ MethodNameCheck:
14
+ pattern: !ruby/regexp /^[_a-z<>=\[\]|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/
15
+ ModuleLineCountCheck: { line_count: 500 }
16
+ ModuleNameCheck:
17
+ pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/
18
+ ParameterNumberCheck: { parameter_count: 5 }
data/config/site.reek ADDED
@@ -0,0 +1,95 @@
1
+ ---
2
+ UncommunicativeParameterName:
3
+ accept: []
4
+ exclude: []
5
+ enabled: false
6
+ reject:
7
+ - !ruby/regexp /^.$/
8
+ - !ruby/regexp /[0-9]$/
9
+ - !ruby/regexp /[A-Z]/
10
+ LargeClass:
11
+ max_methods: 10
12
+ exclude:
13
+ - Ashikawa::Core::Query
14
+ - Ashikawa::Core::Collection
15
+ enabled: true
16
+ max_instance_variables: 5
17
+ UncommunicativeMethodName:
18
+ accept: []
19
+ exclude: []
20
+ enabled: true
21
+ reject:
22
+ - !ruby/regexp /^[a-z]$/
23
+ - !ruby/regexp /[0-9]$/
24
+ - !ruby/regexp /[A-Z]/
25
+ LongParameterList:
26
+ max_params: 3
27
+ exclude:
28
+ - Ashikawa::Core::Query#wrapped_request
29
+ enabled: true
30
+ overrides: {}
31
+ FeatureEnvy:
32
+ exclude: []
33
+ enabled: false
34
+ ClassVariable:
35
+ exclude: []
36
+ enabled: true
37
+ BooleanParameter:
38
+ exclude: []
39
+ enabled: true
40
+ IrresponsibleModule:
41
+ exclude: []
42
+ enabled: true
43
+ UncommunicativeModuleName:
44
+ accept: []
45
+ exclude: []
46
+ enabled: true
47
+ reject: []
48
+ NestedIterators:
49
+ ignore_iterators: []
50
+ exclude: []
51
+ enabled: true
52
+ max_allowed_nesting: 2
53
+ LongMethod:
54
+ max_statements: 8
55
+ exclude: []
56
+ enabled: true
57
+ Duplication:
58
+ allow_calls: []
59
+ exclude:
60
+ - Ashikawa::Core::Document#initialize
61
+ enabled: true
62
+ max_calls: 1
63
+ UtilityFunction:
64
+ max_helper_calls: 0
65
+ exclude: []
66
+ enabled: false
67
+ Attribute:
68
+ exclude: []
69
+ enabled: false
70
+ UncommunicativeVariableName:
71
+ accept: []
72
+ exclude: []
73
+ enabled: true
74
+ reject:
75
+ - !ruby/regexp /^.$/
76
+ - !ruby/regexp /[0-9]$/
77
+ - !ruby/regexp /[A-Z]/
78
+ SimulatedPolymorphism:
79
+ exclude:
80
+ - Ashikawa::Core::Query
81
+ enabled: true
82
+ max_ifs: 1
83
+ DataClump:
84
+ exclude:
85
+ - Ashikawa::Core::Query
86
+ enabled: true
87
+ max_copies: 2
88
+ min_clump_size: 2
89
+ ControlCouple:
90
+ exclude: []
91
+ enabled: true
92
+ LongYieldList:
93
+ max_params: 1
94
+ exclude: []
95
+ enabled: true