bario 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fafa1b73da15e80e4b4c05fc625a090134939c62
4
+ data.tar.gz: cb21ca5c529072919e78dffa9d8d10494a30fb68
5
+ SHA512:
6
+ metadata.gz: 1ae76decfe7ca7fc18f97f08c31c8bbb3a1cc73195b3321b3daca3652a4f39be0d32e96257988c80f66f717deb4e142a190df24fc9b878e169de818e7cfb0192
7
+ data.tar.gz: 8d5253397711b402a7dd763a1aee1dd0fc0c81ac1c52f4d4cfc3fdb45556e680fe4df365d3780f0e852679c536e6e6a9712a5f2fb79a10f410d97f55044e6026
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .ruby-version
13
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,16 @@
1
+ require: rubocop-rspec
2
+
3
+ AllCops:
4
+ DisplayCopNames: true
5
+ TargetRubyVersion: 2.2
6
+
7
+ Style/StringLiterals:
8
+ EnforcedStyle: double_quotes
9
+
10
+ Metrics/BlockLength:
11
+ Exclude:
12
+ - Guardfile
13
+ - "*.gemspec"
14
+ - Rakefile
15
+ - "**/*.rake"
16
+ - spec/**/*.rb
@@ -0,0 +1,20 @@
1
+ sudo: false
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.2.8
6
+ - 2.3.5
7
+ - 2.4.2
8
+ - ruby-head
9
+ - jruby-head
10
+ before_install: gem install bundler -v 1.16.0
11
+
12
+ services:
13
+ - redis-server
14
+
15
+ script:
16
+ - bundle exec rspec
17
+ - bundle exec rubocop
18
+
19
+ notifications:
20
+ email: false
@@ -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 ceritium@gmail.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,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in bario.gemspec
8
+ gemspec
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A sample Guardfile
4
+ # More info at https://github.com/guard/guard#readme
5
+
6
+ ## Uncomment and set this to only include directories you want to watch
7
+ # directories %w(app lib config test spec features) \
8
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
9
+
10
+ ## Note: if you are using the `directories` clause above and you are not
11
+ ## watching the project directory ('.'), then you will want to move
12
+ ## the Guardfile to a watched dir and symlink it back, e.g.
13
+ #
14
+ # $ mkdir config
15
+ # $ mv Guardfile config/
16
+ # $ ln -s config/Guardfile .
17
+ #
18
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
19
+
20
+ # Note: The cmd option is now required due to the increasing number of ways
21
+ # rspec may be run, below are examples of the most common uses.
22
+ # * bundler: 'bundle exec rspec'
23
+ # * bundler binstubs: 'bin/rspec'
24
+ # * spring: 'bin/rspec' (This will use spring if running and you have
25
+ # installed the spring binstubs per the docs)
26
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
27
+ # * 'just' rspec: 'rspec'
28
+
29
+ guard :rspec, cmd: "bundle exec rspec" do
30
+ require "guard/rspec/dsl"
31
+ dsl = Guard::RSpec::Dsl.new(self)
32
+
33
+ # Feel free to open issues for suggestions and improvements
34
+
35
+ # RSpec files
36
+ rspec = dsl.rspec
37
+ watch(rspec.spec_helper) { rspec.spec_dir }
38
+ watch(rspec.spec_support) { rspec.spec_dir }
39
+ watch(rspec.spec_files)
40
+
41
+ # Ruby files
42
+ ruby = dsl.ruby
43
+ dsl.watch_spec_files_for(ruby.lib_files)
44
+
45
+ # Rails files
46
+ rails = dsl.rails(view_extensions: %w[erb haml slim])
47
+ dsl.watch_spec_files_for(rails.app_files)
48
+ dsl.watch_spec_files_for(rails.views)
49
+
50
+ watch(rails.controllers) do |m|
51
+ [
52
+ rspec.spec.call("routing/#{m[1]}_routing"),
53
+ rspec.spec.call("controllers/#{m[1]}_controller"),
54
+ rspec.spec.call("acceptance/#{m[1]}")
55
+ ]
56
+ end
57
+
58
+ # Rails config changes
59
+ watch(rails.spec_helper) { rspec.spec_dir }
60
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
61
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
62
+
63
+ # Capybara features specs
64
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
65
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
66
+
67
+ # Turnip features and steps
68
+ watch(%r{^spec/acceptance/(.+)\.feature$})
69
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
70
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
71
+ end
72
+ end
73
+
74
+ guard :rubocop do
75
+ watch(/.+\.rb$/)
76
+ watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
77
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Jose Galisteo
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,95 @@
1
+ # Bario
2
+
3
+ [![codecov](https://codecov.io/gh/ceritium/bario/branch/master/graph/badge.svg)](https://codecov.io/gh/ceritium/bario)
4
+
5
+ Bario means [Barium](https://en.wikipedia.org/wiki/Barium) in spanish.
6
+
7
+ ![Barium](https://upload.wikimedia.org/wikipedia/commons/1/16/Barium_unter_Argon_Schutzgas_Atmosph%C3%A4re.jpg)
8
+
9
+ This gem aim to provide a simple interface to track the progress of your process like background jobs, scripts, cron jobs... with a kind progress bars backed by redis.
10
+
11
+
12
+ ## Usage
13
+
14
+ Examples:
15
+
16
+ ```ruby
17
+ # Create a bar with 100 as total
18
+ b1 = Bario::Bar.create(total: 100)
19
+
20
+ # Increment a unit
21
+ b1.increment
22
+
23
+ # Increment 10 units
24
+ b1.increment(10)
25
+
26
+ # Decrement
27
+ b1.decrement
28
+
29
+ # Create a nested bar
30
+ b2 = b1.add_bar(total: 10)
31
+ b2.increment
32
+
33
+ # Find a bar
34
+ b3 = Bario::Bar.find(b1.id)
35
+
36
+ # List all bars
37
+ Bario::Bar.all
38
+
39
+ # Delete a bar (and nested bars)
40
+ b3.delete
41
+
42
+ # You can also name a bar, usefull to identify it in the web panel.
43
+ foo = Bario::Bar.create(name: "foo")
44
+
45
+ # Attributes of a bar
46
+ foo.inspect #=>
47
+ #<Bario::Bar:70234519614100 id: 12, name: foo, total: 100, current: 0, root: true, created_at: 2017-11-26 21:29:30 UTC, updated_at: 2017-11-26 21:29:30 UTC>
48
+ ```
49
+
50
+ ## The frontend
51
+
52
+ ![screen shot 2017-11-23 at 23 45 39](https://user-images.githubusercontent.com/16633/33189997-8c95d226-d0a8-11e7-8a62-288e50e73ae8.png)
53
+
54
+ ### Standalone
55
+
56
+ If you've installed Bario as a gem running the front end standalone is easy:
57
+
58
+ ```bash
59
+ $ bario-web start
60
+ ```
61
+
62
+ ```bash
63
+ $ bario-web --redis redis://localhost:6379/0 start
64
+ ```
65
+
66
+ For more options check the help:
67
+ ```bash
68
+ $ bario-web --help
69
+ ```
70
+
71
+ ### Rails 3 onwards
72
+
73
+ You can also mount Bario on a subpath in your existing Rails app by adding `require "bario/web"` to the top of your routes file or in an initializer then adding this to routes.rb:
74
+
75
+ ```ruby
76
+ mount Bario::Web => "/bario"
77
+ ```
78
+
79
+ ## Development
80
+
81
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
82
+
83
+ 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).
84
+
85
+ ## Contributing
86
+
87
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ceritium/bario. 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.
88
+
89
+ ## License
90
+
91
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
92
+
93
+ ## Code of Conduct
94
+
95
+ Everyone interacting in the Bario project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ceritium/bario/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "bario/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "bario"
9
+ spec.version = Bario::VERSION
10
+ spec.authors = ["Jose Galisteo"]
11
+ spec.email = ["ceritium@gmail.com"]
12
+
13
+ spec.summary = "Redis based nested progress bars "
14
+ spec.homepage = "https://github.com/ceritium/bario"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "bin"
21
+ spec.executables = ["bario-demo", "bario-web"]
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "ohm", "~> 3.0"
25
+ spec.add_dependency "sinatra"
26
+ spec.add_development_dependency "bundler", "~> 1.16"
27
+ spec.add_development_dependency "codecov"
28
+ spec.add_development_dependency "guard-rspec", "~> 4.7"
29
+ spec.add_development_dependency "guard-rubocop", "~> 1.0"
30
+ spec.add_development_dependency "rack-test"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+ spec.add_development_dependency "rubocop", "~> 0.51"
34
+ spec.add_development_dependency "rubocop-rspec", "~> 1.20"
35
+ spec.add_development_dependency "timecop"
36
+ end
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "bario"
6
+ require "bario/cli"
7
+
8
+ require "optparse"
9
+
10
+ parser = OptionParser.new do |opts|
11
+ opts.banner = "Usage: bario-demo [options]"
12
+ Bario::CLI.common(opts)
13
+ end
14
+
15
+ parser.parse!
16
+
17
+ threads = []
18
+ 3.times.each do |t1|
19
+ bar = Bario::Bar.create(name: "bar #{t1}")
20
+ threads << Thread.new do
21
+ 100.times do
22
+ bar.increment
23
+ sleep(1.0 / ((t1 + 1) * 2))
24
+ end
25
+ bar.delete
26
+ end
27
+
28
+ t1.times.each do |t2|
29
+ child = bar.add_bar(name: "bar > #{t2}")
30
+ threads << Thread.new do
31
+ 100.times do
32
+ child.increment
33
+ sleep(0.1)
34
+ end
35
+ child.delete
36
+ end
37
+ end
38
+ end
39
+
40
+ threads.map(&:join)
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "bario/web"
6
+ require "bario/cli"
7
+
8
+ require "optparse"
9
+
10
+ parser = OptionParser.new do |opts|
11
+ opts.banner = "Usage: bario-web [options] COMMAND"
12
+
13
+ opts = Bario::CLI.common(opts)
14
+
15
+ opts.separator ""
16
+ opts.separator "Commands:"
17
+ opts.separator " start Start the web server"
18
+ end
19
+
20
+ parser.parse!
21
+
22
+ case ARGV[0]
23
+ when "start"
24
+ Bario::Web.run!
25
+ else
26
+ puts parser.help
27
+ end