railsbytes 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bd60a4ca3df618ee9064620d1688fd2bcf9677a16ff69536bdd566f9b36fdf5e
4
+ data.tar.gz: b2fd5df143412a6115551d278df409f6b9ad39d6e5be95eef0c571155560d30f
5
+ SHA512:
6
+ metadata.gz: 3dc266f5e2138af18b27a6690422057fa7d01581bbe881bf85e3d0d2fa19f2f8346568b20634a780478b75d770b7d3a76f1c79b52d148e6d111d33b4605e8fe5
7
+ data.tar.gz: bd1c98b85e6c6be9a0f3e2b5453a37b8c686e1d193103713776080dd6e8e55ee3314a8605d29e6577ac09b0783c48d21dc93a699c1ca156079380cea2299b18b
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.gem
10
+ Gemfile.lock
@@ -0,0 +1,53 @@
1
+ Metrics/AbcSize:
2
+ Max: 200
3
+
4
+ Metrics/BlockLength:
5
+ Max: 100
6
+
7
+ Metrics/ClassLength:
8
+ Max: 300
9
+
10
+ Metrics/MethodLength:
11
+ Max: 100
12
+
13
+ Metrics/CyclomaticComplexity:
14
+ Max: 10
15
+
16
+ Metrics/PerceivedComplexity:
17
+ Max: 10
18
+
19
+ Layout/LineLength:
20
+ Max: 180
21
+
22
+ Layout/EmptyLinesAroundAttributeAccessor:
23
+ Enabled: true
24
+
25
+ Layout/SpaceAroundMethodCallOperator:
26
+ Enabled: true
27
+
28
+ Lint/RaiseException:
29
+ Enabled: true
30
+
31
+ Lint/StructNewOverride:
32
+ Enabled: true
33
+
34
+ Lint/DeprecatedOpenSSLConstant:
35
+ Enabled: true
36
+
37
+ Style/Documentation:
38
+ Enabled: false
39
+
40
+ Style/HashEachMethods:
41
+ Enabled: true
42
+
43
+ Style/HashTransformKeys:
44
+ Enabled: true
45
+
46
+ Style/HashTransformValues:
47
+ Enabled: true
48
+
49
+ Style/ExponentialNotation:
50
+ Enabled: true
51
+
52
+ Style/SlicingWithRange:
53
+ Enabled: true
@@ -0,0 +1 @@
1
+ 2.7.0
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Marco Roth
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,37 @@
1
+ # Railsbytes CLI
2
+
3
+ This Gem is a proof-of-concept CLI to apply [Railsbytes.com](https://railsbytes.com) templates to your Rails application.
4
+
5
+
6
+ ## Installation
7
+
8
+ Install it with:
9
+
10
+ $ gem install railsbytes
11
+
12
+ ## Usage
13
+
14
+ $ railsbytes install NAME
15
+
16
+ Where `NAME` is the template you want to search for on Railsbytes.com.
17
+
18
+ ### Example
19
+
20
+ This example would apply the tailwind template to your Rails application:
21
+
22
+ $ railsbytes install tailwind
23
+
24
+ ## Development
25
+
26
+ 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.
27
+
28
+ 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).
29
+
30
+ ## Contributing
31
+
32
+ Bug reports and pull requests are welcome on GitHub at https://github.com/marcoroth/railsbytes.
33
+
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -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,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'railsbytes'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ 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,19 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ lib_path = File.expand_path('../lib', __dir__)
5
+ $LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
6
+
7
+ require 'railsbytes/cli'
8
+
9
+ Signal.trap('INT') do
10
+ warn("\n#{caller.join("\n")}: interrupted")
11
+ exit(1)
12
+ end
13
+
14
+ begin
15
+ Railsbytes::CLI.start
16
+ rescue Railsbytes::CLI::Error => e
17
+ puts "ERROR: #{e.message}"
18
+ exit 1
19
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'railsbytes/version'
4
+
5
+ module Railsbytes
6
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+
5
+ module Railsbytes
6
+ class CLI < Thor
7
+ include Thor::Actions
8
+
9
+ desc 'version', 'railsbytes version'
10
+ def version
11
+ require_relative 'version'
12
+ puts "v#{Railsbytes::VERSION}"
13
+ end
14
+ map %w[--version -v] => :version
15
+
16
+ desc 'install NAME', 'Apply a Railsbytes template to your Rails app'
17
+ def install(name)
18
+ require_relative 'commands/install'
19
+ Railsbytes::Commands::Install.new(name).execute
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'forwardable'
4
+
5
+ module Railsbytes
6
+ class Command
7
+ extend Forwardable
8
+
9
+ def_delegators :command, :run
10
+
11
+ # Execute this command
12
+ #
13
+ # @api public
14
+ def execute(*)
15
+ raise(
16
+ NotImplementedError,
17
+ "#{self.class}##{__method__} must be implemented"
18
+ )
19
+ end
20
+
21
+ # The interactive prompt
22
+ #
23
+ # @see http://www.rubydoc.info/gems/tty-prompt
24
+ #
25
+ # @api public
26
+ def prompt(**options)
27
+ require 'tty-prompt'
28
+ TTY::Prompt.new(options)
29
+ end
30
+
31
+ # The external commands runner
32
+ #
33
+ # @see http://www.rubydoc.info/gems/tty-command
34
+ #
35
+ # @api public
36
+ def command(**options)
37
+ require 'tty-command'
38
+ TTY::Command.new(options)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lhc'
4
+ require 'json'
5
+ require 'thor'
6
+
7
+ require 'tty-spinner'
8
+ require 'tty-box'
9
+
10
+ require_relative '../command'
11
+
12
+ module Railsbytes
13
+ module Commands
14
+ class Install < Railsbytes::Command
15
+ include Thor::Actions
16
+
17
+ TEMPLATES = [
18
+ { value: 'X8Bsjx', name: 'devise' },
19
+ { value: 'x9Qsqx', name: 'bootstrap' },
20
+ { value: 'VMysyV', name: 'stimulus_reflex' },
21
+ { value: 'z5OsqV', name: 'tailwind' }
22
+ ].freeze
23
+
24
+ def initialize(name)
25
+ @name = name
26
+ end
27
+
28
+ def execute(*)
29
+ puts ''
30
+
31
+ spinner = TTY::Spinner.new(":spinner Searching for '#{@name}' templates on railsbytes.com", format: :bouncing_ball)
32
+ spinner.auto_spin
33
+ sleep 0.5
34
+ spinner.stop
35
+
36
+ template_id = prompt.select("\nAwesome! Found the following templates:", TEMPLATES)
37
+ template = TEMPLATES.find { |t| t[:value] == template_id }
38
+ script = LHC.get("https://railsbytes.com/script/#{template_id}").body
39
+
40
+ puts ''
41
+ print TTY::Box.info(
42
+ script,
43
+ title: {
44
+ top_left: "Template: #{template[:name]}",
45
+ bottom_right: "id: #{template_id}"
46
+ },
47
+ style: {
48
+ fg: :white,
49
+ bg: :bright_black,
50
+ border: {
51
+ fg: :white,
52
+ bg: :bright_black
53
+ }
54
+ }
55
+ )
56
+ puts ''
57
+
58
+ install = prompt.yes?("Do you want apply this template to your Rails app '#{Dir.pwd}'?", default: false)
59
+
60
+ return unless install
61
+
62
+ command.run("rails app:template LOCATION=\"https://railsbytes.com/script/#{template_id}\"")
63
+ rescue TTY::Reader::InputInterrupt
64
+ puts "\nAborting..."
65
+ exit(0)
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Railsbytes
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/railsbytes/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'railsbytes'
7
+ spec.version = Railsbytes::VERSION
8
+ spec.authors = ['Marco Roth']
9
+ spec.email = ['marco.roth@intergga.ch']
10
+ spec.summary = 'CLI to apply Railsbytes templates to your Rails application'
11
+ spec.description = spec.summary
12
+ spec.homepage = 'https://github.com/marcoroth/railsbytes'
13
+ spec.license = 'MIT'
14
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
15
+
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata['source_code_uri'] = 'https://github.com/marcoroth/railsbytes'
18
+
19
+ spec.files = Dir.chdir(File.expand_path(__dir__)) 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.add_dependency 'lhc', '~> 11.1'
28
+ spec.add_dependency 'thor', '~> 1.0'
29
+ spec.add_dependency 'tty-box', '~> 0.5'
30
+ spec.add_dependency 'tty-command', '~> 0.9'
31
+ spec.add_dependency 'tty-prompt', '~> 0.21'
32
+ spec.add_dependency 'tty-spinner', '~> 0.9'
33
+
34
+ spec.add_development_dependency 'bundler', '~> 2.0'
35
+ spec.add_development_dependency 'rake', '~> 13.0'
36
+ spec.add_development_dependency 'rubocop', '~> 0.84'
37
+ end
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: railsbytes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Marco Roth
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-06-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lhc
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '11.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '11.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: tty-box
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.5'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: tty-command
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.9'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.9'
69
+ - !ruby/object:Gem::Dependency
70
+ name: tty-prompt
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.21'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.21'
83
+ - !ruby/object:Gem::Dependency
84
+ name: tty-spinner
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.9'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.9'
97
+ - !ruby/object:Gem::Dependency
98
+ name: bundler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '13.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '13.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.84'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.84'
139
+ description: CLI to apply Railsbytes templates to your Rails application
140
+ email:
141
+ - marco.roth@intergga.ch
142
+ executables:
143
+ - railsbytes
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - ".gitignore"
148
+ - ".rubocop.yml"
149
+ - ".ruby-version"
150
+ - Gemfile
151
+ - LICENSE.txt
152
+ - README.md
153
+ - Rakefile
154
+ - bin/console
155
+ - bin/setup
156
+ - exe/railsbytes
157
+ - lib/railsbytes.rb
158
+ - lib/railsbytes/cli.rb
159
+ - lib/railsbytes/command.rb
160
+ - lib/railsbytes/commands/install.rb
161
+ - lib/railsbytes/version.rb
162
+ - railsbytes.gemspec
163
+ homepage: https://github.com/marcoroth/railsbytes
164
+ licenses:
165
+ - MIT
166
+ metadata:
167
+ homepage_uri: https://github.com/marcoroth/railsbytes
168
+ source_code_uri: https://github.com/marcoroth/railsbytes
169
+ post_install_message:
170
+ rdoc_options: []
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: 2.3.0
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubygems_version: 3.1.2
185
+ signing_key:
186
+ specification_version: 4
187
+ summary: CLI to apply Railsbytes templates to your Rails application
188
+ test_files: []