Class: Flagit

Inherits:
Object
  • Object
show all
Defined in:
lib/flagit.rb

Defined Under Namespace

Classes: Configuration, Lookout, Postman, Redactor, TwitterOAuth

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



2
3
4
# File 'lib/flagit.rb', line 2

def configuration
  @configuration
end

Class Method Details

.configurationObject



17
18
19
# File 'lib/flagit.rb', line 17

def self.configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



25
26
27
# File 'lib/flagit.rb', line 25

def self.configure
  yield(configuration)
end

.loadObject



35
36
37
38
39
40
41
42
43
44
# File 'lib/flagit.rb', line 35

def self.load
  return unless File.exist?("#{root}/.config.json")
  loaded = JSON.parse(File.read("#{root}/.config.json"))
  configure do |config|
    config.consumer_key = loaded['consumer_key']
    config.consumer_secret = loaded['consumer_secret']
    config.access_token = loaded['access_token']
    config.access_token_secret = loaded['access_token_secret']
  end
end

.resetObject



21
22
23
# File 'lib/flagit.rb', line 21

def self.reset
  @configuration = Configuration.new
end

.rootObject



46
47
48
# File 'lib/flagit.rb', line 46

def self.root
  File.dirname __dir__
end

.run(message, path = '.') ⇒ Object



4
5
6
7
8
9
# File 'lib/flagit.rb', line 4

def self.run(message, path = '.')
  load
  lookout = Flagit::Lookout.new(path)
  redactor = Flagit::Redactor.new(lookout)
  Flagit::Postman.tweet(redactor.write_content(message))
end

.save!Object



29
30
31
32
33
# File 'lib/flagit.rb', line 29

def self.save!
  File.open("#{root}/.config.json","w") do |f|
    f.write(configuration.config_to_json)
  end
end

.usageObject



11
12
13
14
15
# File 'lib/flagit.rb', line 11

def self.usage
  puts "Usage: flagit \"<message>\" <path_to_repository_directory>"
  puts "Eg: flagit \"Just finished and launched Flagit v1.0.0!\""
  puts "Eg: flagit \"My first gem!\" ~/path/to/repo/dir"
end