Sha256: db3626cfffd4a16cd3900533cda94429c21f81f896085ec4ac70c25114a1ca60
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
unless defined?(Motion::Project::Config) raise "This file must be required within a RubyMotion project Rakefile." end class PhraseAppConfig attr_accessor :access_token, :enabled, :project_id CONFIG_FILE = './app/phraseapp_config.rb' def initialize(config) @config = config @enabled = false end def access_token=(access_token) @access_token = access_token create_phraseapp_config_file end def project_id=(project_id) @project_id = project_id create_phraseapp_config_file end def enabled=(enabled) @enabled = enabled create_phraseapp_config_file end private def create_phraseapp_config_file return unless @access_token if !config_file_exists? or config_file_content_outdated? File.open(CONFIG_FILE, 'w') { |f| f.write(config_file_content) } end files = @config.files.flatten files.unshift(CONFIG_FILE) unless files.find { |f| File.expand_path(f) == File.expand_path(CONFIG_FILE) } end def config_file_exists? File.exist?(CONFIG_FILE) end def config_file_content_outdated? config_file_exists? && File.read(CONFIG_FILE) != config_file_content end def config_file_content content = <<EOF # This file is automatically generated. Do not edit. PHRASEAPP_ENABLED = #{enabled} PHRASEAPP_ACCESS_TOKEN = "#{access_token}" PHRASEAPP_PROJECT_ID = "#{project_id}" EOF content end end module Motion module Project class Config variable :phraseapp def phraseapp @phraseapp ||= PhraseAppConfig.new(self) yield @phraseapp if block_given? @phraseapp end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
phraseapp-rubymotion-1.0.0 | lib/motion/project/phrase.rb |