buildrake 0.0.8

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,29 @@
1
+ module Buildrake
2
+ class Github
3
+ def self.asset_urls( base_url )
4
+ asset_urls = []
5
+ require "nokogiri"
6
+ require "open-uri"
7
+ base_uri = URI.parse( base_url )
8
+ document = Nokogiri::HTML.parse( open( base_url ).readlines.join )
9
+ document.xpath( '//a' ).each{|element|
10
+ href = element.attribute( "href" )
11
+ case Rush.ext_name( href )
12
+ when "zip"
13
+ asset_urls.push base_uri.merge( href ).to_s
14
+ end
15
+ }
16
+ asset_urls
17
+ end
18
+
19
+ def self.download_assets( base_url )
20
+ asset_urls( base_url ).each{|asset_url|
21
+ asset_uri = URI.parse( asset_url )
22
+ file_name = Rush.base_name( asset_uri.path )
23
+ Rush.sh( "wget -q #{asset_url}" )
24
+ Rush.sh( "unzip -q #{file_name}" )
25
+ Rush.remove( file_name )
26
+ }
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,122 @@
1
+ require "fileutils"
2
+
3
+ module Buildrake
4
+ module Rush
5
+ extend self
6
+
7
+ def sh( command, options = {}, &block )
8
+ caption = "[#{full_dir_path}] #{command}"
9
+ puts caption
10
+ system( command, options )
11
+ status = $?
12
+ if block_given?
13
+ block.call( status )
14
+ else
15
+ raise "Failed(#{status.exitstatus}): #{caption}" if 0 != status.exitstatus
16
+ end
17
+ end
18
+
19
+ def which?( name )
20
+ Rush.sh( "which #{name}", :out => "/dev/null", :err => "/dev/null" ){|status| return ( 0 == status )}
21
+ end
22
+
23
+ def file?( path )
24
+ File.exists?( path )
25
+ end
26
+
27
+ def dir?( path )
28
+ Dir.exists?( path )
29
+ end
30
+
31
+ def changed( path, &block )
32
+ Dir.chdir( path, &block )
33
+ end
34
+
35
+ def maked( path, &block )
36
+ FileUtils.mkdir_p( path ) if ! Rush.dir?( path )
37
+ Rush.changed( path, &block )
38
+ end
39
+
40
+ def remaked( path, &block )
41
+ Rush.remove( path )
42
+ Rush.maked( path, &block )
43
+ end
44
+
45
+ def copy( src, dst )
46
+ FileUtils.cp_r( src, dst )
47
+ end
48
+
49
+ def rename( src, dst )
50
+ FileUtils.mv( src, dst )
51
+ end
52
+
53
+ def remove( path )
54
+ FileUtils.rm_rf( path ) if Rush.file?( path ) || Rush.dir?( path )
55
+ end
56
+
57
+ def find( pattern, &block )
58
+ Dir.glob( pattern, &block )
59
+ end
60
+
61
+ def base_name( path )
62
+ File.basename( path )
63
+ end
64
+
65
+ def ext_name( path )
66
+ File.extname( path ).gsub( /^\./, "" )
67
+ end
68
+
69
+ def dir_path( path )
70
+ File.dirname( path )
71
+ end
72
+
73
+ def full_dir_path( path = "." )
74
+ Rush.changed( path ){
75
+ path = Dir.pwd
76
+ }
77
+ path
78
+ end
79
+
80
+ def env?( key )
81
+ ENV.key?( key )
82
+ end
83
+
84
+ def env( key, value = nil )
85
+ if value.nil? && Rush.env?( key )
86
+ value = ENV[ key ]
87
+ else
88
+ ENV[ key ] = value
89
+ end
90
+ value
91
+ end
92
+
93
+ def pascal_case( name )
94
+ name.split( "_" ).map{|v| v.capitalize}.join
95
+ end
96
+
97
+ def os_type
98
+ os_type = RbConfig::CONFIG[ "host_os" ]
99
+ case os_type
100
+ when /darwin/
101
+ os_type = "macos"
102
+ when /linux/
103
+ os_type = "linux"
104
+ when /mingw/
105
+ os_type = "windows"
106
+ end
107
+ os_type
108
+ end
109
+
110
+ def macos?
111
+ ( "macos" == Rush.os_type )
112
+ end
113
+
114
+ def linux?
115
+ ( "linux" == Rush.os_type )
116
+ end
117
+
118
+ def windows?
119
+ ( "windows" == Rush.os_type )
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,3 @@
1
+ module Buildrake
2
+ VERSION = "0.0.8"
3
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: buildrake
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8
5
+ platform: ruby
6
+ authors:
7
+ - mskz-3110
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-09-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Multiplatform build for c.
56
+ email:
57
+ - mskz.saito@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - bin/console
68
+ - bin/setup
69
+ - buildrake.gemspec
70
+ - lib/buildrake.rb
71
+ - lib/buildrake/comment.rb
72
+ - lib/buildrake/config.rb
73
+ - lib/buildrake/github.rb
74
+ - lib/buildrake/rush.rb
75
+ - lib/buildrake/version.rb
76
+ homepage: https://github.com/mskz-3110/buildrake/rubygems/buildrake
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubygems_version: 3.0.3
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Multiplatform build for c.
99
+ test_files: []