gloo 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.travis.yml +5 -0
  4. data/CODE_OF_CONDUCT.md +74 -0
  5. data/Gemfile +6 -0
  6. data/Gemfile.lock +139 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +43 -0
  9. data/Rakefile +12 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/exe/gloo +4 -0
  13. data/exe/o +4 -0
  14. data/gloo.gemspec +38 -0
  15. data/lib/gloo.rb +19 -0
  16. data/lib/gloo/app/args.rb +71 -0
  17. data/lib/gloo/app/engine.rb +158 -0
  18. data/lib/gloo/app/help.rb +29 -0
  19. data/lib/gloo/app/info.rb +21 -0
  20. data/lib/gloo/app/log.rb +58 -0
  21. data/lib/gloo/app/mode.rb +25 -0
  22. data/lib/gloo/app/settings.rb +125 -0
  23. data/lib/gloo/core/baseo.rb +28 -0
  24. data/lib/gloo/core/dictionary.rb +101 -0
  25. data/lib/gloo/core/event_manager.rb +46 -0
  26. data/lib/gloo/core/factory.rb +67 -0
  27. data/lib/gloo/core/gloo_system.rb +190 -0
  28. data/lib/gloo/core/heap.rb +42 -0
  29. data/lib/gloo/core/it.rb +30 -0
  30. data/lib/gloo/core/literal.rb +25 -0
  31. data/lib/gloo/core/obj.rb +222 -0
  32. data/lib/gloo/core/obj_finder.rb +35 -0
  33. data/lib/gloo/core/op.rb +33 -0
  34. data/lib/gloo/core/parser.rb +52 -0
  35. data/lib/gloo/core/pn.rb +134 -0
  36. data/lib/gloo/core/script.rb +37 -0
  37. data/lib/gloo/core/tokens.rb +123 -0
  38. data/lib/gloo/core/verb.rb +63 -0
  39. data/lib/gloo/expr/expression.rb +103 -0
  40. data/lib/gloo/expr/l_boolean.rb +29 -0
  41. data/lib/gloo/expr/l_integer.rb +29 -0
  42. data/lib/gloo/expr/l_string.rb +53 -0
  43. data/lib/gloo/expr/op_div.rb +20 -0
  44. data/lib/gloo/expr/op_minus.rb +20 -0
  45. data/lib/gloo/expr/op_mult.rb +20 -0
  46. data/lib/gloo/expr/op_plus.rb +22 -0
  47. data/lib/gloo/objs/basic/boolean.rb +113 -0
  48. data/lib/gloo/objs/basic/container.rb +50 -0
  49. data/lib/gloo/objs/basic/integer.rb +65 -0
  50. data/lib/gloo/objs/basic/script.rb +101 -0
  51. data/lib/gloo/objs/basic/string.rb +65 -0
  52. data/lib/gloo/objs/basic/text.rb +64 -0
  53. data/lib/gloo/objs/basic/untyped.rb +42 -0
  54. data/lib/gloo/objs/cli/colorize.rb +73 -0
  55. data/lib/gloo/objs/cli/confirm.rb +92 -0
  56. data/lib/gloo/objs/cli/prompt.rb +92 -0
  57. data/lib/gloo/objs/ctrl/each.rb +212 -0
  58. data/lib/gloo/objs/dev/git.rb +112 -0
  59. data/lib/gloo/objs/ror/erb.rb +109 -0
  60. data/lib/gloo/objs/ror/eval.rb +92 -0
  61. data/lib/gloo/objs/system/file_handle.rb +86 -0
  62. data/lib/gloo/objs/system/system.rb +120 -0
  63. data/lib/gloo/objs/web/http_get.rb +128 -0
  64. data/lib/gloo/objs/web/http_post.rb +127 -0
  65. data/lib/gloo/objs/web/slack.rb +126 -0
  66. data/lib/gloo/objs/web/teams.rb +117 -0
  67. data/lib/gloo/persist/file_loader.rb +171 -0
  68. data/lib/gloo/persist/file_saver.rb +43 -0
  69. data/lib/gloo/persist/file_storage.rb +43 -0
  70. data/lib/gloo/persist/persist_man.rb +90 -0
  71. data/lib/gloo/utils/words.rb +19 -0
  72. data/lib/gloo/verbs/alert.rb +42 -0
  73. data/lib/gloo/verbs/context.rb +52 -0
  74. data/lib/gloo/verbs/create.rb +52 -0
  75. data/lib/gloo/verbs/help.rb +69 -0
  76. data/lib/gloo/verbs/if.rb +56 -0
  77. data/lib/gloo/verbs/list.rb +85 -0
  78. data/lib/gloo/verbs/load.rb +39 -0
  79. data/lib/gloo/verbs/put.rb +62 -0
  80. data/lib/gloo/verbs/quit.rb +40 -0
  81. data/lib/gloo/verbs/run.rb +46 -0
  82. data/lib/gloo/verbs/save.rb +37 -0
  83. data/lib/gloo/verbs/show.rb +55 -0
  84. data/lib/gloo/verbs/tell.rb +47 -0
  85. data/lib/gloo/verbs/unless.rb +56 -0
  86. data/lib/gloo/verbs/version.rb +37 -0
  87. data/lib/run.rb +13 -0
  88. metadata +254 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: aa0507913bb322d98577252dce4f699185f09d2dc87dc4a8f80ea4fc71859fcc
4
+ data.tar.gz: 7539b9d58d14baeb60cd98cdea9c92f3330d00da5e1c743fd81aefc7246d03e8
5
+ SHA512:
6
+ metadata.gz: c1df92b449aeb3344d47fd8aa3d68b1b7e0ef9001444efbb66897038d8e189d435439c9844afa54948e19c2c161c31213e31ef5ea0573ea31429e30d2f718c51
7
+ data.tar.gz: '028f3fe632304b2e947f9955e42d1aa0b768384c9649a112dc47e2d4c2d69e034f586c8b10f0c416dd09f506ec814f8a61f0ca6c7bb2e442e8d0e85846a98d94'
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.gem
10
+ *.log
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.1
5
+ before_install: gem install bundler -v 1.16.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at eric.crane@mac.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in gloo.gemspec
6
+ gemspec
@@ -0,0 +1,139 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gloo (0.3.0)
5
+ activesupport (~> 5.2, >= 5.2.1)
6
+ chronic (~> 0.10, >= 0.10.2)
7
+ colorize (~> 0.8, >= 0.8.1)
8
+ tty (~> 0.8, >= 0.8.1)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activesupport (5.2.2)
14
+ concurrent-ruby (~> 1.0, >= 1.0.2)
15
+ i18n (>= 0.7, < 2)
16
+ minitest (~> 5.1)
17
+ tzinfo (~> 1.1)
18
+ chronic (0.10.2)
19
+ colorize (0.8.1)
20
+ concurrent-ruby (1.1.4)
21
+ diff-lcs (1.3)
22
+ equatable (0.5.0)
23
+ i18n (1.3.0)
24
+ concurrent-ruby (~> 1.0)
25
+ kramdown (1.16.2)
26
+ minitest (5.11.3)
27
+ necromancer (0.4.0)
28
+ pastel (0.7.2)
29
+ equatable (~> 0.5.0)
30
+ tty-color (~> 0.4.0)
31
+ rake (10.5.0)
32
+ rouge (3.3.0)
33
+ strings (0.1.4)
34
+ strings-ansi (~> 0.1.0)
35
+ unicode-display_width (~> 1.4.0)
36
+ unicode_utils (~> 1.4.0)
37
+ strings-ansi (0.1.0)
38
+ thor (0.20.3)
39
+ thread_safe (0.3.6)
40
+ timers (4.2.0)
41
+ tty (0.9.1)
42
+ bundler (~> 1.16, < 2.0)
43
+ equatable (~> 0.5)
44
+ pastel (~> 0.7.2)
45
+ thor (~> 0.20.0)
46
+ tty-box (~> 0.3.0)
47
+ tty-color (~> 0.4)
48
+ tty-command (~> 0.8.0)
49
+ tty-config (~> 0.3.0)
50
+ tty-cursor (~> 0.6)
51
+ tty-editor (~> 0.5.0)
52
+ tty-file (~> 0.7.0)
53
+ tty-font (~> 0.2.0)
54
+ tty-markdown (~> 0.5.0)
55
+ tty-pager (~> 0.12.0)
56
+ tty-pie (~> 0.1.0)
57
+ tty-platform (~> 0.2.0)
58
+ tty-progressbar (~> 0.16.0)
59
+ tty-prompt (~> 0.18.0)
60
+ tty-screen (~> 0.6)
61
+ tty-spinner (~> 0.9.0)
62
+ tty-table (~> 0.10.0)
63
+ tty-tree (~> 0.2.0)
64
+ tty-which (~> 0.4)
65
+ tty-box (0.3.0)
66
+ pastel (~> 0.7.2)
67
+ strings (~> 0.1.4)
68
+ tty-cursor (~> 0.6.0)
69
+ tty-color (0.4.3)
70
+ tty-command (0.8.2)
71
+ pastel (~> 0.7.0)
72
+ tty-config (0.3.0)
73
+ tty-cursor (0.6.0)
74
+ tty-editor (0.5.0)
75
+ tty-prompt (~> 0.18)
76
+ tty-which (~> 0.4)
77
+ tty-file (0.7.0)
78
+ diff-lcs (~> 1.3)
79
+ pastel (~> 0.7.2)
80
+ tty-prompt (~> 0.18)
81
+ tty-font (0.2.0)
82
+ tty-markdown (0.5.0)
83
+ kramdown (~> 1.16.2)
84
+ pastel (~> 0.7.2)
85
+ rouge (~> 3.3)
86
+ strings (~> 0.1.4)
87
+ tty-color (~> 0.4)
88
+ tty-screen (~> 0.6)
89
+ tty-pager (0.12.0)
90
+ strings (~> 0.1.4)
91
+ tty-screen (~> 0.6)
92
+ tty-which (~> 0.4)
93
+ tty-pie (0.1.0)
94
+ pastel (~> 0.7.2)
95
+ tty-cursor (~> 0.6.0)
96
+ tty-platform (0.2.0)
97
+ tty-progressbar (0.16.0)
98
+ strings-ansi (~> 0.1.0)
99
+ tty-cursor (~> 0.6.0)
100
+ tty-screen (~> 0.6.4)
101
+ unicode-display_width (~> 1.3)
102
+ tty-prompt (0.18.1)
103
+ necromancer (~> 0.4.0)
104
+ pastel (~> 0.7.0)
105
+ timers (~> 4.0)
106
+ tty-cursor (~> 0.6.0)
107
+ tty-reader (~> 0.5.0)
108
+ tty-reader (0.5.0)
109
+ tty-cursor (~> 0.6.0)
110
+ tty-screen (~> 0.6.4)
111
+ wisper (~> 2.0.0)
112
+ tty-screen (0.6.5)
113
+ tty-spinner (0.9.0)
114
+ tty-cursor (~> 0.6.0)
115
+ tty-table (0.10.0)
116
+ equatable (~> 0.5.0)
117
+ necromancer (~> 0.4.0)
118
+ pastel (~> 0.7.2)
119
+ strings (~> 0.1.0)
120
+ tty-screen (~> 0.6.4)
121
+ tty-tree (0.2.0)
122
+ tty-which (0.4.0)
123
+ tzinfo (1.2.5)
124
+ thread_safe (~> 0.1)
125
+ unicode-display_width (1.4.1)
126
+ unicode_utils (1.4.0)
127
+ wisper (2.0.0)
128
+
129
+ PLATFORMS
130
+ ruby
131
+
132
+ DEPENDENCIES
133
+ bundler (~> 1.16)
134
+ gloo!
135
+ minitest (~> 5.0)
136
+ rake (~> 10.0)
137
+
138
+ BUNDLED WITH
139
+ 1.16.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Eric Crane
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,43 @@
1
+ # Gloo
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/gloo`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'gloo'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install gloo
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gloo. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the OutlineScript project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/gloo/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ ENV[ 'GLOO_ENV' ] = "TEST"
6
+
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "gloo"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gloo'
4
+ Gloo.run
data/exe/o ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gloo'
4
+ Gloo.run
@@ -0,0 +1,38 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "gloo/app/info"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gloo"
8
+ spec.version = Gloo::App::Info::VERSION
9
+ spec.authors = ["Eric Crane"]
10
+ spec.email = ["eric.crane@mac.com"]
11
+
12
+ spec.summary = %q{Gloo scripting language. A scripting language built on ruby.}
13
+ spec.description = %q{A scripting languge to keep it all together.}
14
+ spec.homepage = "http://github.com/ecrane/gloo"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.executables << "o"
28
+ spec.executables << "gloo"
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.16"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "minitest", "~> 5.0"
33
+
34
+ spec.add_dependency "activesupport", "~> 5.2", '>= 5.2.1'
35
+ spec.add_dependency "chronic", "~> 0.10", '>= 0.10.2'
36
+ spec.add_dependency "tty", "~> 0.8", '>= 0.8.1'
37
+ spec.add_dependency "colorize", "~> 0.8", '>= 0.8.1'
38
+ end
@@ -0,0 +1,19 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
+ #
4
+ # Start the Engine.
5
+ #
6
+
7
+ path = File.dirname( File.absolute_path( __FILE__ ) )
8
+ root = File.join( path, "gloo", "**/*.rb" )
9
+ Dir.glob( root ) { |ruby_file| require ruby_file }
10
+
11
+ module Gloo
12
+
13
+ def self.run
14
+ params = []
15
+ ( params << "--cli" ) if ARGV.count == 0
16
+ Gloo::App::Engine.new( params ).start
17
+ end
18
+
19
+ end
@@ -0,0 +1,71 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
+ #
4
+ # Arguments (parameters) used to specify functionality.
5
+ # These might have come from the CLI or as parameters
6
+ # in the constructor.
7
+ #
8
+ require 'active_support'
9
+ require 'colorize'
10
+
11
+ module Gloo
12
+ module App
13
+ class Args
14
+
15
+ attr_reader :switches, :files
16
+
17
+ def initialize( params = [] )
18
+ @switches = []
19
+ @files = []
20
+
21
+ params.each { |o| process_one_arg( o ) }
22
+ ARGV.each { |o| process_one_arg( o ) }
23
+ end
24
+
25
+ # Was the --quiet arg passed?
26
+ def quiet?
27
+ return @switches.include?( "quiet" )
28
+ end
29
+
30
+ #
31
+ # Detect the mode to be run in.
32
+ # Start by seeing if a mode is specified.
33
+ # Then look for the presence of files.
34
+ # Then finally use the default: embedded mode.
35
+ #
36
+ def detect_mode
37
+ if ENV[ 'GLOO_ENV' ] == "test"
38
+ mode = Mode::TEST
39
+ elsif @switches.include?( "version" )
40
+ mode = Mode::VERSION
41
+ elsif @switches.include?( "help" )
42
+ mode = Mode::HELP
43
+ elsif @switches.include?( "cli" )
44
+ mode = Mode::CLI
45
+ elsif @switches.include?( "embed" )
46
+ mode = Mode::EMBED
47
+ elsif @files.count > 0
48
+ mode = Mode::SCRIPT
49
+ else
50
+ mode = Mode.default_mode
51
+ end
52
+ $log.debug "running in #{mode} mode"
53
+
54
+ return mode
55
+ end
56
+
57
+
58
+ private
59
+
60
+ # Process one argument or parameter.
61
+ def process_one_arg arg
62
+ if arg.start_with? "--"
63
+ switches << arg[2..-1]
64
+ else
65
+ files << arg
66
+ end
67
+ end
68
+
69
+ end
70
+ end
71
+ end