gorails 0.1.0 → 0.1.1

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: 29dca667bd36fedf515968013fa6c4763553f69edfd1be2abc95c574e6b8d3d4
4
- data.tar.gz: 312a203d5ed1bc901b7c3d9a7440da1c279f481cce9ef6b2f635177d1639482a
3
+ metadata.gz: 7405b120eabf5b2ace5c2e122ab57b456567e1c985471f45582ad538e5a48345
4
+ data.tar.gz: a08c99241ad71f5dcd87af57867c9e6644dd8bf02fed5a5a9909941f9870f673
5
5
  SHA512:
6
- metadata.gz: c7504a9357a8734bb9c1361b19565b7778a3706eb347ff08bc2c5d4ae5b179913d117df720b13a1ff63698f6dcbbaf6eb6a75f01c36b31af66c6d9ab912f8228
7
- data.tar.gz: dc9631ebf5e1fa7918942aa524bae3b2e5b633a55bbeec8f9bd28c4cd4f8c4ba942890720dd8819b60f6d378fb6b71e1687b4c39be71916e049243b96200672a
6
+ metadata.gz: 624969edaed32a320bfeec953e44e291dc1620b83f15fed11d5a45dd9d31362be1b6a4679198c55e8c2ea6b3fc52243c71dcdad51172a1fa89d65e45909405eb
7
+ data.tar.gz: 5d31c6e7e0be210a8b6f4bf81f62f7dd0f8e1899233cfaac86376b2d2d0dd3f6c72576100faaa5176253d13507b63080b6ee26f1d0d28d518677f848b50d5652
data/Gemfile CHANGED
@@ -7,4 +7,6 @@ gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
9
 
10
- gem "minitest", "~> 5.0"
10
+ gem "mocha", "~> 1.5.0", require: false
11
+ gem "minitest", ">= 5.0.0", require: false
12
+ gem "minitest-reporters", require: false
data/Gemfile.lock ADDED
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gorails (0.1.1)
5
+ cli-kit (~> 4.0.0)
6
+ cli-ui (~> 1.5.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ansi (1.5.0)
12
+ ast (2.4.2)
13
+ builder (3.2.4)
14
+ cli-kit (4.0.0)
15
+ cli-ui (>= 1.1.4)
16
+ cli-ui (1.5.1)
17
+ metaclass (0.0.4)
18
+ minitest (5.15.0)
19
+ minitest-reporters (1.5.0)
20
+ ansi
21
+ builder
22
+ minitest (>= 5.0)
23
+ ruby-progressbar
24
+ mocha (1.5.0)
25
+ metaclass (~> 0.0.1)
26
+ parallel (1.21.0)
27
+ parser (3.1.1.0)
28
+ ast (~> 2.4.1)
29
+ rainbow (3.1.1)
30
+ rake (13.0.6)
31
+ regexp_parser (2.2.1)
32
+ rexml (3.2.5)
33
+ rubocop (1.25.1)
34
+ parallel (~> 1.10)
35
+ parser (>= 3.1.0.0)
36
+ rainbow (>= 2.2.2, < 4.0)
37
+ regexp_parser (>= 1.8, < 3.0)
38
+ rexml
39
+ rubocop-ast (>= 1.15.1, < 2.0)
40
+ ruby-progressbar (~> 1.7)
41
+ unicode-display_width (>= 1.4.0, < 3.0)
42
+ rubocop-ast (1.16.0)
43
+ parser (>= 3.1.1.0)
44
+ rubocop-performance (1.13.3)
45
+ rubocop (>= 1.7.0, < 2.0)
46
+ rubocop-ast (>= 0.4.0)
47
+ ruby-progressbar (1.11.0)
48
+ standard (1.7.3)
49
+ rubocop (= 1.25.1)
50
+ rubocop-performance (= 1.13.3)
51
+ unicode-display_width (2.1.0)
52
+
53
+ PLATFORMS
54
+ arm64-darwin-21
55
+
56
+ DEPENDENCIES
57
+ gorails!
58
+ minitest (>= 5.0.0)
59
+ minitest-reporters
60
+ mocha (~> 1.5.0)
61
+ rake (~> 13.0)
62
+ standard
63
+
64
+ BUNDLED WITH
65
+ 2.3.8
data/exe/gorails ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ Encoding.default_external = Encoding::UTF_8
4
+ Encoding.default_internal = Encoding::UTF_8
5
+
6
+ unshift_path = ->(path) {
7
+ p = File.expand_path("../../#{path}", __FILE__)
8
+ $LOAD_PATH.unshift(p) unless $LOAD_PATH.include?(p)
9
+ }
10
+ unshift_path.call("lib")
11
+
12
+ require "bundler/setup"
13
+ require "gorails"
14
+
15
+ exit(Gorails::ErrorHandler.call do
16
+ Gorails::EntryPoint.call(ARGV.dup)
17
+ end)
data/gorails.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = spec.homepage
19
- #spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
19
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
20
20
 
21
21
  # Specify which files should be added to the gem when it is released.
22
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -29,8 +29,9 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ["lib"]
31
31
 
32
- # Uncomment to register a new dependency of your gem
33
- # spec.add_dependency "example-gem", "~> 1.0"
32
+ spec.add_dependency "cli-kit", "~> 4.0.0"
33
+ spec.add_dependency "cli-ui", "~> 1.5.1"
34
+ spec.add_development_dependency "standard"
34
35
 
35
36
  # For more information and examples about making a new gem, checkout our
36
37
  # guide at: https://bundler.io/guides/creating_gem.html
@@ -0,0 +1,25 @@
1
+ require "gorails"
2
+ require "net/http"
3
+ require "json"
4
+
5
+ module Gorails
6
+ module Commands
7
+ class Episodes < Gorails::Command
8
+ def call(_args, _name)
9
+ episodes = JSON.parse Net::HTTP.get(URI("https://gorails.com/episodes.json"))
10
+
11
+ CLI::UI::Frame.open("Latest GoRails episodes") do
12
+ episodes.each do |episode|
13
+ puts CLI::UI.fmt "##{episode["number"]} {{green:#{episode["name"]}}}"
14
+ puts episode["url"]
15
+ puts
16
+ end
17
+ end
18
+ end
19
+
20
+ def self.help
21
+ "View the latest GoRails episodes.\nUsage: {{command:#{Gorails::TOOL_NAME} episodes}}"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ require "gorails"
2
+
3
+ module Gorails
4
+ module Commands
5
+ class Example < Gorails::Command
6
+ def call(_args, _name)
7
+ puts "neato"
8
+
9
+ if rand < 0.05
10
+ raise(CLI::Kit::Abort, "you got unlucky!")
11
+ end
12
+ end
13
+
14
+ def self.help
15
+ "A dummy command.\nUsage: {{command:#{Gorails::TOOL_NAME} example}}"
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ require "gorails"
2
+
3
+ module Gorails
4
+ module Commands
5
+ class Help < Gorails::Command
6
+ def call(args, _name)
7
+ puts CLI::UI.fmt("{{bold:Available commands}}")
8
+ puts ""
9
+
10
+ Gorails::Commands::Registry.resolved_commands.each do |name, klass|
11
+ next if name == "help"
12
+ puts CLI::UI.fmt("{{command:#{Gorails::TOOL_NAME} #{name}}}")
13
+ if (help = klass.help)
14
+ puts CLI::UI.fmt(help)
15
+ end
16
+ puts ""
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,25 @@
1
+ require "gorails"
2
+ require "net/http"
3
+ require "json"
4
+
5
+ module Gorails
6
+ module Commands
7
+ class Jobs < Gorails::Command
8
+ def call(_args, _name)
9
+ jobs = JSON.parse Net::HTTP.get(URI("https://jobs.gorails.com/jobs.json"))
10
+
11
+ CLI::UI::Frame.open("Ruby on Rails jobs") do
12
+ jobs.each do |job|
13
+ puts CLI::UI.fmt "{{green:#{job["title"]}}} at {{blue:#{job.dig("company", "name")}}}"
14
+ puts job["url"]
15
+ puts
16
+ end
17
+ end
18
+ end
19
+
20
+ def self.help
21
+ "View the latest Ruby on Rails jobs.\nUsage: {{command:#{Gorails::TOOL_NAME} jobs}}"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ require "gorails"
2
+ require "net/http"
3
+ require "json"
4
+
5
+ module Gorails
6
+ module Commands
7
+ class Jumpstart < Gorails::Command
8
+ def call(args, _name)
9
+ name = args.first
10
+
11
+ if name.nil?
12
+ puts CLI::UI.fmt "{{red:Application name is required.}}"
13
+ puts "Try again with \"gorails jumpstart myapp\""
14
+ exit 1
15
+ end
16
+
17
+ CLI::UI::Frame.open("Generating Jumpstart application \"#{name}\"") do
18
+ Bundler.with_original_env do
19
+ system "rails new #{name} -d postgresql -m https://raw.githubusercontent.com/excid3/jumpstart/master/template.rb"
20
+ end
21
+ end
22
+ end
23
+
24
+ def self.help
25
+ "Create a new Ruby on Rails application with the Jumpstart template. https://github.com/excid3/jumpstart\nUsage: {{command:#{Gorails::TOOL_NAME} jumpstart myapp}}"
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,26 @@
1
+ require "gorails"
2
+ require "net/http"
3
+ require "json"
4
+
5
+ module Gorails
6
+ module Commands
7
+ class Railsbytes < Gorails::Command
8
+ def call(_args, _name)
9
+ bytes = JSON.parse Net::HTTP.get(URI("https://railsbytes.com/public/templates.json"))
10
+
11
+ CLI::UI::Frame.open("Railsbytes") do
12
+ bytes.each do |byte|
13
+ puts CLI::UI.fmt "{{green:#{byte["name"]}}} by #{byte["created_by"]}"
14
+ puts byte["short_description"]
15
+ puts "#{byte["id"]} - #{byte["url"]}"
16
+ puts
17
+ end
18
+ end
19
+ end
20
+
21
+ def self.help
22
+ "View the latest Railsbytes templates.\nUsage: {{command:#{Gorails::TOOL_NAME} railsbytes}}"
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,22 @@
1
+ require "gorails"
2
+
3
+ module Gorails
4
+ module Commands
5
+ Registry = CLI::Kit::CommandRegistry.new(
6
+ default: "help",
7
+ contextual_resolver: nil
8
+ )
9
+
10
+ def self.register(const, cmd, path)
11
+ autoload(const, path)
12
+ Registry.add(-> { const_get(const) }, cmd)
13
+ end
14
+
15
+ register :Episodes, "episodes", "gorails/commands/episodes"
16
+ register :Jobs, "jobs", "gorails/commands/jobs"
17
+ register :Jumpstart, "jumpstart", "gorails/commands/jumpstart"
18
+ register :Railsbytes, "railsbytes", "gorails/commands/railsbytes"
19
+ # register :Example, 'example', 'gorails/commands/example'
20
+ register :Help, "help", "gorails/commands/help"
21
+ end
22
+ end
@@ -0,0 +1,10 @@
1
+ require "gorails"
2
+
3
+ module Gorails
4
+ module EntryPoint
5
+ def self.call(args)
6
+ cmd, command_name, args = Gorails::Resolver.call(args)
7
+ Gorails::Executor.call(cmd, command_name, args)
8
+ end
9
+ end
10
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gorails
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/gorails.rb CHANGED
@@ -1,8 +1,38 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "gorails/version"
4
+ require "cli/ui"
5
+ require "cli/kit"
6
+
7
+ CLI::UI::StdoutRouter.enable
4
8
 
5
9
  module Gorails
6
10
  class Error < StandardError; end
7
- # Your code goes here...
11
+
12
+ extend CLI::Kit::Autocall
13
+
14
+ TOOL_NAME = "gorails"
15
+ ROOT = File.expand_path("../..", __FILE__)
16
+ LOG_FILE = "/tmp/myproject.log"
17
+
18
+ autoload(:EntryPoint, "gorails/entry_point")
19
+ autoload(:Commands, "gorails/commands")
20
+
21
+ autocall(:Config) { CLI::Kit::Config.new(tool_name: TOOL_NAME) }
22
+ autocall(:Command) { CLI::Kit::BaseCommand }
23
+
24
+ autocall(:Executor) { CLI::Kit::Executor.new(log_file: LOG_FILE) }
25
+ autocall(:Resolver) do
26
+ CLI::Kit::Resolver.new(
27
+ tool_name: TOOL_NAME,
28
+ command_registry: Gorails::Commands::Registry
29
+ )
30
+ end
31
+
32
+ autocall(:ErrorHandler) do
33
+ CLI::Kit::ErrorHandler.new(
34
+ log_file: LOG_FILE,
35
+ exception_reporter: nil
36
+ )
37
+ end
8
38
  end
metadata CHANGED
@@ -1,32 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gorails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-16 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2022-03-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cli-kit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: cli-ui
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.5.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.5.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: standard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
13
55
  description: The GoRails rubygem
14
56
  email:
15
57
  - excid3@gmail.com
16
- executables: []
58
+ executables:
59
+ - gorails
17
60
  extensions: []
18
61
  extra_rdoc_files: []
19
62
  files:
20
63
  - CHANGELOG.md
21
64
  - CODE_OF_CONDUCT.md
22
65
  - Gemfile
66
+ - Gemfile.lock
23
67
  - LICENSE.txt
24
68
  - README.md
25
69
  - Rakefile
26
70
  - bin/console
27
71
  - bin/setup
72
+ - exe/gorails
28
73
  - gorails.gemspec
29
74
  - lib/gorails.rb
75
+ - lib/gorails/commands.rb
76
+ - lib/gorails/commands/episodes.rb
77
+ - lib/gorails/commands/example.rb
78
+ - lib/gorails/commands/help.rb
79
+ - lib/gorails/commands/jobs.rb
80
+ - lib/gorails/commands/jumpstart.rb
81
+ - lib/gorails/commands/railsbytes.rb
82
+ - lib/gorails/entry_point.rb
30
83
  - lib/gorails/version.rb
31
84
  - sig/gorails.rbs
32
85
  homepage: https://github.com/excid3/gorails-ruby
@@ -50,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
103
  - !ruby/object:Gem::Version
51
104
  version: '0'
52
105
  requirements: []
53
- rubygems_version: 3.2.32
106
+ rubygems_version: 3.3.5
54
107
  signing_key:
55
108
  specification_version: 4
56
109
  summary: GoRails rubygem