funky-cli 0.0.1

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
+ SHA1:
3
+ metadata.gz: f56bde6982bfdedb5db4bf82420cc2bd615860fe
4
+ data.tar.gz: 23a432baa90d51b61959b08b4cfc379ffba6deef
5
+ SHA512:
6
+ metadata.gz: cda5dbcdb7d788d73273dac914bd74afc860feafa688bc9c636c571f361952348a56d950a0512574548a46d3058b821d33a222dc943a97dda959501209466f71
7
+ data.tar.gz: e5e6d948be3426f55bbda59756733e4183600febd4e33620b6aea4fec5f466b214be61ee084b2a89f67d577b6f3ce92c90683d4846e1c3c45f4b88f15e8223ce
@@ -0,0 +1,2 @@
1
+ mruby/
2
+ exe/
@@ -0,0 +1 @@
1
+ FROM hone/mruby-cli
@@ -0,0 +1,100 @@
1
+ require 'fileutils'
2
+
3
+ MRUBY_VERSION="1.2.0"
4
+
5
+ file :mruby do
6
+ #sh "git clone --depth=1 https://github.com/mruby/mruby"
7
+ sh "curl -L --fail --retry 3 --retry-delay 1 https://github.com/mruby/mruby/archive/1.2.0.tar.gz -s -o - | tar zxf -"
8
+ FileUtils.mv("mruby-1.2.0", "mruby")
9
+ end
10
+
11
+ APP_NAME=ENV["APP_NAME"] || "funky-cli"
12
+ APP_ROOT=ENV["APP_ROOT"] || Dir.pwd
13
+ # avoid redefining constants in mruby Rakefile
14
+ mruby_root=File.expand_path(ENV["MRUBY_ROOT"] || "#{APP_ROOT}/mruby")
15
+ mruby_config=File.expand_path(ENV["MRUBY_CONFIG"] || "build_config.rb")
16
+ ENV['MRUBY_ROOT'] = mruby_root
17
+ ENV['MRUBY_CONFIG'] = mruby_config
18
+ Rake::Task[:mruby].invoke unless Dir.exist?(mruby_root)
19
+ Dir.chdir(mruby_root)
20
+ load "#{mruby_root}/Rakefile"
21
+
22
+ desc "compile binary"
23
+ task :compile => [:all] do
24
+ %W(#{mruby_root}/build/x86_64-pc-linux-gnu/bin/#{APP_NAME} #{mruby_root}/build/i686-pc-linux-gnu/#{APP_NAME}").each do |bin|
25
+ sh "strip --strip-unneeded #{bin}" if File.exist?(bin)
26
+ end
27
+ end
28
+
29
+ namespace :test do
30
+ desc "run mruby & unit tests"
31
+ # only build mtest for host
32
+ task :mtest => :compile do
33
+ # in order to get mruby/test/t/synatx.rb __FILE__ to pass,
34
+ # we need to make sure the tests are built relative from mruby_root
35
+ MRuby.each_target do |target|
36
+ # only run unit tests here
37
+ target.enable_bintest = false
38
+ run_test if target.test_enabled?
39
+ end
40
+ end
41
+
42
+ def clean_env(envs)
43
+ old_env = {}
44
+ envs.each do |key|
45
+ old_env[key] = ENV[key]
46
+ ENV[key] = nil
47
+ end
48
+ yield
49
+ envs.each do |key|
50
+ ENV[key] = old_env[key]
51
+ end
52
+ end
53
+
54
+ desc "run integration tests"
55
+ task :bintest => :compile do
56
+ MRuby.each_target do |target|
57
+ clean_env(%w(MRUBY_ROOT MRUBY_CONFIG)) do
58
+ run_bintest if target.bintest_enabled?
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ desc "Create gem package"
65
+ task :gem => :compile do
66
+ FileUtils.cd(File.dirname(File.realpath(__FILE__)))
67
+ FileUtils.rm_rf("./exe")
68
+ FileUtils.mkdir_p("./exe")
69
+
70
+ files = Dir["mruby/build/**/bin/funky-cli*"].inject({}) do |hash, f|
71
+ arch = f.match(/mruby\/build\/(.*)\/bin/)[1]
72
+ if arch == "host"
73
+ hash
74
+ else
75
+ if f[-3..-1] == "exe"
76
+ hash[f] = "exe/#{arch}.exe"
77
+ else
78
+ hash[f] = "exe/#{arch}"
79
+ end
80
+ hash
81
+ end
82
+ end
83
+
84
+ files.each do |from,to|
85
+ FileUtils.cp(from, to)
86
+ end
87
+
88
+ FileUtils.chmod 0755, Dir["exe/*"]
89
+
90
+ sh "gem build funky-cli.gemspec"
91
+ end
92
+
93
+ desc "run all tests"
94
+ Rake::Task['test'].clear
95
+ task :test => ["test:mtest", "test:bintest"]
96
+
97
+ desc "cleanup"
98
+ task :clean do
99
+ sh "rake deep_clean"
100
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ platforms = {
4
+ "i386-darwain" => "i386-apple-darwin14",
5
+ "i686-linux" => "i686-pc-linux-gnu",
6
+ "i686-mingw32" => "i686-w64-mingw32.exe",
7
+ "x86_64-darwin" => "x86_64-apple-darwin14",
8
+ "x86_64-linux" => "x86_64-pc-linux-gnu",
9
+ "x86_64-mingw32" => "x86_64-w64-mingw32.exe"
10
+ }
11
+
12
+ executable = platforms["#{`uname -m`.chomp}-#{`uname -s`.chomp.downcase}"]
13
+
14
+ system("#{File.dirname(File.realpath(__FILE__))}/../exe/#{executable}", *ARGV)
@@ -0,0 +1,17 @@
1
+ require 'open3'
2
+
3
+ BIN_PATH = File.join(File.dirname(__FILE__), "../mruby/bin/funky-cli")
4
+
5
+ assert('hello') do
6
+ output, status = Open3.capture2(BIN_PATH)
7
+
8
+ assert_true status.success?, "Process did not exit cleanly"
9
+ assert_include output, "Hello World"
10
+ end
11
+
12
+ assert('version') do
13
+ output, status = Open3.capture2(BIN_PATH, "version")
14
+
15
+ assert_true status.success?, "Process did not exit cleanly"
16
+ assert_include output, "v0.0.1"
17
+ end
@@ -0,0 +1,94 @@
1
+ def gem_config(conf)
2
+ #conf.gembox 'default'
3
+
4
+ # be sure to include this gem (the cli app)
5
+ conf.gem File.expand_path(File.dirname(__FILE__))
6
+ end
7
+
8
+ MRuby::Build.new do |conf|
9
+ toolchain :clang
10
+
11
+ conf.enable_bintest
12
+ conf.enable_debug
13
+ conf.enable_test
14
+
15
+ gem_config(conf)
16
+ end
17
+
18
+ MRuby::Build.new('x86_64-pc-linux-gnu') do |conf|
19
+ toolchain :gcc
20
+
21
+ gem_config(conf)
22
+ end
23
+
24
+ MRuby::CrossBuild.new('i686-pc-linux-gnu') do |conf|
25
+ toolchain :gcc
26
+
27
+ [conf.cc, conf.cxx, conf.linker].each do |cc|
28
+ cc.flags << "-m32"
29
+ end
30
+
31
+ gem_config(conf)
32
+ end
33
+
34
+ MRuby::CrossBuild.new('x86_64-apple-darwin14') do |conf|
35
+ toolchain :clang
36
+
37
+ [conf.cc, conf.linker].each do |cc|
38
+ cc.command = 'x86_64-apple-darwin14-clang'
39
+ end
40
+ conf.cxx.command = 'x86_64-apple-darwin14-clang++'
41
+ conf.archiver.command = 'x86_64-apple-darwin14-ar'
42
+
43
+ conf.build_target = 'x86_64-pc-linux-gnu'
44
+ conf.host_target = 'x86_64-apple-darwin14'
45
+
46
+ gem_config(conf)
47
+ end
48
+
49
+ MRuby::CrossBuild.new('i386-apple-darwin14') do |conf|
50
+ toolchain :clang
51
+
52
+ [conf.cc, conf.linker].each do |cc|
53
+ cc.command = 'i386-apple-darwin14-clang'
54
+ end
55
+ conf.cxx.command = 'i386-apple-darwin14-clang++'
56
+ conf.archiver.command = 'i386-apple-darwin14-ar'
57
+
58
+ conf.build_target = 'i386-pc-linux-gnu'
59
+ conf.host_target = 'i386-apple-darwin14'
60
+
61
+ gem_config(conf)
62
+ end
63
+
64
+ MRuby::CrossBuild.new('x86_64-w64-mingw32') do |conf|
65
+ toolchain :gcc
66
+
67
+ [conf.cc, conf.linker].each do |cc|
68
+ cc.command = 'x86_64-w64-mingw32-gcc'
69
+ end
70
+ conf.cxx.command = 'x86_64-w64-mingw32-cpp'
71
+ conf.archiver.command = 'x86_64-w64-mingw32-gcc-ar'
72
+ conf.exts.executable = ".exe"
73
+
74
+ conf.build_target = 'x86_64-pc-linux-gnu'
75
+ conf.host_target = 'x86_64-w64-mingw32'
76
+
77
+ gem_config(conf)
78
+ end
79
+
80
+ MRuby::CrossBuild.new('i686-w64-mingw32') do |conf|
81
+ toolchain :gcc
82
+
83
+ [conf.cc, conf.linker].each do |cc|
84
+ cc.command = 'i686-w64-mingw32-gcc'
85
+ end
86
+ conf.cxx.command = 'i686-w64-mingw32-cpp'
87
+ conf.archiver.command = 'i686-w64-mingw32-gcc-ar'
88
+ conf.exts.executable = ".exe"
89
+
90
+ conf.build_target = 'i686-pc-linux-gnu'
91
+ conf.host_target = 'i686-w64-mingw32'
92
+
93
+ gem_config(conf)
94
+ end
@@ -0,0 +1,23 @@
1
+ compile: &defaults
2
+ build: .
3
+ volumes:
4
+ - .:/home/mruby/code:rw
5
+ command: rake compile
6
+ test:
7
+ <<: *defaults
8
+ command: rake test
9
+ bintest:
10
+ <<: *defaults
11
+ command: rake test:bintest
12
+ mtest:
13
+ <<: *defaults
14
+ command: rake test:mtest
15
+ clean:
16
+ <<: *defaults
17
+ command: rake clean
18
+ shell:
19
+ <<: *defaults
20
+ command: bash
21
+ gem:
22
+ <<: *defaults
23
+ command: rake gem
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../mrblib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'funky-cli/version.rb'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "funky-cli"
9
+ spec.version = FunkyCli::VERSION
10
+ spec.authors = ["Thiago Scalone"]
11
+ spec.email = ["thiago@cloudwalk.io"]
12
+ spec.summary = "CLI for DaFunk projects"
13
+ spec.description = "DaFunk is a Embedded System Framework optimized for programmer happiness and sustainable productivity. It encourages beautiful code by favoring convention over configuration."
14
+ spec.homepage = "http://github.com/da_funk/funky-cli"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0") + Dir["exe/*"]
18
+ spec.executables = Dir["bin/*"].collect { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.bindir = 'bin'
21
+ spec.require_paths = ["mrblib"]
22
+
23
+ spec.required_ruby_version = '>= 1.9.3'
24
+
25
+ spec.add_dependency "rake", "~> 10.4"
26
+ spec.add_dependency "bundler", "~> 1.7"
27
+ end
@@ -0,0 +1,9 @@
1
+ MRuby::Gem::Specification.new('funky-cli') do |spec|
2
+ spec.license = 'MIT'
3
+ spec.author = 'MRuby Developer'
4
+ spec.summary = 'funky-cli'
5
+ spec.bins = ['funky-cli']
6
+
7
+ spec.add_dependency 'mruby-print', :core => 'mruby-print'
8
+ spec.add_dependency 'mruby-mtest', :mgem => 'mruby-mtest'
9
+ end
@@ -0,0 +1,7 @@
1
+ def __main__(argv)
2
+ if argv[1] == "version"
3
+ puts "v#{FunkyCli::VERSION}"
4
+ else
5
+ puts "Hello World"
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module FunkyCli
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,7 @@
1
+ class TestFunkyCli < MTest::Unit::TestCase
2
+ def test_main
3
+ assert_nil __main__([])
4
+ end
5
+ end
6
+
7
+ MTest::Unit.new.run
@@ -0,0 +1,33 @@
1
+ // This file is generated by mruby-cli. Do not touch.
2
+ #include <stdlib.h>
3
+ #include <stdio.h>
4
+
5
+ /* Include the mruby header */
6
+ #include <mruby.h>
7
+ #include <mruby/array.h>
8
+
9
+ int main(int argc, char *argv[])
10
+ {
11
+ mrb_state *mrb = mrb_open();
12
+ mrb_value ARGV = mrb_ary_new_capa(mrb, argc);
13
+ int i;
14
+ int return_value;
15
+
16
+ for (i = 0; i < argc; i++) {
17
+ mrb_ary_push(mrb, ARGV, mrb_str_new_cstr(mrb, argv[i]));
18
+ }
19
+ mrb_define_global_const(mrb, "ARGV", ARGV);
20
+
21
+ // call __main__(ARGV)
22
+ mrb_funcall(mrb, mrb_top_self(mrb), "__main__", 1, ARGV);
23
+
24
+ return_value = EXIT_SUCCESS;
25
+
26
+ if (mrb->exc) {
27
+ mrb_print_error(mrb);
28
+ return_value = EXIT_FAILURE;
29
+ }
30
+ mrb_close(mrb);
31
+
32
+ return return_value;
33
+ }
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: funky-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Thiago Scalone
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '10.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '10.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ description: DaFunk is a Embedded System Framework optimized for programmer happiness
42
+ and sustainable productivity. It encourages beautiful code by favoring convention
43
+ over configuration.
44
+ email:
45
+ - thiago@cloudwalk.io
46
+ executables:
47
+ - funky-cli
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - ".gitignore"
52
+ - Dockerfile
53
+ - Rakefile
54
+ - bin/funky-cli
55
+ - bintest/funky-cli.rb
56
+ - build_config.rb
57
+ - docker-compose.yml
58
+ - exe/i386-apple-darwin14
59
+ - exe/i686-pc-linux-gnu
60
+ - exe/i686-w64-mingw32.exe
61
+ - exe/x86_64-apple-darwin14
62
+ - exe/x86_64-pc-linux-gnu
63
+ - exe/x86_64-w64-mingw32.exe
64
+ - funky-cli.gemspec
65
+ - mrbgem.rake
66
+ - mrblib/funky-cli.rb
67
+ - mrblib/funky-cli/version.rb
68
+ - test/test_funky-cli.rb
69
+ - tools/funky-cli/funky-cli.c
70
+ homepage: http://github.com/da_funk/funky-cli
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - mrblib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 1.9.3
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.4.5
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: CLI for DaFunk projects
94
+ test_files:
95
+ - test/test_funky-cli.rb