rox-rollout 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +45 -0
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/LICENSE +50 -0
- data/README_DEVELOP.md +19 -0
- data/Rakefile +16 -0
- data/_archive/.document +5 -0
- data/_archive/.rspec +1 -0
- data/_archive/Gemfile +15 -0
- data/_archive/Gemfile.lock +87 -0
- data/_archive/README.md +32 -0
- data/_archive/README.rdoc +19 -0
- data/_archive/Rakefile +50 -0
- data/_archive/lib/expr_function_definition.rb +52 -0
- data/_archive/lib/function_definition.rb +48 -0
- data/_archive/lib/function_token.rb +12 -0
- data/_archive/lib/object_extends.rb +12 -0
- data/_archive/lib/ruby_interpreter.rb +292 -0
- data/_archive/lib/stack.rb +48 -0
- data/_archive/lib/string_extends.rb +14 -0
- data/_archive/spec/ruby_interpreter_spec.rb +203 -0
- data/_archive/spec/spec_helper.rb +30 -0
- data/_archive/spec/stack_spec.rb +77 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/e2e/container.rb +38 -0
- data/e2e/custom_props.rb +55 -0
- data/e2e/rox_e2e_test.rb +159 -0
- data/e2e/test_vars.rb +24 -0
- data/lib/rox.rb +5 -0
- data/lib/rox/core/client/buid.rb +82 -0
- data/lib/rox/core/client/device_properties.rb +45 -0
- data/lib/rox/core/client/internal_flags.rb +20 -0
- data/lib/rox/core/client/sdk_settings.rb +5 -0
- data/lib/rox/core/configuration/configuration.rb +5 -0
- data/lib/rox/core/configuration/configuration_fetched_args.rb +23 -0
- data/lib/rox/core/configuration/configuration_fetched_invoker.rb +37 -0
- data/lib/rox/core/configuration/configuration_parser.rb +85 -0
- data/lib/rox/core/configuration/fetcher_error.rb +13 -0
- data/lib/rox/core/configuration/fetcher_status.rb +10 -0
- data/lib/rox/core/configuration/models/experiment_model.rb +5 -0
- data/lib/rox/core/configuration/models/target_group_model.rb +5 -0
- data/lib/rox/core/consts/build.rb +8 -0
- data/lib/rox/core/consts/environment.rb +42 -0
- data/lib/rox/core/consts/property_type.rb +29 -0
- data/lib/rox/core/context/merged_context.rb +16 -0
- data/lib/rox/core/core.rb +131 -0
- data/lib/rox/core/entities/flag.rb +26 -0
- data/lib/rox/core/entities/flag_setter.rb +39 -0
- data/lib/rox/core/entities/variant.rb +56 -0
- data/lib/rox/core/impression/impression_args.rb +5 -0
- data/lib/rox/core/impression/impression_invoker.rb +41 -0
- data/lib/rox/core/impression/models/experiment.rb +14 -0
- data/lib/rox/core/impression/models/reporting_value.rb +5 -0
- data/lib/rox/core/logging/logging.rb +17 -0
- data/lib/rox/core/logging/no_op_logger.rb +11 -0
- data/lib/rox/core/network/configuration_fetch_result.rb +5 -0
- data/lib/rox/core/network/configuration_fetcher.rb +38 -0
- data/lib/rox/core/network/configuration_fetcher_base.rb +25 -0
- data/lib/rox/core/network/configuration_fetcher_roxy.rb +29 -0
- data/lib/rox/core/network/configuration_source.rb +9 -0
- data/lib/rox/core/network/request.rb +46 -0
- data/lib/rox/core/network/request_configuration_builder.rb +48 -0
- data/lib/rox/core/network/request_data.rb +5 -0
- data/lib/rox/core/network/response.rb +16 -0
- data/lib/rox/core/properties/custom_property.rb +18 -0
- data/lib/rox/core/properties/custom_property_type.rb +18 -0
- data/lib/rox/core/properties/device_property.rb +11 -0
- data/lib/rox/core/register/registerer.rb +35 -0
- data/lib/rox/core/reporting/error_reporter.rb +152 -0
- data/lib/rox/core/repositories/custom_property_repository.rb +61 -0
- data/lib/rox/core/repositories/experiment_repository.rb +21 -0
- data/lib/rox/core/repositories/flag_repository.rb +49 -0
- data/lib/rox/core/repositories/roxx/experiments_extensions.rb +82 -0
- data/lib/rox/core/repositories/roxx/properties_extensions.rb +26 -0
- data/lib/rox/core/repositories/target_group_repository.rb +17 -0
- data/lib/rox/core/roxx/core_stack.rb +22 -0
- data/lib/rox/core/roxx/evaluation_result.rb +28 -0
- data/lib/rox/core/roxx/node.rb +11 -0
- data/lib/rox/core/roxx/parser.rb +143 -0
- data/lib/rox/core/roxx/regular_expression_extensions.rb +33 -0
- data/lib/rox/core/roxx/string_tokenizer.rb +68 -0
- data/lib/rox/core/roxx/symbols.rb +14 -0
- data/lib/rox/core/roxx/token_type.rb +30 -0
- data/lib/rox/core/roxx/tokenized_expression.rb +119 -0
- data/lib/rox/core/roxx/value_compare_extensions.rb +137 -0
- data/lib/rox/core/security/signature_verifier.rb +18 -0
- data/lib/rox/core/utils/periodic_task.rb +12 -0
- data/lib/rox/core/utils/type_utils.rb +9 -0
- data/lib/rox/server/client/sdk_settings.rb +5 -0
- data/lib/rox/server/client/server_properties.rb +20 -0
- data/lib/rox/server/flags/rox_flag.rb +19 -0
- data/lib/rox/server/flags/rox_variant.rb +8 -0
- data/lib/rox/server/logging/server_logger.rb +35 -0
- data/lib/rox/server/rox_options.rb +27 -0
- data/lib/rox/server/rox_server.rb +83 -0
- data/lib/rox/version.rb +3 -0
- data/rox.gemspec +29 -0
- metadata +184 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5f41922c6dd20fbbadc0522358c446887112b503
|
4
|
+
data.tar.gz: ff48ba25bfb7eedf8327cb665089b0e73bf9b424
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4ec8cc7159065fb67fc56b2b1ac6f1973d76d44d93719e5d1f35c01a7ab6b3974cbd60c44e5ba9688239270404a461354051442c5da9a9b4a22e16cc7ec22388
|
7
|
+
data.tar.gz: 2588175877bdd95f062c840ac0aca9bb625979bd7c3274b015966b679bbb93a9beb0b13e0871ec7546fd2b7f3498852aeb89a70c184deea07d4bc340a6552adc
|
@@ -0,0 +1,45 @@
|
|
1
|
+
version: 2
|
2
|
+
workflows:
|
3
|
+
version: 2
|
4
|
+
test:
|
5
|
+
jobs:
|
6
|
+
- test-2.5
|
7
|
+
- test-2.4
|
8
|
+
- test-2.3
|
9
|
+
jobs:
|
10
|
+
test-2.5: &test-template
|
11
|
+
docker:
|
12
|
+
- image: circleci/ruby:2.5.1
|
13
|
+
|
14
|
+
working_directory: ~/repo
|
15
|
+
|
16
|
+
steps:
|
17
|
+
- checkout
|
18
|
+
|
19
|
+
- restore_cache:
|
20
|
+
keys:
|
21
|
+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
22
|
+
- v1-dependencies-
|
23
|
+
|
24
|
+
- run:
|
25
|
+
name: install dependencies
|
26
|
+
command: |
|
27
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
28
|
+
|
29
|
+
- save_cache:
|
30
|
+
paths:
|
31
|
+
- ./vendor/bundle
|
32
|
+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
33
|
+
|
34
|
+
- run:
|
35
|
+
name: run tests
|
36
|
+
command: |
|
37
|
+
bundle exec rake test
|
38
|
+
test-2.4:
|
39
|
+
<<: *test-template
|
40
|
+
docker:
|
41
|
+
- image: circleci/ruby:2.4.4
|
42
|
+
test-2.3:
|
43
|
+
<<: *test-template
|
44
|
+
docker:
|
45
|
+
- image: circleci/ruby:2.3.7
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
All components of this product are
|
2
|
+
Copyright (c) Rollout, Inc. All rights reserved.
|
3
|
+
|
4
|
+
Certain inventions disclosed in this file may be claimed within
|
5
|
+
patents owned or patent applications filed by Rollout, Inc. or third
|
6
|
+
parties.
|
7
|
+
|
8
|
+
Subject to the terms of this notice, Rollout grants you a nonexclusive,
|
9
|
+
nontransferable license, without the right to sublicense, to (a) install and
|
10
|
+
execute one copy of these files on any number of workstations owned or
|
11
|
+
controlled by you and (b) distribute verbatim copies of these files to third
|
12
|
+
parties. You may install, execute, and distribute these files and their
|
13
|
+
contents only in conjunction with your direct use of Rollout’s services.
|
14
|
+
These files and their contents shall not be used in conjunction with any other
|
15
|
+
product or software, including but not limited to those that may compete with
|
16
|
+
any Rollout product, feature, or software. As a condition to the foregoing
|
17
|
+
grant, you must provide this notice along with each copy you distribute and you
|
18
|
+
must not remove, alter, or obscure this notice. In the event you submit or
|
19
|
+
provide any feedback, code, pull requests, or suggestions to Rollout you
|
20
|
+
hereby grant Rollout a worldwide, non-exclusive, irrevocable, transferrable,
|
21
|
+
fully paid-up license to use the code, algorithms, patents, and ideas therein in
|
22
|
+
our products.
|
23
|
+
|
24
|
+
All other use, reproduction, modification, distribution, or other exploitation
|
25
|
+
of these files is strictly prohibited, except as may be set forth in a separate
|
26
|
+
written license agreement between you and Rollout. The terms of any such
|
27
|
+
license agreement will control over this notice. The license stated above will
|
28
|
+
be automatically terminated and revoked if you exceed its scope or violate any
|
29
|
+
of the terms of this notice.
|
30
|
+
|
31
|
+
This License does not grant permission to use the trade names, trademarks,
|
32
|
+
service marks, or product names of Rollout, except as required for reasonable
|
33
|
+
and customary use in describing the origin of this file and reproducing the
|
34
|
+
content of this notice. You may not mark or brand this file with any trade
|
35
|
+
name, trademarks, service marks, or product names other than the original brand
|
36
|
+
(if any) provided by Rollout.
|
37
|
+
|
38
|
+
Unless otherwise expressly agreed by Rollout in a separate written license
|
39
|
+
agreement, these files are provided AS IS, WITHOUT WARRANTY OF ANY KIND,
|
40
|
+
including without any implied warranties of MERCHANTABILITY, FITNESS FOR A
|
41
|
+
PARTICULAR PURPOSE, TITLE, or NON-INFRINGEMENT. As a condition to your use of
|
42
|
+
these files, you are solely responsible for such use. Rollout will have no
|
43
|
+
liability to you for direct, indirect, consequential, incidental, special, or
|
44
|
+
punitive damages or for lost profits or data.
|
45
|
+
|
46
|
+
|
47
|
+
The Rollout SDK also uses code from the following open source
|
48
|
+
projects under the following licenses:
|
49
|
+
|
50
|
+
<TODO>
|
data/README_DEVELOP.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Developer Guide
|
2
|
+
|
3
|
+
## Run tests on current Ruby version
|
4
|
+
|
5
|
+
```
|
6
|
+
// Run unit tests (folder 'tests')
|
7
|
+
rake test
|
8
|
+
|
9
|
+
// Run E2E tests (folder 'e2e')
|
10
|
+
rake e2e
|
11
|
+
```
|
12
|
+
|
13
|
+
## Publish new version
|
14
|
+
|
15
|
+
### Steps
|
16
|
+
|
17
|
+
1. Increment version in ```lib/rox/version.rb```
|
18
|
+
2. Generate the gem package: ```gem build rox.gemspec```
|
19
|
+
2. Upload to RubyGem: ```gem push rox-rollout-VERSION.gem```
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.libs << "lib"
|
7
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
8
|
+
end
|
9
|
+
|
10
|
+
Rake::TestTask.new(:e2e) do |t|
|
11
|
+
t.libs << "lib"
|
12
|
+
t.libs << "e2e"
|
13
|
+
t.test_files = FileList["e2e/**/*_test.rb"]
|
14
|
+
end
|
15
|
+
|
16
|
+
task :default => :test
|
data/_archive/.document
ADDED
data/_archive/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/_archive/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem 'pry'
|
10
|
+
gem "rspec", "~> 3.5.0"
|
11
|
+
gem "rdoc", "~> 3.12"
|
12
|
+
gem "bundler", "~> 1.0"
|
13
|
+
gem "jeweler", "~> 2.0.1"
|
14
|
+
gem "simplecov", ">= 0"
|
15
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
addressable (2.5.2)
|
5
|
+
public_suffix (>= 2.0.2, < 4.0)
|
6
|
+
builder (3.2.3)
|
7
|
+
coderay (1.1.2)
|
8
|
+
descendants_tracker (0.0.4)
|
9
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
10
|
+
diff-lcs (1.3)
|
11
|
+
docile (1.3.1)
|
12
|
+
faraday (0.12.2)
|
13
|
+
multipart-post (>= 1.2, < 3)
|
14
|
+
git (1.5.0)
|
15
|
+
github_api (0.18.2)
|
16
|
+
addressable (~> 2.4)
|
17
|
+
descendants_tracker (~> 0.0.4)
|
18
|
+
faraday (~> 0.8)
|
19
|
+
hashie (~> 3.5, >= 3.5.2)
|
20
|
+
oauth2 (~> 1.0)
|
21
|
+
hashie (3.6.0)
|
22
|
+
highline (2.0.0)
|
23
|
+
jeweler (2.0.1)
|
24
|
+
builder
|
25
|
+
bundler (>= 1.0)
|
26
|
+
git (>= 1.2.5)
|
27
|
+
github_api
|
28
|
+
highline (>= 1.6.15)
|
29
|
+
nokogiri (>= 1.5.10)
|
30
|
+
rake
|
31
|
+
rdoc
|
32
|
+
json (1.8.6)
|
33
|
+
jwt (1.5.6)
|
34
|
+
method_source (0.9.0)
|
35
|
+
mini_portile2 (2.3.0)
|
36
|
+
multi_json (1.13.1)
|
37
|
+
multi_xml (0.6.0)
|
38
|
+
multipart-post (2.0.0)
|
39
|
+
nokogiri (1.8.4)
|
40
|
+
mini_portile2 (~> 2.3.0)
|
41
|
+
oauth2 (1.4.0)
|
42
|
+
faraday (>= 0.8, < 0.13)
|
43
|
+
jwt (~> 1.0)
|
44
|
+
multi_json (~> 1.3)
|
45
|
+
multi_xml (~> 0.5)
|
46
|
+
rack (>= 1.2, < 3)
|
47
|
+
pry (0.11.3)
|
48
|
+
coderay (~> 1.1.0)
|
49
|
+
method_source (~> 0.9.0)
|
50
|
+
public_suffix (3.0.3)
|
51
|
+
rack (2.0.5)
|
52
|
+
rake (12.3.1)
|
53
|
+
rdoc (3.12.2)
|
54
|
+
json (~> 1.4)
|
55
|
+
rspec (3.5.0)
|
56
|
+
rspec-core (~> 3.5.0)
|
57
|
+
rspec-expectations (~> 3.5.0)
|
58
|
+
rspec-mocks (~> 3.5.0)
|
59
|
+
rspec-core (3.5.4)
|
60
|
+
rspec-support (~> 3.5.0)
|
61
|
+
rspec-expectations (3.5.0)
|
62
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
63
|
+
rspec-support (~> 3.5.0)
|
64
|
+
rspec-mocks (3.5.0)
|
65
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
+
rspec-support (~> 3.5.0)
|
67
|
+
rspec-support (3.5.0)
|
68
|
+
simplecov (0.16.1)
|
69
|
+
docile (~> 1.1)
|
70
|
+
json (>= 1.8, < 3)
|
71
|
+
simplecov-html (~> 0.10.0)
|
72
|
+
simplecov-html (0.10.2)
|
73
|
+
thread_safe (0.3.6)
|
74
|
+
|
75
|
+
PLATFORMS
|
76
|
+
ruby
|
77
|
+
|
78
|
+
DEPENDENCIES
|
79
|
+
bundler (~> 1.0)
|
80
|
+
jeweler (~> 2.0.1)
|
81
|
+
pry
|
82
|
+
rdoc (~> 3.12)
|
83
|
+
rspec (~> 3.5.0)
|
84
|
+
simplecov
|
85
|
+
|
86
|
+
BUNDLED WITH
|
87
|
+
1.16.1
|
data/_archive/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
![Rollout](https://1ko9923xosh2dsbjsxpwqp45-wpengine.netdna-ssl.com/wp-content/themes/rollout/images/rollout_white_logo1.png)
|
2
|
+
|
3
|
+
Rollout is a Secure Feature Managment Solution for the Enterprise.
|
4
|
+
|
5
|
+
> Accelerate development and minimize the risk of deploying new code with simple to create feature flags, controlled rollouts, advanced target groups & deployment rules.
|
6
|
+
|
7
|
+
## Getting Started
|
8
|
+
|
9
|
+
Please see the detailed instructions in our docs how to [add Rollout to your project](https://support.rollout.io/docs/installing-the-sdk).
|
10
|
+
|
11
|
+
## Documentation
|
12
|
+
|
13
|
+
Getting started guide, use cases, examples and videos can be found in [Rollout support site](https://support.rollout.io)
|
14
|
+
|
15
|
+
# Rollout Ruby SDK
|
16
|
+
|
17
|
+
Rollout Ruby SDK. Define and use simple and advanced feature flags, remote configuration variables, static and computed custom properties in code. Control your application features via Rollout's dashboard.
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
```
|
21
|
+
gem install rox-rollout
|
22
|
+
```
|
23
|
+
|
24
|
+
## LICENSE
|
25
|
+
|
26
|
+
Rollout is free-to-use, proprietary software. Please see the full license (found in LICENSE in this distribution) for details on its license and the licenses of its dependencies.
|
27
|
+
|
28
|
+
Rollout Ruby SDK is free-to-use, proprietary software. Please see the full license found under the LICENSE file for more details.
|
29
|
+
|
30
|
+
## Feedback
|
31
|
+
|
32
|
+
Feedback is always welcomed support@rollout.io
|
@@ -0,0 +1,19 @@
|
|
1
|
+
= ruby-interpreter
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to ruby-interpreter
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2018 stoarch. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/_archive/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
|
+
gem.name = "ruby-interpreter"
|
18
|
+
gem.homepage = "http://github.com/stoarch/ruby-interpreter"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{TODO: one-line summary of your gem}
|
21
|
+
gem.description = %Q{TODO: longer description of your gem}
|
22
|
+
gem.email = "stormarchitextor@gmail.com"
|
23
|
+
gem.authors = ["stoarch"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Code coverage detail"
|
35
|
+
task :simplecov do
|
36
|
+
ENV['COVERAGE'] = "true"
|
37
|
+
Rake::Task['spec'].execute
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
require 'rdoc/task'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "ruby-interpreter #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
module ExprFunctionDefinition
|
3
|
+
def add_func(name)
|
4
|
+
@func_list ||= []
|
5
|
+
@func_list << name unless @func_list.include? name
|
6
|
+
end
|
7
|
+
|
8
|
+
def unary_bool_func(name, operator)
|
9
|
+
add_func(name.to_s)
|
10
|
+
|
11
|
+
define_method("evaluate_#{name.to_s}") do
|
12
|
+
|
13
|
+
a = @stack.pop
|
14
|
+
|
15
|
+
res = a.evaluate.to_boolean.send(operator.to_sym)
|
16
|
+
|
17
|
+
@stack.push BooleanValue.new(res, @stack)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def bool_func(name, operator)
|
22
|
+
add_func(name.to_s)
|
23
|
+
|
24
|
+
define_method("evaluate_#{name.to_s}") do
|
25
|
+
|
26
|
+
a = @stack.pop
|
27
|
+
b = @stack.pop
|
28
|
+
|
29
|
+
res = a.evaluate.send(operator.to_sym, b.evaluate)
|
30
|
+
@stack.push BooleanValue.new(res, @stack)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def comp_func(name, operator)
|
35
|
+
add_func(name.to_s)
|
36
|
+
|
37
|
+
define_method("evaluate_#{name.to_s}") do
|
38
|
+
a = @stack.pop
|
39
|
+
b = @stack.pop
|
40
|
+
|
41
|
+
aval = a.evaluate
|
42
|
+
bval = b.evaluate
|
43
|
+
|
44
|
+
if( aval.class == bval.class ) #we can compare string with string and numeric with numeric only
|
45
|
+
|
46
|
+
@stack.push BooleanValue.new(aval.send(operator.to_sym, bval), @stack)
|
47
|
+
else
|
48
|
+
@stack.push BooleanValue.new(false, @stack)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
|
2
|
+
module FunctionDefinition
|
3
|
+
def add_func(name)
|
4
|
+
@func_list ||= []
|
5
|
+
@func_list << name unless @func_list.include? name
|
6
|
+
end
|
7
|
+
|
8
|
+
def unary_bool_func(name, operator)
|
9
|
+
add_func(name.to_s)
|
10
|
+
|
11
|
+
define_method("evaluate#{name[0].upcase}#{name[1..-1]}") do |stack_index|
|
12
|
+
|
13
|
+
a = @operands_stack.pop
|
14
|
+
|
15
|
+
res = a.to_boolean.send(operator.to_sym).to_s
|
16
|
+
|
17
|
+
@operands_stack.push res
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def bool_func(name, operator)
|
22
|
+
add_func(name.to_s)
|
23
|
+
|
24
|
+
define_method("evaluate#{name[0].upcase}#{name[1..-1]}") do |stack_index|
|
25
|
+
|
26
|
+
a = @operands_stack.pop
|
27
|
+
b = @operands_stack.pop
|
28
|
+
|
29
|
+
res = a.to_boolean.send(operator.to_sym, b.to_boolean).to_s
|
30
|
+
@operands_stack.push res
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def comp_func(name, operator)
|
35
|
+
add_func(name.to_s)
|
36
|
+
|
37
|
+
define_method("evaluate#{name[0].upcase}#{name[1..-1]}") do |stack_index|
|
38
|
+
a = @operands_stack.pop
|
39
|
+
b = @operands_stack.pop
|
40
|
+
|
41
|
+
if( a.class == b.class ) #we can compare string with string and numeric with numeric only
|
42
|
+
@operands_stack.push b.send(operator.to_sym, a).to_s
|
43
|
+
else
|
44
|
+
@operands_stack.push 'false'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|