Class: Pod::Command::Repo::Bump

Inherits:
Pod::Command::Repo show all
Defined in:
lib/pod/command/bump-version.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Bump

Returns a new instance of Bump.



24
25
26
27
# File 'lib/pod/command/bump-version.rb', line 24

def initialize(argv)
    @tag_version = argv.shift_argument
    super
end

Class Method Details

.optionsObject



20
21
22
# File 'lib/pod/command/bump-version.rb', line 20

def self.options
    [].concat(super)
end

Instance Method Details

#modify_podspec(path, version) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/pod/command/bump-version.rb', line 50

def modify_podspec(path, version)
    unless version =~ /^(\d+\.)?(\d+\.)?(\*|\d+)$/
        UI.puts "Invalid version #{version}"
        return 
    end
    
    unless File.exist?path
        UI.puts "Podspec file not found"
        return
    end
            
    File.open(path, "r+") do |f|
        s = ""
        f.each_line do |line|
            if line.to_s =~ /s\.version\s*=\s*'|"(\d+\.)?(\d+\.)?(\*|\d+)'|"/
                line = line.sub(/(\d+\.)?(\d+\.)?(\*|\d+)/) do |match| 
                    version.to_s
                end
            end
            s += line
        end
        File.open(path, "w+") do |f| f.write(s) end
    end 
end

#podspec_filesArray<Pathname>

def podspec_files

if @podspec
    path = Pathname(@podspec)
    raise Informative, "Couldn't find #{@podspec}" unless path.exist?
    [path]
else
    files = Pathname.glob('**/*.podspec')
    raise Informative, "Couldn't find any podspec files in current directory" if files.empty?
    files
end

end

Returns:

  • (Array<Pathname>)

    The path of the specifications to push.

Raises:

  • (Informative)


89
90
91
92
93
# File 'lib/pod/command/bump-version.rb', line 89

def podspec_files
    files = Pathname.glob('**/*.podspec')
    raise Informative, "Couldn't find any podspec files in current directory" if files.empty?
    files
end

#runObject



39
40
41
42
43
44
45
46
47
48
# File 'lib/pod/command/bump-version.rb', line 39

def run
    podspec_files.each do |spec_file|
        spec = Pod::Specification.from_file(spec_file)
        if @tag_version.to_s != spec.version.to_s
            modify_podspec(spec_file, @tag_version)
        else 
            UI.puts " - [No change] #{spec.name}: #{@tag_version}"
        end
    end
end

#validate!Object



29
30
31
32
33
34
35
36
37
# File 'lib/pod/command/bump-version.rb', line 29

def validate!
    super
    help! 'A bump version is required.' unless @tag_version
    unless @tag_version
        raise Informative,
            "A bump version is required." \
            '`pod repo bump 0.1.0`.'
    end
end