azxczxc 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (8) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +18 -0
  3. data/a.gemspec +18 -0
  4. data/bin/a +55 -0
  5. data/lib/a.rb +7 -0
  6. data/lib/commands/gem.rb +105 -0
  7. data/rakefile.rb +25 -0
  8. metadata +50 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 531278164fb2ff46fa68589e8edb405466597bc70f5b6c9fa40078fb6abf9c4d
4
+ data.tar.gz: 1b31d7a006b2348c1c6d1ce42dc06ac857f5b38e7599008d84bce4ebe4b98caa
5
+ SHA512:
6
+ metadata.gz: 8bb8503aad703061a861ec8be6ff2cc96a18d53cddb5e39ef7ee451b5222d0f8ae63dded676a037b3302c2622031068873911dee8c84b1711fab11f16ec94f09
7
+ data.tar.gz: 4d0a2a02e8e7f4467b74945760ddef688d34116217730e26ce99b34baf0b717cbc6321d896517deddfce7534c71e69f3254d8d7b4b0cb78deb6b319984761a2a
data/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # a
2
+ a gem generator etc.
3
+
4
+ ## install:
5
+ gem install a
6
+ will create a `a` command
7
+ ## example: use `a` create a gem
8
+ sudo a gem mytest
9
+ cd mytest
10
+ sudo rake run
11
+ for starter, you need just type `a gem`
12
+
13
+
14
+
15
+ ## license:
16
+ MIT
17
+ ## versions:
18
+ 2018-10-17 init
data/a.gemspec ADDED
@@ -0,0 +1,18 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "azxczxc"
3
+ s.version = "0.2.8"
4
+ s.summary = "a gem generator etc."
5
+ s.authors = ['author']
6
+
7
+ s.license = 'MIT'
8
+ s.email = 'degcat@126.com'
9
+ s.homepage = 'https://github.com/axgle/a'
10
+
11
+ s.files = ["README.md","a.gemspec","rakefile.rb","lib/a.rb"]
12
+ s.files += Dir["lib/commands/*.rb"]
13
+ s.executables << "a"
14
+
15
+ s.require_paths << 'lib'
16
+ s.required_ruby_version = '>= 2.0.0'
17
+
18
+ end
data/bin/a ADDED
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #ex: gem
4
+ def target
5
+
6
+ unless $*[0]
7
+ puts <<-EOT
8
+ example:
9
+ a gem mytest
10
+ will create new gem project named mytest directory
11
+
12
+ EOT
13
+ exit 1
14
+ end
15
+ t = String.new $*[0]
16
+ t.capitalize!
17
+ t
18
+ end
19
+
20
+ #ex: mytest
21
+ def dir
22
+
23
+ unless $*[1]
24
+ puts "must have mtarget_dir\nfor example:\n a gem mytest "
25
+ exit 2
26
+ end
27
+
28
+ t = String.new $*[1]
29
+
30
+ # t.capitalize!
31
+ t
32
+ end
33
+
34
+
35
+ def main
36
+
37
+ begin
38
+ #require 'pathname'
39
+ #require(File.join(File.dirname(__FILE__),'..','lib','commands',target.downcase))
40
+ require File.join('commands',target.downcase)
41
+ rescue LoadError
42
+
43
+ puts "the #{target} not exist"
44
+ exit 4
45
+
46
+ end
47
+
48
+ target_class = Object.const_get('A::'+target)
49
+
50
+
51
+ target_class.index(dir: dir,target: target)
52
+
53
+ end
54
+
55
+ main()
data/lib/a.rb ADDED
@@ -0,0 +1,7 @@
1
+ module A
2
+ class << self
3
+ def info
4
+ puts rand
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,105 @@
1
+ module A
2
+ class Gem
3
+ class << self
4
+
5
+ def make_dirs(config)
6
+ dir = config[:dir]
7
+
8
+ Dir.mkdir dir rescue nil
9
+
10
+ Dir.chdir dir
11
+ Dir.mkdir 'lib' rescue nil
12
+ Dir.mkdir 'bin' rescue nil
13
+ end
14
+
15
+ def make_rakefile(config)
16
+ dir = config[:dir]
17
+
18
+ rakefile = <<-eot
19
+ def latest_gem
20
+ Dir["*.gem"].sort.last
21
+ end
22
+
23
+ task :default do
24
+ puts `gem build #{dir}.gemspec`
25
+ if $?.success?
26
+ puts "\\nyou can install it with:"
27
+ puts "rake install\\n"
28
+ puts "then run your app with:\\n#{dir}\\n"
29
+
30
+ end
31
+ end
32
+ task :run do
33
+ puts `gem build #{dir}.gemspec`
34
+ puts `gem install --local \#{latest_gem}`
35
+ puts "===output==="
36
+ puts `#{dir}`
37
+
38
+ end
39
+
40
+ task :install do
41
+ puts `gem install --local \#{latest_gem}`
42
+ end
43
+
44
+ task :push do
45
+ puts "pusing \#{latest_gem}..."
46
+ puts `gem push \#{latest_gem}`
47
+ if $?.success?
48
+ puts "https://rubygems.org/gems/#{dir}"
49
+ end
50
+ end
51
+
52
+ task :i=>:install
53
+
54
+ eot
55
+ IO.write "rakefile.rb",rakefile
56
+ end
57
+
58
+ def make_specfile(config)
59
+ dir = config[:dir]
60
+ gemspec = <<-eot
61
+
62
+ Gem::Specification.new do |s|
63
+ s.name = "#{dir}"
64
+ s.version = "0.0.1"
65
+ s.summary = "summary"
66
+ s.authors = ['authors']
67
+
68
+ s.license = 'MIT'
69
+ s.email = 'degcat@126.com'
70
+ s.homepage = 'https://rubygems.org/gems/a'
71
+
72
+ s.files = Dir["lib/*.rb"]
73
+ s.executables << "#{dir}"
74
+ end
75
+
76
+ eot
77
+ IO.write "#{dir}.gemspec",gemspec
78
+ end
79
+ def index(config)
80
+ dir = config[:dir]
81
+ target = config[:target]
82
+
83
+ self.make_dirs(config)
84
+
85
+ self.make_rakefile(config)
86
+ self.make_specfile(config)
87
+
88
+ IO.write "lib/#{dir}.rb",''
89
+
90
+ binfile=<<-eot
91
+ #!/usr/bin/env ruby
92
+ puts "hello world!"
93
+ eot
94
+ IO.write "bin/#{dir}",binfile
95
+
96
+ FileUtils.chmod "u=wrx","bin/#{dir}" rescue nil
97
+
98
+
99
+
100
+ #puts gemspec
101
+
102
+ end
103
+ end
104
+ end
105
+ end
data/rakefile.rb ADDED
@@ -0,0 +1,25 @@
1
+ task :default do
2
+ puts `gem build a.gemspec`
3
+ puts `gem install --local #{latest_gem}`
4
+ puts `ruby -e '' -ra`
5
+ puts `a gem mytest`
6
+ end
7
+
8
+ task :install do
9
+ puts `gem install --local #{latest_gem}`
10
+ end
11
+
12
+ task :push do
13
+ puts "pusing #{latest_gem}..."
14
+ exec "gem push #{latest_gem}"
15
+ if $?.success?
16
+ puts "https://rubygems.org/gems/a"
17
+ end
18
+ end
19
+
20
+ task :i=>:install
21
+
22
+
23
+ def latest_gem
24
+ Dir["*.gem"].sort.last
25
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: azxczxc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.8
5
+ platform: ruby
6
+ authors:
7
+ - author
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-10-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: degcat@126.com
15
+ executables:
16
+ - a
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - README.md
21
+ - a.gemspec
22
+ - bin/a
23
+ - lib/a.rb
24
+ - lib/commands/gem.rb
25
+ - rakefile.rb
26
+ homepage: https://github.com/axgle/a
27
+ licenses:
28
+ - MIT
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 2.0.0
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubygems_version: 3.2.22
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: a gem generator etc.
50
+ test_files: []