tycli-public 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7389b8d31d240723a43a84599a77b46a09768eab
4
- data.tar.gz: ac90133fcac7f3fb12ce8cbb5f1c2fdac13c5efb
3
+ metadata.gz: c3b7a4f859f04c8d94b57642435824bee59f013e
4
+ data.tar.gz: 53b8bf1da7fcd9d60509876b2f75c7afd022fe9a
5
5
  SHA512:
6
- metadata.gz: 9c3575fdbffcd4ff1db8fc4187af295f0ebb360d72204a213d7e813583fc5665181d3d278b84ff33209c658c0015f40ece8719d96a95001ee37ffbab07cef52c
7
- data.tar.gz: 0aaf7b5fe4d710a492a7efce3cf90b4dc876d55398476d468bcf5f8784428bba56cb9ab6fb4ee982d2bbf520deeb5680754a850769ed01e17553cdcba29336bd
6
+ metadata.gz: 5637a49fdcc4789acc6fb5ce040fa5c6973baed4883e5e1c5a999db44986aa15a0129c181dec79f58fcf3604faeab63cab01e82668f218a1db7969bd8159e6ad
7
+ data.tar.gz: d250e5df5a7480228df20a953056231eff3fe1b27cc1a46fb31b5426ef74c29b116f6a4aea35eada8d8044e9deb6dc27c8c738b66bdd88212372b10173fdf4ac
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/ruby -w
2
+
1
3
  module Tuya
2
4
  class Command
3
5
  class Group < Command
@@ -1,3 +1,6 @@
1
+ require 'tycli/repo/spec'
2
+ require 'tycli/spec_repo'
3
+
1
4
  module Tuya
2
5
  class Command
3
6
  class Repo < Command
@@ -6,15 +9,13 @@ module Tuya
6
9
  self.summary = "push a module to tuya specs(your spec)"
7
10
  self.command = 'push'
8
11
 
9
- def self.options
10
- [
11
- ['--name=group_name', '--name the name for your group']
12
- ].concat(super)
13
- end
14
-
15
12
  def validate!
16
- help! "use --version assign your verion " unless @version
17
- help! "podspec can not be nil" unless @podspec
13
+
14
+ @podspec = Tuya::PodSpec.ask_pod_spec unless @podspec
15
+ help! "\npodspec can not be nil" unless @podspec
16
+
17
+ @version = Tuya::PodSpec.pod_spec_version @podspec unless @version
18
+ help! "\nuse --version assign your verion " unless @version
18
19
  end
19
20
 
20
21
  def initialize(argv)
@@ -26,14 +27,11 @@ module Tuya
26
27
  # @version = '0.0.1' unless @version
27
28
  @podspec = argv.shift_argument
28
29
 
29
- # p ("we will push version is #{@version} and before #{@is_commit}")
30
30
  end
31
31
 
32
32
  def run
33
33
  puts "Pushing the podspec: #{@podspec} to version: #{@version}".green
34
34
 
35
- require 'tycli/spec_repo'
36
-
37
35
  Tuya::SpecRepo.push(@version, @is_commit, @podspec)
38
36
  end
39
37
  end
@@ -1,5 +1,34 @@
1
1
  module Tuya
2
2
  class PodSpec
3
+
4
+ def self.ask_pod_spec
5
+
6
+ files = podspec_files(nil)
7
+
8
+ answer = ""
9
+
10
+ if files.size == 1
11
+ answer = files[0]
12
+ elsif files.size > 1
13
+ require 'tycli/util/ask'
14
+
15
+ podspecs = Array.new
16
+ files.each do |podspec_path|
17
+ podspecs.push File.basename(podspec_path)
18
+ end
19
+ answer = Tuya::TYAsk.ask_with_answers("which podspec will be pushed", podspecs)
20
+ end
21
+
22
+ answer
23
+
24
+ end
25
+
26
+ def self.pod_spec_version(podspec)
27
+ content = File.read("./#{podspec}")
28
+ version = (content.match(/s.version[\s]*=[\s]*'([\d]+.){2}[\d]+'/)[0]).match(/([\d]+.){2}[\d]+/)[0]
29
+ version.gsub(/(\d+)$/, ((version.split(".")[-1]).to_i + 1).to_s)
30
+ end
31
+
3
32
  def self.update(podspec, version)
4
33
 
5
34
  result = Array.new
@@ -51,7 +80,8 @@ module Tuya
51
80
  [path]
52
81
  else
53
82
  files = Pathname.glob('*.podspec{,.json}')
54
- raise Informative, "Couldn't find any podspec files in current directory" if files.empty?
83
+ # raise Informative, "Couldn't find any podspec files in current directory" if files.empty?
84
+ puts "Couldn't find any podspec files in current directory".red if files.empty?
55
85
  files
56
86
  end
57
87
  end
@@ -0,0 +1,60 @@
1
+ module Tuya
2
+ class TYAsk
3
+
4
+ def self.ask(question)
5
+ answer = ""
6
+ loop do
7
+ puts "\n#{question}?"
8
+
9
+ # @message_bank.show_prompt
10
+ print ">".green
11
+ answer = STDIN.gets.chomp
12
+
13
+ break if answer.length > 0
14
+
15
+ print "\nYou need to provide an answer."
16
+ end
17
+ answer
18
+ end
19
+
20
+ def self.ask_with_answers(question, possible_answers)
21
+
22
+ print "\n#{question}? ["
23
+
24
+ print_info = Proc.new {
25
+
26
+ possible_answers_string = possible_answers.each_with_index do |answer, i|
27
+ _answer = (i == 0) ? answer.underline : answer
28
+ print " " + _answer
29
+ print(" /") if i != possible_answers.length-1
30
+ end
31
+ print " ]\n"
32
+ }
33
+ print_info.call
34
+
35
+ answer = ""
36
+
37
+ loop do
38
+ # @message_bank.show_prompt
39
+ print ">".green
40
+ answer = STDIN.gets.downcase.chomp
41
+
42
+ answer = "yes" if answer == "y"
43
+ answer = "no" if answer == "n"
44
+
45
+ # default to first answer
46
+ if answer == ""
47
+ answer = possible_answers[0].downcase
48
+ print answer.yellow
49
+ end
50
+
51
+ break if possible_answers.map { |a| a.downcase }.include? answer
52
+
53
+ print "\nPossible answers are ["
54
+ print_info.call
55
+ end
56
+
57
+ answer
58
+ end
59
+ end
60
+ end
data/lib/tycli/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tycli
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tycli-public
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - fangdong
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-14 00:00:00.000000000 Z
11
+ date: 2018-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -59,7 +59,7 @@ dependencies:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.0.2
62
- type: :development
62
+ type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
@@ -73,7 +73,7 @@ dependencies:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
75
  version: 1.10.0
76
- type: :development
76
+ type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
@@ -87,7 +87,7 @@ dependencies:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.2'
90
- type: :development
90
+ type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
@@ -101,7 +101,7 @@ dependencies:
101
101
  - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
- type: :development
104
+ type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
@@ -142,6 +142,7 @@ files:
142
142
  - lib/tycli/repo/spec.rb
143
143
  - lib/tycli/spec_repo.rb
144
144
  - lib/tycli/system.rb
145
+ - lib/tycli/util/ask.rb
145
146
  - lib/tycli/util/puts_util.rb
146
147
  - lib/tycli/version.rb
147
148
  homepage: https://docs.tuya.com/cn/