r2ree 0.1.1 → 0.1.2

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
- SHA1:
3
- metadata.gz: 1880fd4e308c99714e1ea13e5c796eb9afc50ad1
4
- data.tar.gz: d6d536b0ff188ea98d48453f4ae2a94779d6d765
2
+ SHA256:
3
+ metadata.gz: 3c8335cbef249961ab636592b8c0915feea8d6c10b977b71c5d3024b133c490a
4
+ data.tar.gz: 90dfad4cb86a41f33a4c569b3f63c99bc4d21fe67db2e0e8bcc40f56aba49825
5
5
  SHA512:
6
- metadata.gz: 2d5e9858d46d1c6e97e79b7b54e958ce07e5c97f661f0bb56cccad5580fc5b5e046fdc34c989bd54acebc3e5d35301024643d17c71a6f87c6a39d532691be6a5
7
- data.tar.gz: b277343834e0096d6ad7df512b7873a3dbc328283ac866f93e1f8b9dce7f8dfbfab2fc42d944626106d9410f1934da04bbf1b1e000818d91cea8c3de4022f040
6
+ metadata.gz: 93ac6878efc2d145ba8faf1a4b1575ddbe9eb0337b37f843bf5eb9b6e3e61d6951d0d9993f1f6ad9e6c0135208be8bc44274f24ce8612498cf6c9a0e1ee85541
7
+ data.tar.gz: 838a4fa38d82e1500f17f901bd28ac36970cf93a148a1f8e24144253a73aea9dbfa7ce3a725faf84eed0af771e12afe424060cff9ea0f167f1c2339d8650435d
@@ -1,3 +1,3 @@
1
1
  class R2ree
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
@@ -1,21 +1,47 @@
1
+ sudo: required
2
+ dist: trusty
1
3
  language: cpp
2
4
  os:
3
5
  - linux
4
6
  - osx
5
- cache:
6
- - apt
7
- compiler:
8
- - clang
9
- - gcc
10
- before_install:
11
- - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update; fi
7
+ compiler: clang++
8
+ env: CXXFLAGS='-std=c++11'
9
+ addons:
10
+ apt:
11
+ sources:
12
+ - ubuntu-toolchain-r-test
13
+ - george-edison55-precise-backports
14
+ packages:
15
+ - cmake
16
+ - cmake-data
17
+ - libgtest-dev
18
+ matrix:
19
+ include:
20
+ - compiler: clang++-3.6
21
+ addons:
22
+ apt:
23
+ sources:
24
+ - ubuntu-toolchain-r-test
25
+ - llvm-toolchain-precise-3.6
26
+ packages:
27
+ - clang-3.6
28
+ env: CXX=clang++-3.6
29
+ - compiler: clang++-3.7
30
+ addons:
31
+ apt:
32
+ sources:
33
+ - ubuntu-toolchain-r-test
34
+ - llvm-toolchain-precise-3.7
35
+ packages:
36
+ - clang-3.7
37
+ env: CXX=clang++-3.7
12
38
  install:
13
39
  - wget https://github.com/google/googletest/archive/release-1.7.0.zip -O googletest-release-1.7.0.zip
14
- - if [ "$TRAVIS_OS_NAME" == "linux" ]; then unzip -q googletest-release-1.7.0.zip && cd googletest-release-1.7.0 && sudo cp -r include/gtest /usr/local/include && g++ src/gtest-all.cc -I. -Iinclude -c && g++ src/gtest_main.cc -I. -Iinclude -c && ar -rv libgtest.a gtest-all.o && ar -rv libgtest_main.a gtest_main.o && sudo mv *.a /usr/local/lib && g++ -m32 src/gtest-all.cc -I. -Iinclude -c && g++ -m32 src/gtest_main.cc -I. -Iinclude -c && ar -rv libgtest.a gtest-all.o && ar -rv libgtest_main.a gtest_main.o && sudo mkdir /usr/local/lib32 && sudo mv *.a /usr/local/lib32 && cd ..; fi
15
40
  - if [ "$TRAVIS_OS_NAME" == "osx" ]; then unzip -q googletest-release-1.7.0.zip && cd googletest-release-1.7.0 && sudo cp -r include/gtest /usr/local/include && clang++ src/gtest-all.cc -I. -Iinclude -c && g++ src/gtest_main.cc -I. -Iinclude -c && ar -rv libgtest.a gtest-all.o && ar -rv libgtest_main.a gtest_main.o && sudo mv *.a /usr/local/lib && cd ..; fi
16
- matrix:
17
- exclude:
18
- - os: osx
19
- compiler: gcc
20
41
  script:
21
- - mkdir build && cd build && cmake .. && make && ./r2ree_test
42
+ - mkdir build
43
+ - cd build
44
+ - cmake ..
45
+ - cat Makefile
46
+ - make
47
+ - ./r2ree_test
@@ -20,7 +20,7 @@ set(EXT_PROJECTS_DIR ${PROJECT_SOURCE_DIR}/ext)
20
20
 
21
21
  add_subdirectory(${EXT_PROJECTS_DIR}/gtest)
22
22
 
23
- set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ -Iinclude -include ${PROJECT_SOURCE_DIR}/src/r2ree.cc")
23
+ set(CMAKE_CXX_FLAGS "-std=c++11 ${CXX_FLAGS} -Iinclude -include ${PROJECT_SOURCE_DIR}/src/r2ree.cc")
24
24
 
25
25
  #-------------------
26
26
  # Test
@@ -1,5 +1,7 @@
1
1
  # r2ree
2
2
 
3
+ [![Build Status](https://travis-ci.org/namusyaka/r2ree.svg?branch=master)](https://travis-ci.org/namusyaka/r2ree)
4
+
3
5
  Radix tree implementation for use in HTTP routing.
4
6
 
5
7
  r2ree is written in C++ and licensed under the MIT License, it can be used as a library.
@@ -28,4 +28,4 @@ set(GTEST_INCLUDE_DIRS ${source_dir}/googletest/include PARENT_SCOPE)
28
28
 
29
29
  # Specify MainTest's link libraries
30
30
  ExternalProject_Get_Property(googletest binary_dir)
31
- set(GTEST_LIBS_DIR ${binary_dir}/googlemock/gtest PARENT_SCOPE)
31
+ set(GTEST_LIBS_DIR ${binary_dir}/lib PARENT_SCOPE)
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * The MIT License (MIT)
3
3
  *
4
- * Copyright (c) 2016 namusyaka
4
+ * Copyright (c) 2016 namusyaka, shiyanhui
5
5
  *
6
6
  * Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  * of this software and associated documentation files (the "Software"), to deal
@@ -163,14 +163,16 @@ namespace r2ree {
163
163
  }
164
164
 
165
165
  parse_result radix_tree::get(const string &path) {
166
- parameters params = parameters{ new parameter[root->max_parameters] };
166
+ parameters params = parameters{ new parameter[root->max_parameters], 0};
167
167
 
168
168
  auto root = this->root;
169
169
  int i = 0, n = path.size(), p;
170
170
 
171
171
  while (i < n) {
172
- if (root->indices.empty())
172
+ if (root->indices.empty()) {
173
+ delete[] params.params;
173
174
  return parse_result();
175
+ }
174
176
 
175
177
  if (root->indices[0] == colon) {
176
178
  root = root->children[0];
@@ -183,8 +185,10 @@ namespace r2ree {
183
185
  break;
184
186
  } else {
185
187
  root = root->get_child(path[i]);
186
- if (!root || path.substr(i, root->path.size()) != root->path)
188
+ if (!root || path.substr(i, root->path.size()) != root->path) {
189
+ delete[] params.params;
187
190
  return parse_result();
191
+ }
188
192
  i += root->path.size();
189
193
  }
190
194
  }
@@ -73,4 +73,21 @@ namespace {
73
73
  ASSERT_EQ("foo", params.params[1].second);
74
74
  ASSERT_EQ(true, std::get<3>(actual));
75
75
  }
76
+
77
+ TEST_F(r2ree_test, get_with_splat) {
78
+ r2ree::parse_result actual;
79
+ r2ree::parameters params;
80
+
81
+ tree.insert("/splat/*");
82
+
83
+ actual = tree.get("/splat/boofoowoo");
84
+ params = std::get<2>(actual);
85
+
86
+ ASSERT_EQ(true, std::get<0>(actual));
87
+ ASSERT_EQ(0, std::get<1>(actual));
88
+ ASSERT_EQ(1, params.size);
89
+ ASSERT_EQ("", params.params[0].first);
90
+ ASSERT_EQ("boofoowoo", params.params[0].second);
91
+ ASSERT_EQ(true, std::get<3>(actual));
92
+ }
76
93
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r2ree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - namusyaka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-24 00:00:00.000000000 Z
11
+ date: 2019-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  version: '0'
72
72
  requirements: []
73
73
  rubyforge_project:
74
- rubygems_version: 2.5.1
74
+ rubygems_version: 2.7.3
75
75
  signing_key:
76
76
  specification_version: 4
77
77
  summary: r2ree radix tree implementation for ruby