mruby_gem_scaffolding 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 783eb964ba50e66fb179d27ed507d4c70ef6247a34af6cdaf6c7119e50721946
4
+ data.tar.gz: 466bddf489420f787e08185cde1298ffd780b8494644558be6063a1bc6736d7c
5
+ SHA512:
6
+ metadata.gz: 4e0952293610de3d05b4614f7baab9a987fcd403d444d158d208abab889a156c08b81a27689b5cc4c66f011328d10685f97c9b084bca885c6c822642145a954e
7
+ data.tar.gz: 30b44945f4c728ce689a057ca7073d992681d0fef2e831ed1b77631b116db1db7a55dd9faa81b29b098f61ed3e7d6dda0bc5e69f45b21d12897e4febffc9b995
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in mruby_gem_scaffolding.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,19 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mruby_gem_scaffolding (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (12.3.3)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ mruby_gem_scaffolding!
16
+ rake (~> 12.0)
17
+
18
+ BUNDLED WITH
19
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 _Tradam
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.
data/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # mruby Gem Scaffolding
2
+
3
+ This gem allows you to easily create a basic working scaffold of an mruby gem.
4
+
5
+ Install the gem by `gem install mruby_gem_scaffolding` and then run with `mruby_gem_scaffolding`
6
+
7
+ https://rubygems.org/gems/mruby_gem_scaffolding
8
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mruby_gem_scaffolding"
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__)
data/bin/setup ADDED
@@ -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,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "mruby_gem_scaffolding"
4
+
5
+ print "Enter your project name: "
6
+ project_name = gets.chomp
7
+
8
+ Dir.mkdir project_name unless File.exists? project_name
9
+ if !Dir.empty? project_name
10
+ puts "#{project_name} directory is not empty. Quitting..."
11
+ return
12
+ end
13
+
14
+ print "Enter your author name: "
15
+ user_name = gets.chomp
16
+
17
+ MrubyGemScaffolding.write(
18
+ "./#{project_name}",
19
+ MrubyGemScaffolding.generate(user_name: user_name, project_name: project_name)
20
+ )
21
+
22
+ puts "Done!"
@@ -0,0 +1,3 @@
1
+ module MrubyGemScaffolding
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,127 @@
1
+ require "mruby_gem_scaffolding/version"
2
+
3
+ module MrubyGemScaffolding
4
+ module Utility
5
+ class << self
6
+ # from thor gem
7
+ def snake_case(str)
8
+ return str.downcase if str =~ /^[A-Z_]+$/
9
+ str.gsub(/\B[A-Z]/, '_\&').squeeze("_") =~ /_*(.*)/
10
+ Regexp.last_match(-1).downcase
11
+ end
12
+
13
+ # from thor gem
14
+ def camel_case(str)
15
+ return str if str !~ /_/ && str =~ /[A-Z]+.*/
16
+ str.split("_").map(&:capitalize).join
17
+ end
18
+ end
19
+ end
20
+
21
+ class << self
22
+ def empty_project
23
+ {
24
+ "README.md" => '',
25
+ "mrbgem.rake" => '',
26
+ "include" => {},
27
+ "mrblib" => {},
28
+ "src" => {},
29
+ "tools" => {},
30
+ "test" => {},
31
+ "LICENSE" => '',
32
+ }
33
+ end
34
+
35
+ def generate(user_name:, project_name:)
36
+ result = empty_project
37
+
38
+ result["README.md"] =
39
+ <<MULTILINE
40
+ # #{Utility.camel_case(project_name)}
41
+ An mruby gem created by #{user_name} using mruby_gem_scaffolding.
42
+ MULTILINE
43
+
44
+ result["mrbgem.rake"] =
45
+ <<MULTILINE
46
+ MRuby::Gem::Specification.new('#{Utility.snake_case(project_name)}') do |spec|
47
+ spec.license = 'MIT'
48
+ spec.author = '#{user_name}'
49
+ end
50
+ MULTILINE
51
+
52
+ result["src"]["main.c"] =
53
+ <<MULTILINE
54
+ #include <mruby.h>
55
+ #include <stdio.h>
56
+
57
+ // defining the function to be later bound to a ruby method
58
+ static mrb_value
59
+ hello_world(mrb_state *mrb, mrb_value self)
60
+ {
61
+ printf("Hello World");
62
+
63
+ return mrb_nil_value(); // return null
64
+ }
65
+
66
+ // gem initializer
67
+ void
68
+ mrb_#{Utility.snake_case(project_name)}_gem_init(mrb_state* mrb) {
69
+ struct RClass *#{Utility.snake_case(project_name)}_class = mrb_define_module(mrb, "#{Utility.camel_case(project_name)}");
70
+ mrb_define_class_method(
71
+ mrb, // Mruby VM state
72
+ #{Utility.snake_case(project_name)}_class, // Class we bind method to
73
+ "say_hello", // Name of method
74
+ hello_world, // Function we are binding as a method
75
+ MRB_ARGS_NONE() // How many arguments are optional/required
76
+ );
77
+ }
78
+
79
+ // gem finalizer
80
+ void
81
+ mrb_#{Utility.snake_case(project_name)}_gem_final(mrb_state* mrb) {
82
+
83
+ }
84
+ MULTILINE
85
+
86
+ result["LICENSE"] =
87
+ <<MULTILINE
88
+ The MIT License (MIT)
89
+
90
+ Copyright (c) #{Time.now.year} #{user_name}
91
+
92
+ Permission is hereby granted, free of charge, to any person obtaining a copy
93
+ of this software and associated documentation files (the "Software"), to deal
94
+ in the Software without restriction, including without limitation the rights
95
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
96
+ copies of the Software, and to permit persons to whom the Software is
97
+ furnished to do so, subject to the following conditions:
98
+
99
+ The above copyright notice and this permission notice shall be included in
100
+ all copies or substantial portions of the Software.
101
+
102
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
103
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
104
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
105
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
106
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
107
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
108
+ THE SOFTWARE.
109
+
110
+ MULTILINE
111
+
112
+ return result
113
+ end
114
+
115
+ def write(dir, hash_data)
116
+ Dir.mkdir dir unless File.exists? dir
117
+ hash_data.each do |key, value|
118
+ if value.is_a? Hash
119
+ write("#{dir}/#{key}", value)
120
+ else
121
+ File.open("#{dir}/#{key}", 'w') { |file| file.write(value) }
122
+ end
123
+ end
124
+ end
125
+ end
126
+
127
+ end
@@ -0,0 +1,30 @@
1
+ require_relative 'lib/mruby_gem_scaffolding/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "mruby_gem_scaffolding"
5
+ spec.version = MrubyGemScaffolding::VERSION
6
+ spec.authors = ["Tradam"]
7
+ spec.email = ["github@tradam.dev"]
8
+
9
+ spec.summary = %q{Creates a blank mruby gem for you with all the required files generated automatically.}
10
+ #spec.description = %q{TODO: Write a longer description or delete this line.}
11
+ #spec.homepage = "TODO: Put your gem's website or public repo URL here."
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ #spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
16
+
17
+ #spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/realtradam/mruby_gem_scaffolding"
19
+ #spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ #spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.executables = "mruby_gem_scaffolding"
29
+ spec.require_paths = ["lib"]
30
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mruby_gem_scaffolding
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Tradam
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-02-07 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - github@tradam.dev
16
+ executables:
17
+ - mruby_gem_scaffolding
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".gitignore"
22
+ - Gemfile
23
+ - Gemfile.lock
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - bin/console
28
+ - bin/setup
29
+ - exe/mruby_gem_scaffolding
30
+ - lib/mruby_gem_scaffolding.rb
31
+ - lib/mruby_gem_scaffolding/version.rb
32
+ - mruby_gem_scaffolding.gemspec
33
+ homepage:
34
+ licenses:
35
+ - MIT
36
+ metadata:
37
+ source_code_uri: https://github.com/realtradam/mruby_gem_scaffolding
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 2.3.0
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubygems_version: 3.1.6
54
+ signing_key:
55
+ specification_version: 4
56
+ summary: Creates a blank mruby gem for you with all the required files generated automatically.
57
+ test_files: []