rollout-ui 0.1.0 → 0.2.0

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
2
  SHA256:
3
- metadata.gz: b51e55b90f5c713ca98c9726a869a7302772016df6e02bd44b9796d8ff3a0501
4
- data.tar.gz: 61572ff1cc7d32ce2dbf9dd970f0d4b5c4f769467257106c2e9172ca5a4d9d29
3
+ metadata.gz: e342dafb4fb3a868d96da458d3227d4d177d168a28e640d3ba6eb4e85caa3393
4
+ data.tar.gz: f7d5778665b1da78012854c306b1df04797fe924fa5733d68de3bd1428ce8c84
5
5
  SHA512:
6
- metadata.gz: 38efbeae497f9277c0e9cf8ffb74c61b51dc7cfb15e8caa19f1a290e20f8a40a1cd68212a0d4867758c157781ed667a4b726a13fada39ccfe1047be7687ee749
7
- data.tar.gz: 4cc4ec83d9dbc3e7f29aab4c15b6c05197af5c57f7182caf13338d5f805b6f6dd2cd866fbefc29d63b53efb10201f69cca3cadaae557a7eb0affdea90576b235
6
+ metadata.gz: b91d583fecd5e7b9ba6d0d1adfddec7e5a8894e943d80c9c258bb7399d40fc1687cdbe0b72129b111e5c3dfb162d1fc445784660e09c37adeaa8f95165956658
7
+ data.tar.gz: cf24e7f1bb6b083bad9fd4e30f1838cef1b746f662eb3b94f5de28beb69485f2729a38f302b30a3b807505a22259eb951564ef24bf25bb075af56206b2b57ab2
data/.gitignore CHANGED
@@ -9,3 +9,6 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ Gemfile.lock
14
+ *.gem
@@ -0,0 +1 @@
1
+ 2.6.6
data/Gemfile CHANGED
@@ -4,3 +4,5 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in rollout-ui.gemspec
6
6
  gemspec
7
+
8
+
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Rollout::Ui
1
+ # Rollout::UI
2
2
 
3
- Minimalistic UI for the [rollout](https://github.com/fetlife/rollout) gem that
3
+ Minimalist UI for the [rollout](https://github.com/fetlife/rollout) gem that
4
4
  you can just mount as a Rack app and it will just work.
5
5
 
6
6
  ![Index Page](./screenshot_index.png)
@@ -83,6 +83,21 @@ end
83
83
 
84
84
  Bug reports and pull requests are welcome on GitHub at https://github.com/fetlife/rollout-ui.
85
85
 
86
+ To run this project for development in isolation:
87
+
88
+ ```sh
89
+ bundle install
90
+ bundle exec rerun rackup
91
+ ```
92
+
93
+ And visit [http://localhost:9292/](http://localhost:9292/).
94
+
95
+ Alternatively you can also configure which Redis with:
96
+
97
+ ```sh
98
+ REDIS_HOST=localhost REDIS_PORT=6379 REDIS_DB=10 be rerun rackup
99
+ ```
100
+
86
101
  ## License
87
102
 
88
103
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,23 @@
1
+ # Development Rackup config you can run with `bundle exec rerun rackup`
2
+
3
+ require_relative 'lib/rollout/ui'
4
+ require 'redis'
5
+
6
+ redis_host = ENV.fetch('REDIS_HOST', 'localhost')
7
+ redis_port = ENV.fetch('REDIS_PORT', '6379')
8
+ redis_db = ENV.fetch('REDIS_DB', '10')
9
+
10
+ redis = Redis.new(host: redis_host, port: redis_port, db: redis_db)
11
+ rollout = Rollout.new(redis, logging: { history_length: 100, global: true })
12
+
13
+ %i[employees developers subscribers].each do |group|
14
+ rollout.define_group(group) { }
15
+ end
16
+
17
+ Rollout::UI.configure do
18
+ instance { rollout }
19
+ actor { "JohnDoe" }
20
+ actor_url { "https://www.youtube.com/watch?v=fbGkxcY7YFU" }
21
+ end
22
+
23
+ run Rollout::UI::Web.new
@@ -39,7 +39,7 @@ module Rollout::UI
39
39
  end
40
40
 
41
41
  def defined?(key)
42
- @blocks.present? && @blocks.key?(key)
42
+ !@blocks.nil? && @blocks.key?(key)
43
43
  end
44
44
  end
45
45
  end
@@ -10,7 +10,7 @@ module Rollout::UI
10
10
  end
11
11
 
12
12
  def index_path
13
- request.script_name
13
+ "#{request.script_name}/"
14
14
  end
15
15
 
16
16
  def new_feature_path
@@ -32,7 +32,17 @@ module Rollout::UI
32
32
  def current_user
33
33
  @current_user ||= begin
34
34
  id = request.session["warden.user.user.key"].try(:[], 0).try(:[], 0)
35
- User.find_by(id: id) if id.present?
35
+ User.find_by(id: id) unless id.nil?
36
+ end
37
+ end
38
+
39
+ def with_rollout_context(rollout, context)
40
+ if rollout.respond_to?(:logging)
41
+ rollout.logging.with_context(context) do
42
+ yield
43
+ end
44
+ else
45
+ yield
36
46
  end
37
47
  end
38
48
 
@@ -1,5 +1,5 @@
1
1
  class Rollout
2
2
  module UI
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -26,7 +26,7 @@
26
26
  - if event.name == "update"
27
27
  - if event.context && event.context[:actor]
28
28
  - if config.defined?(:actor_url)
29
- a.underline> href=config.get(:actor_url, event.context[:actor])
29
+ a.underline> href=config.get(:actor_url, event.context[:actor]) target='_blank'
30
30
  = event.context[:actor]
31
31
  - else
32
32
  ' #{event.context[:actor]}
@@ -1,4 +1,5 @@
1
- a.text-sm.text-blue-600(href=index_path class='hover:text-blue-700 hover:underline') ← back to overview
1
+ a.text-sm.text-blue-600(href=index_path class='hover:text-blue-700 hover:underline')
2
+ ' ← back to overview
2
3
 
3
4
  h2.font-semibold.text-xl.text-gray-500.pt-12
4
5
  = @feature.name
@@ -20,7 +21,7 @@ form.p-6.bg-gray-100.max-w-lg.w-full.text-sm.rounded-sm action=feature_path(@fea
20
21
  | Groups
21
22
  span.ml-1.text-gray-400
22
23
  | (multi-select)
23
- select.block.appearance-none.w-full.bg-white.border.border-gray-300.px-4.py-3.rounded-sm.leading-relaxed(name="groups[]" id='groups' multiple=true size=$rollout.groups.count)
24
+ select.block.appearance-none.w-full.bg-white.border.border-gray-300.px-4.py-3.rounded-sm.leading-relaxed(name="groups[]" id='groups' multiple=true size=(@rollout.groups.count + 1))
24
25
  option.py-1.px-1(value='' selected=(@feature.groups.count == 0))
25
26
  = '(none)'
26
27
  - @rollout.groups.each do |group|
@@ -38,9 +39,7 @@ form.p-6.bg-gray-100.max-w-lg.w-full.text-sm.rounded-sm action=feature_path(@fea
38
39
  value=@feature.percentage
39
40
  class='hover:border-gray-500'
40
41
  type='number'
41
- min='0'
42
- max='100'
43
- step='10'
42
+ step='0.1'
44
43
  )
45
44
 
46
45
  .mb-5
@@ -38,7 +38,7 @@ module Rollout::UI
38
38
  rollout = config.get(:instance)
39
39
  actor = config.get(:actor, scope: self)
40
40
 
41
- rollout.logging.with_context(actor: actor) do
41
+ with_rollout_context(rollout, actor: actor) do
42
42
  rollout.with_feature(params[:feature_name]) do |feature|
43
43
  feature.percentage = params[:percentage].to_f.clamp(0.0, 100.0)
44
44
  feature.groups = (params[:groups] || []).reject(&:empty?).map(&:to_sym)
@@ -56,7 +56,7 @@ module Rollout::UI
56
56
  rollout = config.get(:instance)
57
57
  actor = config.get(:actor, scope: self)
58
58
 
59
- rollout.logging.with_context(actor: actor) do
59
+ with_rollout_context(rollout, actor: actor) do
60
60
  rollout.with_feature(params[:feature_name]) do |feature|
61
61
  feature.percentage = params[:percentage].to_f.clamp(0.0, 100.0)
62
62
  end
@@ -1,32 +1,33 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
1
+ lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "rollout/ui/version"
3
+ require 'rollout/ui/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "rollout-ui"
6
+ spec.name = 'rollout-ui'
8
7
  spec.version = Rollout::UI::VERSION
9
- spec.authors = ["FetLife"]
10
- spec.email = ["dev@fetlife.com"]
8
+ spec.authors = ['FetLife']
9
+ spec.email = ['dev@fetlife.com']
11
10
 
12
11
  spec.summary = %q{}
13
12
  spec.description = %q{}
14
- spec.homepage = "https://github.com/fetlife/rollout-ui"
15
- spec.license = "MIT"
13
+ spec.homepage = 'https://github.com/fetlife/rollout-ui'
14
+ spec.license = 'MIT'
16
15
 
17
16
  # Specify which files should be added to the gem when it is released.
18
17
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
18
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
19
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
20
  end
22
- spec.bindir = "exe"
21
+ spec.bindir = 'exe'
23
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
- spec.require_paths = ["lib"]
23
+ spec.require_paths = ['lib']
25
24
 
26
- spec.add_dependency "rollout", "~> 2.5"
27
- spec.add_dependency "sinatra", "~> 2.0"
25
+ spec.add_dependency 'rollout', '~> 2.5'
26
+ spec.add_dependency 'sinatra', '~> 2.0'
27
+ spec.add_dependency 'slim', '~> 4.0'
28
28
 
29
- spec.add_development_dependency "bundler", "~> 1.17"
30
- spec.add_development_dependency "rake", "~> 10.0"
31
- spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency 'bundler', '~> 1.17'
30
+ spec.add_development_dependency 'rake', '~> 10.0'
31
+ spec.add_development_dependency 'rspec', '~> 3.0'
32
+ spec.add_development_dependency 'rerun', '~> 0.13'
32
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollout-ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - FetLife
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-21 00:00:00.000000000 Z
11
+ date: 2020-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rollout
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: slim
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '4.0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +94,20 @@ dependencies:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
96
  version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rerun
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.13'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.13'
83
111
  description: ''
84
112
  email:
85
113
  - dev@fetlife.com
@@ -89,12 +117,14 @@ extra_rdoc_files: []
89
117
  files:
90
118
  - ".gitignore"
91
119
  - ".rspec"
120
+ - ".ruby-version"
92
121
  - Gemfile
93
122
  - LICENSE.txt
94
123
  - README.md
95
124
  - Rakefile
96
125
  - bin/console
97
126
  - bin/setup
127
+ - config.ru
98
128
  - lib/rollout/ui.rb
99
129
  - lib/rollout/ui/config.rb
100
130
  - lib/rollout/ui/helpers.rb